Skip to contentSkip to conversation

Nokia H4+ support

PATCH Superseded Sebastian Reichel 5 participants 27 messages Mar 21, 2017 – Mar 23, 2017

Subsystems (5)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Nokia H4+ support

Hi,

This is the second revision from the Nokia H4+ bluetooth patchset. I fixed all comments I received and verified that scanning for bluetooth devices still works on N950.

The patchset is based upon 4.11-rc1 and is also available from the following branch:

https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-n900.git nokia-bt-serdev-v2

-- Sebastian

Rob Herring (1):
Bluetooth: hci_uart: add serdev driver support library

Sebastian Reichel (10):
Bluetooth: hci_uart: add support for word alignment
Bluetooth: hci_serdev: do not open device in hci open
tty: serial: omap: add UPF_BOOT_AUTOCONF flag for DT init
serdev: add serdev_device_wait_until_sent
serdev: implement get/set tiocm
serdev: add helpers for cts and rts handling
dt-bindings: net: bluetooth: Add nokia-bluetooth
Bluetooth: add nokia driver
ARM: dts: N900: Add bluetooth
ARM: dts: N9/N950: add bluetooth

 .../devicetree/bindings/net/nokia-bluetooth.txt    |  51 ++
 arch/arm/boot/dts/omap3-n900.dts                   |  23 +-
 arch/arm/boot/dts/omap3-n950-n9.dtsi               |  32 +
 drivers/bluetooth/Kconfig                          |  12 +
 drivers/bluetooth/Makefile                         |   3 +
 drivers/bluetooth/hci_h4.c                         |  17 +
 drivers/bluetooth/hci_ldisc.c                      |   4 +
 drivers/bluetooth/hci_nokia.c                      | 819 +++++++++++++++++++++
 drivers/bluetooth/hci_serdev.c                     | 355 +++++++++
 drivers/bluetooth/hci_uart.h                       |   7 +
 drivers/tty/serdev/core.c                          |  33 +
 drivers/tty/serdev/serdev-ttyport.c                |  39 +-
 drivers/tty/serial/omap-serial.c                   |   3 +
 include/linux/serdev.h                             |  47 ++
 14 files changed, 1442 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/nokia-bluetooth.txt
 create mode 100644 drivers/bluetooth/hci_nokia.c
 create mode 100644 drivers/bluetooth/hci_serdev.c
Signature · 1 line
2.11.0
#1 lore raw

PATCH v2 1/11 Bluetooth: hci_uart: add support for word alignment

This will be used by Nokia's H4+ protocol, which
uses 2-byte aligned packets.

---
Changes since PATCHv1:
* use u8 instead of uint8_t

---
 drivers/bluetooth/hci_h4.c    | 17 +++++++++++++++++
 drivers/bluetooth/hci_ldisc.c |  4 ++++
 drivers/bluetooth/hci_uart.h  |  3 +++
 3 files changed, 24 insertions(+)
drivers/bluetooth/hci_h4.c +17 -0
index 635597b6e168..82e5a32b87a4 100644
@@ -171,9 +171,20 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
 			    const unsigned char *buffer, int count,
 			    const struct h4_recv_pkt *pkts, int pkts_count)
 {
+	struct hci_uart *hu = hci_get_drvdata(hdev);
+	u8 alignment = hu->alignment;
+
 	while (count) {
 		int i, len;
 
+		/* remove padding bytes from buffer */
+		for (; hu->padding && count > 0; hu->padding--) {
+			count--;
+			buffer++;
+		}
+		if (!count)
+			break;
+
 		if (!skb) {
 			for (i = 0; i < pkts_count; i++) {
 				if (buffer[0] != (&pkts[i])->type)
@@ -253,11 +264,17 @@ struct sk_buff *h4_recv_buf(struct hci_dev *hdev, struct sk_buff *skb,
 			}
 
 			if (!dlen) {
+				hu->padding = (skb->len - 1) % alignment;
+				hu->padding = (alignment - hu->padding) % alignment;
+
 				/* No more data, complete frame */
 				(&pkts[i])->recv(hdev, skb);
 				skb = NULL;
 			}
 		} else {
+			hu->padding = (skb->len - 1) % alignment;
+			hu->padding = (alignment - hu->padding) % alignment;
+
 			/* Complete frame */
 			(&pkts[i])->recv(hdev, skb);
 			skb = NULL;
drivers/bluetooth/hci_ldisc.c +4 -0
index 9497c469efd2..0ec8a94bd712 100644
@@ -459,6 +459,10 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 	hu->tty = tty;
 	tty->receive_room = 65536;
 
+	/* disable alignment support by default */
+	hu->alignment = 1;
+	hu->padding = 0;
+
 	INIT_WORK(&hu->init_ready, hci_uart_init_work);
 	INIT_WORK(&hu->write_work, hci_uart_write_work);
 
drivers/bluetooth/hci_uart.h +3 -0
index 070139513e65..4aff50960cac 100644
@@ -92,6 +92,9 @@ struct hci_uart {
 
 	unsigned int init_speed;
 	unsigned int oper_speed;
+
+	u8			alignment;
+	u8			padding;
 };
 
 /* HCI_UART proto flag bits */
Signature · 1 line
2.11.0
#2 lore raw

PATCH v2 2/11 Bluetooth: hci_uart: add serdev driver support library

In reply to Sebastian Reichel

From: Rob Herring <[email protected]>

This adds library functions for serdev based BT drivers. This is largely copied from hci_ldisc.c and modified to use serdev calls. There's a little bit of duplication, but I avoided intermixing this as the ldisc code should eventually go away.

Cc Marcel Holtmann <[email protected]>
Cc Gustavo Padovan <[email protected]>
Cc Johan Hedberg <[email protected]>
[Fix style issues reported by Pavel]

---
Changes since PATCHv1:
* Drop FSF address from license section
* Add error message if hu->proto->set_baudrate fails
* Remove useless label/goto in hci_uart_setup
* Use proper kerneldoc for hci_uart_write_wakeup
* Use proper kerneldoc for hci_uart_receive_buf
* Wrap hci_uart_register_device define to get < 80 chars
* Use do..while instead of goto restart in hci_uart_write_work
* The file checkpatch clean now

---
 drivers/bluetooth/Makefile     |   1 +
 drivers/bluetooth/hci_serdev.c | 361 +++++++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/hci_uart.h   |   4 +
 3 files changed, 366 insertions(+)
 create mode 100644 drivers/bluetooth/hci_serdev.c
drivers/bluetooth/Makefile +1 -0
index 80627187c8b6..fd571689eed6 100644
@@ -29,6 +29,7 @@ btmrvl-y			:= btmrvl_main.o
 btmrvl-$(CONFIG_DEBUG_FS)	+= btmrvl_debugfs.o
 
 hci_uart-y				:= hci_ldisc.o
+hci_uart-$(CONFIG_SERIAL_DEV_BUS)	+= hci_serdev.o
 hci_uart-$(CONFIG_BT_HCIUART_H4)	+= hci_h4.o
 hci_uart-$(CONFIG_BT_HCIUART_BCSP)	+= hci_bcsp.o
 hci_uart-$(CONFIG_BT_HCIUART_LL)	+= hci_ll.o
drivers/bluetooth/hci_serdev.c new file +361 -0

361 lines not on this page · raw message

drivers/bluetooth/hci_uart.h +4 -0
index 4aff50960cac..1b41c661bbb8 100644
@@ -58,6 +58,7 @@
 #define HCI_UART_VND_DETECT	5
 
 struct hci_uart;
+struct serdev_device;
 
 struct hci_uart_proto {
 	unsigned int id;
@@ -77,6 +78,7 @@ struct hci_uart_proto {
 
 struct hci_uart {
 	struct tty_struct	*tty;
+	struct serdev_device	*serdev;
 	struct hci_dev		*hdev;
 	unsigned long		flags;
 	unsigned long		hdev_flags;
@@ -108,6 +110,8 @@ struct hci_uart {
 
 int hci_uart_register_proto(const struct hci_uart_proto *p);
 int hci_uart_unregister_proto(const struct hci_uart_proto *p);
+int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p);
+
 int hci_uart_tx_wakeup(struct hci_uart *hu);
 int hci_uart_init_ready(struct hci_uart *hu);
 void hci_uart_init_tty(struct hci_uart *hu);
Signature · 1 line
2.11.0
Acked-by on v2 2/11
#3 lore raw

Re: [PATCHv2 02/11] Bluetooth: hci_uart: add serdev driver support library

Quoted 7 lines · Sebastian Reichel

From: Rob Herring <[email protected]>

This adds library functions for serdev based BT drivers. This is largely copied from hci_ldisc.c and modified to use serdev calls. There's a little bit of duplication, but I avoided intermixing this as the ldisc code should eventually go away.

Quoted 7 lines
Cc Marcel Holtmann <[email protected]>
Cc Gustavo Padovan <[email protected]>
Cc Johan Hedberg <[email protected]>
[Fix style issues reported by Pavel]
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#4 lore raw

PATCH v2 3/11 Bluetooth: hci_serdev: do not open device in hci open

In reply to Sebastian Reichel

The device driver may need to communicate with the UART device while the Bluetooth device is closed (e.g. due to interrupts).

---
 drivers/bluetooth/hci_serdev.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/bluetooth/hci_serdev.c +3 -9
index f5ccb2c7ef92..3b8ac0ece3fb 100644
@@ -104,13 +104,9 @@ static void hci_uart_write_work(struct work_struct *work)
 /* Initialize device */
 static int hci_uart_open(struct hci_dev *hdev)
 {
-	struct hci_uart *hu  = hci_get_drvdata(hdev);
-
 	BT_DBG("%s %p", hdev->name, hdev);
 
-	serdev_device_set_client_ops(hu->serdev, &hci_serdev_client_ops);
-
-	return serdev_device_open(hu->serdev);
+	return 0;
 }
 
 /* Reset device */
@@ -136,15 +132,11 @@ static int hci_uart_flush(struct hci_dev *hdev)
 /* Close device */
 static int hci_uart_close(struct hci_dev *hdev)
 {
-	struct hci_uart *hu  = hci_get_drvdata(hdev);
-
 	BT_DBG("hdev %p", hdev);
 
 	hci_uart_flush(hdev);
 	hdev->flush = NULL;
 
-	serdev_device_close(hu->serdev);
-
 	return 0;
 }
 
@@ -289,6 +281,8 @@ int hci_uart_register_device(struct hci_uart *hu,
 
 	BT_DBG("");
 
+	serdev_device_set_client_ops(hu->serdev, &hci_serdev_client_ops);
+
 	err = p->open(hu);
 	if (err)
 		return err;
Signature · 1 line
2.11.0
#5 lore raw

PATCH v2 4/11 tty: serial: omap: add UPF_BOOT_AUTOCONF flag for DT init

In reply to Sebastian Reichel

The UPF_BOOT_AUTOCONF flag is needed for proper
flow control support.

---
 drivers/tty/serial/omap-serial.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/tty/serial/omap-serial.c +3 -0
index 6c6f82ad8d5c..a4734649a0f0 100644
@@ -1597,6 +1597,9 @@ static struct omap_uart_port_info *of_get_uart_port_info(struct device *dev)
 
 	of_property_read_u32(dev->of_node, "clock-frequency",
 					 &omap_up_info->uartclk);
+
+	omap_up_info->flags = UPF_BOOT_AUTOCONF;
+
 	return omap_up_info;
 }
 
Signature · 1 line
2.11.0
Acked-by on v2 4/11
#6 lore raw

Re: [PATCHv2 04/11] tty: serial: omap: add UPF_BOOT_AUTOCONF flag for DT init

Quoted 4 lines · Sebastian Reichel

The UPF_BOOT_AUTOCONF flag is needed for proper
flow control support.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#7 lore raw

PATCH v2 5/11 serdev: add serdev_device_wait_until_sent

In reply to Sebastian Reichel

Add method, which waits until the transmission buffer has been sent. Note, that the change in ttyport_write_wakeup is related, since tty_wait_until_sent will hang without that change.

---
 drivers/tty/serdev/core.c           | 11 +++++++++++
 drivers/tty/serdev/serdev-ttyport.c | 15 ++++++++++++++-
 include/linux/serdev.h              |  3 +++
 3 files changed, 28 insertions(+), 1 deletion(-)
drivers/tty/serdev/core.c +11 -0
index f4c6c90add78..a63b74031e22 100644
@@ -173,6 +173,17 @@ void serdev_device_set_flow_control(struct serdev_device *serdev, bool enable)
 }
 EXPORT_SYMBOL_GPL(serdev_device_set_flow_control);
 
+void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->wait_until_sent)
+		return;
+
+	ctrl->ops->wait_until_sent(ctrl, timeout);
+}
+EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
+
 static int serdev_drv_probe(struct device *dev)
 {
 	const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
drivers/tty/serdev/serdev-ttyport.c +14 -1
index d05393594f15..db2bc601e554 100644
@@ -14,6 +14,7 @@
 #include <linux/serdev.h>
 #include <linux/tty.h>
 #include <linux/tty_driver.h>
+#include <linux/poll.h>
 
 #define SERPORT_ACTIVE		1
 
@@ -47,10 +48,13 @@ static void ttyport_write_wakeup(struct tty_port *port)
 	struct serport *serport = serdev_controller_get_drvdata(ctrl);
 
 	if (!test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &port->tty->flags))
-		return;
+		goto out;
 
 	if (test_bit(SERPORT_ACTIVE, &serport->flags))
 		serdev_controller_write_wakeup(ctrl);
+
+out:
+	wake_up_interruptible_poll(&port->tty->write_wait, POLLOUT);
 }
 
 static const struct tty_port_client_operations client_ops = {
@@ -167,6 +171,14 @@ static void ttyport_set_flow_control(struct serdev_controller *ctrl, bool enable
 	tty_set_termios(tty, &ktermios);
 }
 
+static void ttyport_wait_until_sent(struct serdev_controller *ctrl, long timeout)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+
+	tty_wait_until_sent(tty, timeout);
+}
+
 static const struct serdev_controller_ops ctrl_ops = {
 	.write_buf = ttyport_write_buf,
 	.write_flush = ttyport_write_flush,
@@ -175,6 +187,7 @@ static const struct serdev_controller_ops ctrl_ops = {
 	.close = ttyport_close,
 	.set_flow_control = ttyport_set_flow_control,
 	.set_baudrate = ttyport_set_baudrate,
+	.wait_until_sent = ttyport_wait_until_sent,
 };
 
 struct device *serdev_tty_port_register(struct tty_port *port,
include/linux/serdev.h +3 -0
index 9519da6253a8..a308b206d204 100644
@@ -81,6 +81,7 @@ struct serdev_controller_ops {
 	void (*close)(struct serdev_controller *);
 	void (*set_flow_control)(struct serdev_controller *, bool);
 	unsigned int (*set_baudrate)(struct serdev_controller *, unsigned int);
+	void (*wait_until_sent)(struct serdev_controller *, long);
 };
 
 /**
@@ -186,6 +187,7 @@ int serdev_device_open(struct serdev_device *);
 void serdev_device_close(struct serdev_device *);
 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
 void serdev_device_set_flow_control(struct serdev_device *, bool);
+void serdev_device_wait_until_sent(struct serdev_device *, long);
 int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
 void serdev_device_write_flush(struct serdev_device *);
 int serdev_device_write_room(struct serdev_device *);
@@ -223,6 +225,7 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev
 	return 0;
 }
 static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {}
+static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {}
 static inline int serdev_device_write_buf(struct serdev_device *sdev, const unsigned char *buf, size_t count)
 {
 	return -ENODEV;
Signature · 1 line
2.11.0
Acked-by on v2 5/11
#8 lore raw

Re: [PATCHv2 05/11] serdev: add serdev_device_wait_until_sent

Hi!

drivers/tty/serdev/serdev-ttyport.c static void ttyport_write_wakeup(struct tty_port *port) · line 56

Quoted 11 lines
drivers/tty/serdev/serdev-ttyport.c +3 -1
@@ -47,10 +48,13 @@ static void ttyport_write_wakeup(struct tty_port *port)
 	struct serport *serport = serdev_controller_get_drvdata(ctrl);
 
 	if (!test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &port->tty->flags))
-		return;
+		goto out;
 
 	if (test_bit(SERPORT_ACTIVE, &serport->flags))
 		serdev_controller_write_wakeup(ctrl);
+
+out:

I'd do "if (test_and_clear_bit() && test_bit()) serdev_()" here. Otherwise it looks fine.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw

PATCH v2 6/11 serdev: implement get/set tiocm

In reply to Sebastian Reichel

Add method for getting and setting tiocm.

---
 drivers/tty/serdev/core.c           | 22 ++++++++++++++++++++++
 drivers/tty/serdev/serdev-ttyport.c | 24 ++++++++++++++++++++++++
 include/linux/serdev.h              | 13 +++++++++++++
 3 files changed, 59 insertions(+)
drivers/tty/serdev/core.c +22 -0
index a63b74031e22..1e1cbae3a0ea 100644
@@ -184,6 +184,28 @@ void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
 }
 EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
 
+int serdev_device_get_tiocm(struct serdev_device *serdev)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->get_tiocm)
+		return -ENOTSUPP;
+
+	return ctrl->ops->get_tiocm(ctrl);
+}
+EXPORT_SYMBOL_GPL(serdev_device_get_tiocm);
+
+int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->set_tiocm)
+		return -ENOTSUPP;
+
+	return ctrl->ops->set_tiocm(ctrl, set, clear);
+}
+EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
+
 static int serdev_drv_probe(struct device *dev)
 {
 	const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
drivers/tty/serdev/serdev-ttyport.c +24 -0
index db2bc601e554..c5bdb901ff11 100644
@@ -179,6 +179,28 @@ static void ttyport_wait_until_sent(struct serdev_controller *ctrl, long timeout
 	tty_wait_until_sent(tty, timeout);
 }
 
+static int ttyport_get_tiocm(struct serdev_controller *ctrl)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+
+	if (!tty->ops->tiocmget)
+		return -ENOTSUPP;
+
+	return tty->driver->ops->tiocmget(tty);
+}
+
+static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, unsigned int clear)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+
+	if (!tty->ops->tiocmset)
+		return -ENOTSUPP;
+
+	return tty->driver->ops->tiocmset(tty, set, clear);
+}
+
 static const struct serdev_controller_ops ctrl_ops = {
 	.write_buf = ttyport_write_buf,
 	.write_flush = ttyport_write_flush,
@@ -188,6 +210,8 @@ static const struct serdev_controller_ops ctrl_ops = {
 	.set_flow_control = ttyport_set_flow_control,
 	.set_baudrate = ttyport_set_baudrate,
 	.wait_until_sent = ttyport_wait_until_sent,
+	.get_tiocm = ttyport_get_tiocm,
+	.set_tiocm = ttyport_set_tiocm,
 };
 
 struct device *serdev_tty_port_register(struct tty_port *port,
include/linux/serdev.h +13 -0
index a308b206d204..3ad1d695f947 100644
@@ -15,6 +15,7 @@
 
 #include <linux/types.h>
 #include <linux/device.h>
+#include <asm-generic/termios.h>
 
 struct serdev_controller;
 struct serdev_device;
@@ -82,6 +83,8 @@ struct serdev_controller_ops {
 	void (*set_flow_control)(struct serdev_controller *, bool);
 	unsigned int (*set_baudrate)(struct serdev_controller *, unsigned int);
 	void (*wait_until_sent)(struct serdev_controller *, long);
+	int (*get_tiocm)(struct serdev_controller *);
+	int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int);
 };
 
 /**
@@ -188,6 +191,8 @@ void serdev_device_close(struct serdev_device *);
 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
 void serdev_device_set_flow_control(struct serdev_device *, bool);
 void serdev_device_wait_until_sent(struct serdev_device *, long);
+int serdev_device_get_tiocm(struct serdev_device *);
+int serdev_device_set_tiocm(struct serdev_device *, int, int);
 int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
 void serdev_device_write_flush(struct serdev_device *);
 int serdev_device_write_room(struct serdev_device *);
@@ -226,6 +231,14 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev
 }
 static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {}
 static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {}
+static inline int serdev_device_get_tiocm(struct serdev_device *serdev)
+{
+	return -ENOTSUPP;
+}
+static inline int serdev_device_set_tiocm(struct serdev_controller *serdev, int set, int clear)
+{
+	return -ENOTSUPP;
+}
 static inline int serdev_device_write_buf(struct serdev_device *sdev, const unsigned char *buf, size_t count)
 {
 	return -ENODEV;
Signature · 1 line
2.11.0
#10 lore raw

[PATCHv2.1] serdev: implement get/set tiocm

Add method for getting and setting tiocm.

---
Changes since PATCHv2:
* fix serdev_device_set_tiocm inline definition for disabled SERDEV
* use <linux/termios.h> instead of <asm-generic/termios.h>

---
 drivers/tty/serdev/core.c           | 22 ++++++++++++++++++++++
 drivers/tty/serdev/serdev-ttyport.c | 24 ++++++++++++++++++++++++
 include/linux/serdev.h              | 13 +++++++++++++
 3 files changed, 59 insertions(+)
drivers/tty/serdev/core.c +22 -0
index a63b74031e22..1e1cbae3a0ea 100644
@@ -184,6 +184,28 @@ void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
 }
 EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
 
+int serdev_device_get_tiocm(struct serdev_device *serdev)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->get_tiocm)
+		return -ENOTSUPP;
+
+	return ctrl->ops->get_tiocm(ctrl);
+}
+EXPORT_SYMBOL_GPL(serdev_device_get_tiocm);
+
+int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->set_tiocm)
+		return -ENOTSUPP;
+
+	return ctrl->ops->set_tiocm(ctrl, set, clear);
+}
+EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
+
 static int serdev_drv_probe(struct device *dev)
 {
 	const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
drivers/tty/serdev/serdev-ttyport.c +24 -0
index db2bc601e554..c5bdb901ff11 100644
@@ -179,6 +179,28 @@ static void ttyport_wait_until_sent(struct serdev_controller *ctrl, long timeout
 	tty_wait_until_sent(tty, timeout);
 }
 
+static int ttyport_get_tiocm(struct serdev_controller *ctrl)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+
+	if (!tty->ops->tiocmget)
+		return -ENOTSUPP;
+
+	return tty->driver->ops->tiocmget(tty);
+}
+
+static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, unsigned int clear)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+
+	if (!tty->ops->tiocmset)
+		return -ENOTSUPP;
+
+	return tty->driver->ops->tiocmset(tty, set, clear);
+}
+
 static const struct serdev_controller_ops ctrl_ops = {
 	.write_buf = ttyport_write_buf,
 	.write_flush = ttyport_write_flush,
@@ -188,6 +210,8 @@ static const struct serdev_controller_ops ctrl_ops = {
 	.set_flow_control = ttyport_set_flow_control,
 	.set_baudrate = ttyport_set_baudrate,
 	.wait_until_sent = ttyport_wait_until_sent,
+	.get_tiocm = ttyport_get_tiocm,
+	.set_tiocm = ttyport_set_tiocm,
 };
 
 struct device *serdev_tty_port_register(struct tty_port *port,
include/linux/serdev.h +13 -0
index a308b206d204..e29a270f603c 100644
@@ -15,6 +15,7 @@
 
 #include <linux/types.h>
 #include <linux/device.h>
+#include <linux/termios.h>
 
 struct serdev_controller;
 struct serdev_device;
@@ -82,6 +83,8 @@ struct serdev_controller_ops {
 	void (*set_flow_control)(struct serdev_controller *, bool);
 	unsigned int (*set_baudrate)(struct serdev_controller *, unsigned int);
 	void (*wait_until_sent)(struct serdev_controller *, long);
+	int (*get_tiocm)(struct serdev_controller *);
+	int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int);
 };
 
 /**
@@ -188,6 +191,8 @@ void serdev_device_close(struct serdev_device *);
 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
 void serdev_device_set_flow_control(struct serdev_device *, bool);
 void serdev_device_wait_until_sent(struct serdev_device *, long);
+int serdev_device_get_tiocm(struct serdev_device *);
+int serdev_device_set_tiocm(struct serdev_device *, int, int);
 int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
 void serdev_device_write_flush(struct serdev_device *);
 int serdev_device_write_room(struct serdev_device *);
@@ -226,6 +231,14 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev
 }
 static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {}
 static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {}
+static inline int serdev_device_get_tiocm(struct serdev_device *serdev)
+{
+	return -ENOTSUPP;
+}
+static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
+{
+	return -ENOTSUPP;
+}
 static inline int serdev_device_write_buf(struct serdev_device *sdev, const unsigned char *buf, size_t count)
 {
 	return -ENODEV;
Signature · 1 line
2.11.0
Acked-by
#12 lore raw

Re: [PATCHv2.1] serdev: implement get/set tiocm

In reply to Sebastian Reichel
Quoted 7 lines · Sebastian Reichel

Add method for getting and setting tiocm.

---
Changes since PATCHv2:
* fix serdev_device_set_tiocm inline definition for disabled SERDEV
* use <linux/termios.h> instead of <asm-generic/termios.h>

Quoted 5 lines
---
 drivers/tty/serdev/core.c           | 22 ++++++++++++++++++++++
 drivers/tty/serdev/serdev-ttyport.c | 24 ++++++++++++++++++++++++
 include/linux/serdev.h              | 13 +++++++++++++
 3 files changed, 59 insertions(+)

I'm not that big of a fan of {set,get}_tiocm, but I guess it is fine.

Rob

#13 lore raw

PATCH v2 7/11 serdev: add helpers for cts and rts handling

In reply to Sebastian Reichel

Add serdev helper functions for handling of cts and rts lines using the serdev's tiocm functions.

---
 include/linux/serdev.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
include/linux/serdev.h +31 -0
index 3ad1d695f947..8cdce2ea0d51 100644
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <linux/device.h>
 #include <asm-generic/termios.h>
+#include <linux/delay.h>
 
 struct serdev_controller;
 struct serdev_device;
@@ -254,6 +255,36 @@ static inline int serdev_device_write_room(struct serdev_device *sdev)
 
 #endif /* CONFIG_SERIAL_DEV_BUS */
 
+static inline bool serdev_device_get_cts(struct serdev_device *serdev)
+{
+	int status = serdev_device_get_tiocm(serdev);
+	return !!(status & TIOCM_CTS);
+}
+
+static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
+{
+	unsigned long timeout;
+	bool signal;
+
+	timeout = jiffies + msecs_to_jiffies(timeout_ms);
+	while (!time_after(jiffies, timeout)) {
+		signal = serdev_device_get_cts(serdev);
+		if (signal == state)
+			return 0;
+		usleep_range(1000, 2000);
+	}
+
+	return -ETIMEDOUT;
+}
+
+static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
+{
+	if (enable)
+		return serdev_device_set_tiocm(serdev, TIOCM_OUT2 | TIOCM_RTS, 0);
+	else
+		return serdev_device_set_tiocm(serdev, 0, TIOCM_OUT2 | TIOCM_RTS);
+}
+
 /*
  * serdev hooks into TTY core
  */
Signature · 1 line
2.11.0
Acked-by on v2 7/11
#14 lore raw

Re: [PATCHv2 07/11] serdev: add helpers for cts and rts handling

Quoted 27 lines · Sebastian Reichel

Add serdev helper functions for handling of cts and rts lines using the serdev's tiocm functions.

---
 include/linux/serdev.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
include/linux/serdev.h +4 -0
index 3ad1d695f947..8cdce2ea0d51 100644
@@ -16,6 +16,7 @@
 #include <linux/types.h>
 #include <linux/device.h>
 #include <asm-generic/termios.h>
+#include <linux/delay.h>
 
 struct serdev_controller;
 struct serdev_device;
@@ -254,6 +255,36 @@ static inline int serdev_device_write_room(struct serdev_device *sdev)
 
 #endif /* CONFIG_SERIAL_DEV_BUS */
 
+static inline bool serdev_device_get_cts(struct serdev_device *serdev)
+{
+       int status = serdev_device_get_tiocm(serdev);

include/linux/serdev.h static inline int serdev_device_write_room(struct serdev_device *sdev) · line 270

Quoted 10 lines
include/linux/serdev.h +10 -0
+       return !!(status & TIOCM_CTS);
+}
+
+static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
+{
+       unsigned long timeout;
+       bool signal;
+
+       timeout = jiffies + msecs_to_jiffies(timeout_ms);
+       while (!time_after(jiffies, timeout)) {

You can use time_is_after_jiffies(timeout) instead of !time_after.

include/linux/serdev.h static inline int serdev_device_write_room(struct serdev_device *sdev) · line 283

Quoted 13 lines
include/linux/serdev.h +13 -0
+               signal = serdev_device_get_cts(serdev);
+               if (signal == state)
+                       return 0;
+               usleep_range(1000, 2000);
+       }
+
+       return -ETIMEDOUT;
+}
+
+static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
+{
+       if (enable)
+               return serdev_device_set_tiocm(serdev, TIOCM_OUT2 | TIOCM_RTS, 0);

Perhaps a comment why we're messing with OUT2.

With those,

Quoted 10 lines
include/linux/serdev.h +4 -1
+       else
+               return serdev_device_set_tiocm(serdev, 0, TIOCM_OUT2 | TIOCM_RTS);
+}
+
 /*
  * serdev hooks into TTY core
  */
--

2.11.0

#15 lore raw

PATCH v2 8/11 dt-bindings: net: bluetooth: Add nokia-bluetooth

In reply to Sebastian Reichel

Add binding document for serial bluetooth chips using Nokia H4+ protocol.

---
Changes since PATCHv1:
* change compatible strings
* mention active high/low state for GPIOs

---
 .../devicetree/bindings/net/nokia-bluetooth.txt    | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/nokia-bluetooth.txt
Documentation/devicetree/bindings/net/nokia-bluetooth.txt new file +51 -0
new file mode 100644
index 000000000000..42be7dc9a70b
@@ -0,0 +1,51 @@
+Nokia Bluetooth Chips
+---------------------
+
+Nokia phones often come with UART connected bluetooth chips from different
+vendors and modified device API. Those devices speak a protocol named H4+
+(also known as h4p) by Nokia, which is similar to the H4 protocol from the
+Bluetooth standard. In addition to the H4 protocol it specifies two more
+UART status lines for wakeup of UART transceivers to improve power management
+and a few new packet types used to negotiate uart speed.
+
+Required properties:
+
+ - compatible: should contain "nokia,h4p-bluetooth" as well as one of the following:
+   * "brcm,bcm2048-nokia"
+   * "ti,wl1271-bluetooth-nokia"
+ - reset-gpios: GPIO specifier, used to reset the BT module (active low)
+ - bluetooth-wakeup-gpios: GPIO specifier, used to wakeup the BT module (active high)
+ - host-wakeup-gpios: GPIO specifier, used to wakeup the host processor (active high)
+ - clock-names: should be "sysclk"
+ - clocks: should contain a clock specifier for every name in clock-names
+
+Optional properties:
+
+ - None
+
+Example:
+
+/ {
+       /* controlled (enabled/disabled) directly by BT module */
+       bluetooth_clk: vctcxo {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <38400000>;
+       };
+};
+
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2_pins>;
+
+       bluetooth {
+               compatible = "ti,wl1271-bluetooth-nokia", "nokia,h4p-bluetooth";
+
+               reset-gpios = <&gpio1 26 GPIO_ACTIVE_LOW>; /* gpio26 */
+               host-wakeup-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>; /* gpio101 */
+               bluetooth-wakeup-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>; /* gpio37 */
+
+               clocks = <&bluetooth_clk>;
+               clock-names = "sysclk";
+       };
+};
Signature · 1 line
2.11.0
Acked-by on v2 8/11
#16 lore raw

Re: [PATCHv2 08/11] dt-bindings: net: bluetooth: Add nokia-bluetooth

Quoted 4 lines · Sebastian Reichel

Add binding document for serial bluetooth chips using Nokia H4+ protocol.

Quoted 8 lines

---
Changes since PATCHv1:
* change compatible strings
* mention active high/low state for GPIOs

---
 .../devicetree/bindings/net/nokia-bluetooth.txt    | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/nokia-bluetooth.txt
#17 lore raw

PATCH v2 9/11 Bluetooth: add nokia driver

In reply to Sebastian Reichel

This adds a driver for the Nokia H4+ protocol, which is used at least on the Nokia N9, N900 & N950.

---
Changes since PATCHv1:
* replace __u8 and uint8_t with u8
* replace __u16 and uint16_t with u16
* drop BT_BAUDRATE_DIVIDER and use btdev->sysclk_speed * 10 instead
* fix wording of a sentence
* fix error path of negotation & alive package receive functions
* replaced nokia_wait_for_cts with newly introduced serdev function
* use "nokia,h4p-bluetooth" as compatible string

---
 drivers/bluetooth/Kconfig     |  12 +
 drivers/bluetooth/Makefile    |   2 +
 drivers/bluetooth/hci_nokia.c | 819 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 833 insertions(+)
 create mode 100644 drivers/bluetooth/hci_nokia.c
drivers/bluetooth/Kconfig +12 -0
index c2c14a12713b..2e3e4d3547ad 100644
@@ -86,6 +86,18 @@ config BT_HCIUART_H4
 
 	  Say Y here to compile support for HCI UART (H4) protocol.
 
+config BT_HCIUART_NOKIA
+	tristate "UART Nokia H4+ protocol support"
+	depends on BT_HCIUART
+	depends on SERIAL_DEV_BUS
+	depends on PM
+	help
+	  Nokia H4+ is serial protocol for communication between Bluetooth
+	  device and host. This protocol is required for Bluetooth devices
+	  with UART interface in Nokia devices.
+
+	  Say Y here to compile support for Nokia's H4+ protocol.
+
 config BT_HCIUART_BCSP
 	bool "BCSP protocol support"
 	depends on BT_HCIUART
drivers/bluetooth/Makefile +2 -0
index fd571689eed6..a7f237320f4b 100644
@@ -25,6 +25,8 @@ obj-$(CONFIG_BT_BCM)		+= btbcm.o
 obj-$(CONFIG_BT_RTL)		+= btrtl.o
 obj-$(CONFIG_BT_QCA)		+= btqca.o
 
+obj-$(CONFIG_BT_HCIUART_NOKIA)	+= hci_nokia.o
+
 btmrvl-y			:= btmrvl_main.o
 btmrvl-$(CONFIG_DEBUG_FS)	+= btmrvl_debugfs.o
 
drivers/bluetooth/hci_nokia.c new file +819 -0

819 lines not on this page · raw message

Signature · 1 line
2.11.0
#18 lore raw

Re: [PATCHv2 09/11] Bluetooth: add nokia driver

Quoted 6 lines · Sebastian Reichel

This adds a driver for the Nokia H4+ protocol, which is used at least on the Nokia N9, N900 & N950.

---

drivers/bluetooth/hci_nokia.c line 720

Quoted 8 lines
drivers/bluetooth/hci_nokia.c new file +8 -0
+       btdev->wakeup_host = devm_gpiod_get(dev, "host-wakeup", GPIOD_IN);
+       if (IS_ERR(btdev->wakeup_host)) {
+               err = PTR_ERR(btdev->wakeup_host);
+               dev_err(dev, "could not get host wakeup gpio: %d", err);
+               return err;
+       }
+
+       btdev->wake_irq = gpiod_to_irq(btdev->wakeup_host);

Missed this in the binding review, but generally, we make these interrupts rather than gpios in the binding.

Quoted 9 lines
drivers/bluetooth/hci_nokia.c new file +9 -0
+
+       err = devm_request_threaded_irq(dev, btdev->wake_irq, NULL,
+               wakeup_handler,
+               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+               "wakeup", btdev);
+       if (err) {
+               dev_err(dev, "could request wakeup irq: %d", err);
+               return err;
+       }
#19 lore raw

Re: [PATCHv2 09/11] Bluetooth: add nokia driver

Hi,

Quoted 16 lines · Rob Herring
Quoted 6 lines · Sebastian Reichel

This adds a driver for the Nokia H4+ protocol, which is used at least on the Nokia N9, N900 & N950.

---

drivers/bluetooth/hci_nokia.c line 720

Quoted 8 lines
drivers/bluetooth/hci_nokia.c new file +8 -0
+       btdev->wakeup_host = devm_gpiod_get(dev, "host-wakeup", GPIOD_IN);
+       if (IS_ERR(btdev->wakeup_host)) {
+               err = PTR_ERR(btdev->wakeup_host);
+               dev_err(dev, "could not get host wakeup gpio: %d", err);
+               return err;
+       }
+
+       btdev->wake_irq = gpiod_to_irq(btdev->wakeup_host);
Quoted 2 lines

Missed this in the binding review, but generally, we make these interrupts rather than gpios in the binding.

I also read the state of the GPIO. AFAIK it's not possible to read the state of an IRQ, so I can't switch to IRQ.

Quoted 9 lines

drivers/bluetooth/hci_nokia.c line 729

Quoted 9 lines
drivers/bluetooth/hci_nokia.c new file +9 -0
+
+       err = devm_request_threaded_irq(dev, btdev->wake_irq, NULL,
+               wakeup_handler,
+               IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+               "wakeup", btdev);
+       if (err) {
+               dev_err(dev, "could request wakeup irq: %d", err);
+               return err;
+       }

-- Sebastian

#20 lore raw

Re: [PATCHv2 09/11] Bluetooth: add nokia driver

In reply to Sebastian Reichel

Hello Sebastian,

Quoted 48 lines · Sebastian Reichel

This adds a driver for the Nokia H4+ protocol, which is used at least on the Nokia N9, N900 & N950.

---
Changes since PATCHv1:
* replace __u8 and uint8_t with u8
* replace __u16 and uint16_t with u16
* drop BT_BAUDRATE_DIVIDER and use btdev->sysclk_speed * 10 instead
* fix wording of a sentence
* fix error path of negotation & alive package receive functions
* replaced nokia_wait_for_cts with newly introduced serdev function
* use "nokia,h4p-bluetooth" as compatible string

---
  drivers/bluetooth/Kconfig     |  12 +
  drivers/bluetooth/Makefile    |   2 +
  drivers/bluetooth/hci_nokia.c | 819 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 833 insertions(+)

create mode 100644 drivers/bluetooth/hci_nokia.c

drivers/bluetooth/Kconfig +12 -0
index c2c14a12713b..2e3e4d3547ad 100644
@@ -86,6 +86,18 @@ config BT_HCIUART_H4
 
  	  Say Y here to compile support for HCI UART (H4) protocol.
 
+config BT_HCIUART_NOKIA
+	tristate "UART Nokia H4+ protocol support"
+	depends on BT_HCIUART
+	depends on SERIAL_DEV_BUS
+	depends on PM
+	help
+	  Nokia H4+ is serial protocol for communication between Bluetooth
+	  device and host. This protocol is required for Bluetooth devices
+	  with UART interface in Nokia devices.
+
+	  Say Y here to compile support for Nokia's H4+ protocol.
+
  config BT_HCIUART_BCSP
  	bool "BCSP protocol support"
  	depends on BT_HCIUART
drivers/bluetooth/Makefile +0 -0
index fd571689eed6..a7f237320f4b 100644

drivers/bluetooth/Makefile obj-$(CONFIG_BT_BCM) += btbcm.o · line 31

Quoted 7 lines
drivers/bluetooth/Makefile +2 -0
@@ -25,6 +25,8 @@ obj-$(CONFIG_BT_BCM)		+= btbcm.o
  obj-$(CONFIG_BT_RTL)		+= btrtl.o
  obj-$(CONFIG_BT_QCA)		+= btqca.o
 
+obj-$(CONFIG_BT_HCIUART_NOKIA)	+= hci_nokia.o
+
  btmrvl-y			:= btmrvl_main.o
  btmrvl-$(CONFIG_DEBUG_FS)	+= btmrvl_debugfs.o

This does not build as module with following error:
ERROR: "hci_uart_tx_wakeup" [drivers/bluetooth/hci_nokia.ko] undefined!
ERROR: "hci_uart_register_device" [drivers/bluetooth/hci_nokia.ko] undefined!

Should not hci_nokia be part of the hci_uart module?

Regards,

Fred

#21 lore raw

Re: [PATCHv2 09/11] Bluetooth: add nokia driver

Hi,

Quoted 59 lines · Frédéric Danis
Quoted 46 lines · Sebastian Reichel

This adds a driver for the Nokia H4+ protocol, which is used at least on the Nokia N9, N900 & N950.

---
Changes since PATCHv1:
* replace __u8 and uint8_t with u8
* replace __u16 and uint16_t with u16
* drop BT_BAUDRATE_DIVIDER and use btdev->sysclk_speed * 10 instead
* fix wording of a sentence
* fix error path of negotation & alive package receive functions
* replaced nokia_wait_for_cts with newly introduced serdev function
* use "nokia,h4p-bluetooth" as compatible string

---
  drivers/bluetooth/Kconfig     |  12 +
  drivers/bluetooth/Makefile    |   2 +
  drivers/bluetooth/hci_nokia.c | 819 ++++++++++++++++++++++++++++++++++++++++++
  3 files changed, 833 insertions(+)

create mode 100644 drivers/bluetooth/hci_nokia.c

drivers/bluetooth/Kconfig +12 -0
index c2c14a12713b..2e3e4d3547ad 100644
@@ -86,6 +86,18 @@ config BT_HCIUART_H4
  	  Say Y here to compile support for HCI UART (H4) protocol.
+config BT_HCIUART_NOKIA
+	tristate "UART Nokia H4+ protocol support"
+	depends on BT_HCIUART
+	depends on SERIAL_DEV_BUS
+	depends on PM
+	help
+	  Nokia H4+ is serial protocol for communication between Bluetooth
+	  device and host. This protocol is required for Bluetooth devices
+	  with UART interface in Nokia devices.
+
+	  Say Y here to compile support for Nokia's H4+ protocol.
+
  config BT_HCIUART_BCSP
  	bool "BCSP protocol support"
  	depends on BT_HCIUART
drivers/bluetooth/Makefile +0 -0
index fd571689eed6..a7f237320f4b 100644

drivers/bluetooth/Makefile obj-$(CONFIG_BT_BCM) += btbcm.o · line 30

Quoted 6 lines
drivers/bluetooth/Makefile +2 -0
@@ -25,6 +25,8 @@ obj-$(CONFIG_BT_BCM)		+= btbcm.o
  obj-$(CONFIG_BT_RTL)		+= btrtl.o
  obj-$(CONFIG_BT_QCA)		+= btqca.o
+obj-$(CONFIG_BT_HCIUART_NOKIA)	+= hci_nokia.o
+
  btmrvl-y			:= btmrvl_main.o
  btmrvl-$(CONFIG_DEBUG_FS)	+= btmrvl_debugfs.o

This does not build as module with following error:
ERROR: "hci_uart_tx_wakeup" [drivers/bluetooth/hci_nokia.ko] undefined!
ERROR: "hci_uart_register_device" [drivers/bluetooth/hci_nokia.ko] undefined!

Quoted 1 line

Should not hci_nokia be part of the hci_uart module?

Yeah, I also received that from kbuild test robot after sending the patchset. I intentionally did not add this to hci_uart, so that I can use module_serdev_device_driver(). I think at least for serdev-only based bluetooth drivers it makes sense to have them in their own module. I already have added EXPORT_SYMBOL_GPL for those functions in the next version of this patchset.

-- Sebastian

#22 lore raw

PATCH v2 10/11 ARM: dts: N900: Add bluetooth

In reply to Sebastian Reichel

Add bcm2048 node and its system clock to the N900 device tree file. Apart from that a reference to the new clock has been added to wl1251 (which uses it, too).

---
Changes since PATCHv1:
- update compatible string

---
 arch/arm/boot/dts/omap3-n900.dts | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
arch/arm/boot/dts/omap3-n900.dts +21 -2
index b64cfda8dbb7..49f37084e435 100644
@@ -155,6 +155,13 @@
 		compatible = "nokia,n900-ir";
 		pwms = <&pwm9 0 26316 0>; /* 38000 Hz */
 	};
+
+	/* controlled (enabled/disabled) directly by bcm2048 and wl1251 */
+	vctcxo: vctcxo {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <38400000>;
+	};
 };
 
 &omap3_pmx_core {
@@ -162,8 +169,10 @@
 
 	uart2_pins: pinmux_uart2_pins {
 		pinctrl-single,pins = <
-			OMAP3_CORE1_IOPAD(0x217a, PIN_INPUT | MUX_MODE0)		/* uart2_rx */
+			OMAP3_CORE1_IOPAD(0x2174, PIN_INPUT_PULLUP | MUX_MODE0)		/* uart2_cts */
+			OMAP3_CORE1_IOPAD(0x2176, PIN_OUTPUT | MUX_MODE0)		/* uart2_rts */
 			OMAP3_CORE1_IOPAD(0x2178, PIN_OUTPUT | MUX_MODE0)		/* uart2_tx */
+			OMAP3_CORE1_IOPAD(0x217a, PIN_INPUT | MUX_MODE0)		/* uart2_rx */
 		>;
 	};
 
@@ -920,6 +929,8 @@
 
 		interrupt-parent = <&gpio2>;
 		interrupts = <10 IRQ_TYPE_NONE>; /* gpio line 42 */
+
+		clocks = <&vctcxo>;
 	};
 };
 
@@ -937,9 +948,17 @@
 };
 
 &uart2 {
-	interrupts-extended = <&intc 73 &omap3_pmx_core OMAP3_UART2_RX>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart2_pins>;
+
+	bcm2048: bluetooth {
+		compatible = "brcm,bcm2048-nokia", "nokia,h4p-bluetooth";
+		reset-gpios = <&gpio3 27 GPIO_ACTIVE_LOW>; /* 91 */
+		host-wakeup-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>; /* 101 */
+		bluetooth-wakeup-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>; /* 37 */
+		clocks = <&vctcxo>;
+		clock-names = "sysclk";
+	};
 };
 
 &uart3 {
Signature · 1 line
2.11.0
Acked-by on v2 10/11
#23 lore raw

Re: [PATCHv2 10/11] ARM: dts: N900: Add bluetooth

Quoted 4 lines · Sebastian Reichel

Add bcm2048 node and its system clock to the N900 device tree file. Apart from that a reference to the new clock has been added to wl1251 (which uses it, too).

Quoted 8 lines

---
Changes since PATCHv1:
- update compatible string

---
 arch/arm/boot/dts/omap3-n900.dts | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
#24 lore raw

Re: [PATCHv2 10/11] ARM: dts: N900: Add bluetooth

Quoted 14 lines · Rob Herring
Quoted 4 lines · Sebastian Reichel

Add bcm2048 node and its system clock to the N900 device tree file. Apart from that a reference to the new clock has been added to wl1251 (which uses it, too).

Quoted 8 lines

---
Changes since PATCHv1:
- update compatible string

---
 arch/arm/boot/dts/omap3-n900.dts | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
Quoted 1 line

Picking patches 10 and 11 into omap-for-v4.12/dt-v2.

Regards,

Tony

#25 lore raw

PATCH v2 11/11 ARM: dts: N9/N950: add bluetooth

In reply to Sebastian Reichel

The Nokia N950 and N9 have a wl1271 (with nokia bootloader) bluetooth module connected to second UART.

---
Changes since PATCHv1:
- update compatible string

---
 arch/arm/boot/dts/omap3-n950-n9.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
arch/arm/boot/dts/omap3-n950-n9.dtsi +32 -0
index 5d8c4b4a4205..df3366fa5409 100644
@@ -58,6 +58,13 @@
 			pinctrl-0 = <&debug_leds>;
 		};
 	};
+
+	/* controlled (enabled/disabled) directly by wl1271 */
+	vctcxo: vctcxo {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <38400000>;
+	};
 };
 
 &omap3_pmx_core {
@@ -125,6 +132,15 @@
 			OMAP3_CORE1_IOPAD(0x210a, PIN_OUTPUT | MUX_MODE4)            /* gpio_93 (cmt_apeslpx) */
 		>;
 	};
+
+	uart2_pins: pinmux_uart2_pins {
+		pinctrl-single,pins = <
+			OMAP3_CORE1_IOPAD(0x2174, PIN_INPUT_PULLUP | MUX_MODE0)		/* uart2_cts */
+			OMAP3_CORE1_IOPAD(0x2176, PIN_OUTPUT | MUX_MODE0)		/* uart2_rts */
+			OMAP3_CORE1_IOPAD(0x2178, PIN_OUTPUT | MUX_MODE0)		/* uart2_tx */
+			OMAP3_CORE1_IOPAD(0x217a, PIN_INPUT | MUX_MODE0)		/* uart2_rx */
+		>;
+	};
 };
 
 &omap3_pmx_core2 {
@@ -435,3 +451,19 @@
 &ssi_port2 {
 	status = "disabled";
 };
+
+&uart2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart2_pins>;
+
+	bluetooth {
+		compatible = "ti,wl1271-bluetooth-nokia", "nokia,h4p-bluetooth";
+
+		reset-gpios = <&gpio1 26 GPIO_ACTIVE_LOW>; /* 26 */
+		host-wakeup-gpios = <&gpio4 5 GPIO_ACTIVE_HIGH>; /* 101 */
+		bluetooth-wakeup-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>; /* 37 */
+
+		clocks = <&vctcxo>;
+		clock-names = "sysclk";
+	};
+};
Signature · 1 line
2.11.0
Acked-by on v2 11/11
#26 lore raw

Re: [PATCHv2 11/11] ARM: dts: N9/N950: add bluetooth

Quoted 10 lines · Sebastian Reichel

The Nokia N950 and N9 have a wl1271 (with nokia bootloader) bluetooth module connected to second UART.

---
Changes since PATCHv1:
- update compatible string

---
 arch/arm/boot/dts/omap3-n950-n9.dtsi | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)