Skip to contentSkip to conversation

n_gsm serdev support and protocol driver for droid4 modem

PATCH Superseded Tony Lindgren 4 participants 19 messages Apr 21, 2020 – Jan 2, 2021

Subsystems (10)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover n_gsm serdev support and protocol driver for droid4 modem

Hi all,

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

The patches are against v5.6-rc series.

Regards,

Tony

Changes since v5:
- Cosmetic fixes for issues noted by Pavel

Changes since v4:
- Use drivers/tty/serdev/protocol directory for the driver instead of drivers/mfd as discussed on the lists for v3 set of patches
- Fix remove to call kfree only after removing device from the list

Changes since v3:
- Update list of folks in Cc, looks like I sent v3 only to Lee and lkml
- Init privdata before motmdm_register_dlci calls gsm_serdev_register_dlci
- Update binding based on Rob's comments for license and "allOf"

Changes since v2:
- Drop useless send_command indirection, use static motmdm_send_command

Changes since v1:

- Simplified usage and got rid of few pointless inline functions
- Added consumer MFD driver, devicetree binding, and dts changes

Tony Lindgren (4):
tty: n_gsm: Add support for serdev drivers
serdev: ngsm-motmdm: Add Motorola TS 27.010 serdev modem driver for
droid4
dt-bindings: serdev: motmdm: Add binding for motorola-mdm
ARM: dts: omap4-droid4: Enable basic modem support

 .../serdev/motorola,mapphone-mdm6600.yaml     |   34 +
 .../boot/dts/motorola-mapphone-common.dtsi    |    6 +
 drivers/tty/n_gsm.c                           |  372 +++++
 drivers/tty/serdev/Kconfig                    |    2 +
 drivers/tty/serdev/Makefile                   |    2 +
 drivers/tty/serdev/protocol/Kconfig           |   14 +
 drivers/tty/serdev/protocol/Makefile          |    3 +
 .../tty/serdev/protocol/serdev-ngsm-motmdm.c  | 1191 +++++++++++++++++
 include/linux/serdev-gsm.h                    |  168 +++
 9 files changed, 1792 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serdev/motorola,mapphone-mdm6600.yaml
 create mode 100644 drivers/tty/serdev/protocol/Kconfig
 create mode 100644 drivers/tty/serdev/protocol/Makefile
 create mode 100644 drivers/tty/serdev/protocol/serdev-ngsm-motmdm.c
 create mode 100644 include/linux/serdev-gsm.h
Signature · 1 line
2.26.2
#1 lore raw

PATCH v6 1/4 tty: n_gsm: Add support for serdev drivers

We can make use of serdev drivers to do simple device drivers for TS 27.010 chanels, and we can handle vendor specific protocols on top of TS 27.010 with serdev drivers.

So far this has been tested with Motorola droid4 where there is a custom packet numbering protocol on top of TS 27.010 for the MDM6600 modem.

I initially though about adding the serdev support into a separate file, but that will take some refactoring of n_gsm.c. And I'd like to have things working first. Then later on we might want to consider splitting n_gsm.c into three pieces for core, tty and serdev parts. And then maybe the serdev related parts can be just moved to live under something like drivers/tty/serdev/protocol/ngsm.c.

---
 drivers/tty/n_gsm.c        | 372 +++++++++++++++++++++++++++++++++++++
 include/linux/serdev-gsm.h | 168 +++++++++++++++++
 2 files changed, 540 insertions(+)
 create mode 100644 include/linux/serdev-gsm.h
drivers/tty/n_gsm.c +372 -0
@@ -39,6 +39,7 @@
 #include <linux/file.h>
 #include <linux/uaccess.h>
 #include <linux/module.h>
+#include <linux/serdev.h>
 #include <linux/timer.h>
 #include <linux/tty_flip.h>
 #include <linux/tty_driver.h>
@@ -50,6 +51,7 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/gsmmux.h>
+#include <linux/serdev-gsm.h>
 
 static int debug;
 module_param(debug, int, 0600);
@@ -150,6 +152,7 @@ struct gsm_dlci {
 	/* Data handling callback */
 	void (*data)(struct gsm_dlci *dlci, const u8 *data, int len);
 	void (*prev_data)(struct gsm_dlci *dlci, const u8 *data, int len);
+	struct gsm_serdev_dlci *ops; /* serdev dlci ops, if used */
 	struct net_device *net; /* network interface, if created */
 };
 
@@ -198,6 +201,7 @@ enum gsm_mux_state {
  */
 
 struct gsm_mux {
+	struct gsm_serdev *gsd;		/* Serial device bus data */
 	struct tty_struct *tty;		/* The tty our ldisc is bound to */
 	spinlock_t lock;
 	struct mutex mutex;
@@ -2346,6 +2350,374 @@ static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c)
 	return 0;
 }
 
+#ifdef CONFIG_SERIAL_DEV_BUS
+
+/**
+ * gsm_serdev_get_config - read ts 27.010 config
+ * @gsd:	serdev-gsm instance
+ * @c:		ts 27.010 config data
+ *
+ * See gsm_copy_config_values() for more information.
+ */
+int gsm_serdev_get_config(struct gsm_serdev *gsd, struct gsm_config *c)
+{
+	struct gsm_mux *gsm;
+
+	if (!gsd || !gsd->gsm)
+		return -ENODEV;
+
+	gsm = gsd->gsm;
+
+	if (!c)
+		return -EINVAL;
+
+	gsm_copy_config_values(gsm, c);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_get_config);
+
+/**
+ * gsm_serdev_set_config - set ts 27.010 config
+ * @gsd:	serdev-gsm instance
+ * @c:		ts 27.010 config data
+ *
+ * See gsm_config() for more information.
+ */
+int gsm_serdev_set_config(struct gsm_serdev *gsd, struct gsm_config *c)
+{
+	struct gsm_mux *gsm;
+
+	if (!gsd || !gsd->serdev || !gsd->gsm)
+		return -ENODEV;
+
+	gsm = gsd->gsm;
+
+	if (!c)
+		return -EINVAL;
+
+	return gsm_config(gsm, c);
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_set_config);
+
+static struct gsm_dlci *gsd_dlci_get(struct gsm_serdev *gsd, int line,
+				     bool allocate)
+{
+	struct gsm_mux *gsm;
+	struct gsm_dlci *dlci;
+
+	if (!gsd || !gsd->gsm)
+		return ERR_PTR(-ENODEV);
+
+	gsm = gsd->gsm;
+
+	if (line < 1 || line >= 63)
+		return ERR_PTR(-EINVAL);
+
+	mutex_lock(&gsm->mutex);
+
+	if (gsm->dlci[line]) {
+		dlci = gsm->dlci[line];
+		goto unlock;
+	} else if (!allocate) {
+		dlci = ERR_PTR(-ENODEV);
+		goto unlock;
+	}
+
+	dlci = gsm_dlci_alloc(gsm, line);
+	if (!dlci) {
+		gsm = ERR_PTR(-ENOMEM);
+		goto unlock;
+	}
+
+	gsm->dlci[line] = dlci;
+
+unlock:
+	mutex_unlock(&gsm->mutex);
+
+	return dlci;
+}
+
+static void gsd_dlci_data(struct gsm_dlci *dlci, const u8 *buf, int len)
+{
+	struct gsm_mux *gsm = dlci->gsm;
+	struct gsm_serdev *gsd = gsm->gsd;
+
+	if (!gsd || !dlci->ops)
+		return;
+
+	switch (dlci->adaption) {
+	case 0:
+	case 1:
+		if (dlci->ops->receive_buf)
+			dlci->ops->receive_buf(dlci->ops, buf, len);
+		break;
+	default:
+		pr_warn("dlci%i adaption %i not yet implemented\n",
+			dlci->addr, dlci->adaption);
+		break;
+	}
+}
+
+/**
+ * gsm_serdev_write - write data to a ts 27.010 channel
+ * @gsd:	serdev-gsm instance
+ * @ops:	channel ops
+ * @buf:	write buffer
+ * @len:	buffer length
+ */
+int gsm_serdev_write(struct gsm_serdev *gsd, struct gsm_serdev_dlci *ops,
+		     const u8 *buf, int len)
+{
+	struct gsm_mux *gsm;
+	struct gsm_dlci *dlci;
+	struct gsm_msg *msg;
+	int h, size, total_size = 0;
+	u8 *dp;
+
+	if (!gsd || !gsd->gsm)
+		return -ENODEV;
+
+	gsm = gsd->gsm;
+
+	dlci = gsd_dlci_get(gsd, ops->line, false);
+	if (IS_ERR(dlci))
+		return PTR_ERR(dlci);
+
+	h = dlci->adaption - 1;
+
+	if (len > gsm->mtu)
+		len = gsm->mtu;
+
+	size = len + h;
+
+	msg = gsm_data_alloc(gsm, dlci->addr, size, gsm->ftype);
+	if (!msg)
+		return -ENOMEM;
+
+	dp = msg->data;
+	switch (dlci->adaption) {
+	case 1:
+		break;
+	case 2:
+		*dp++ = gsm_encode_modem(dlci);
+		break;
+	}
+	memcpy(dp, buf, len);
+	gsm_data_queue(dlci, msg);
+	total_size += size;
+
+	return total_size;
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_write);
+
+/**
+ * gsm_serdev_data_kick - indicate more data can be transmitted
+ * @gsd:	serdev-gsm instance
+ *
+ * See gsm_data_kick() for more information.
+ */
+void gsm_serdev_data_kick(struct gsm_serdev *gsd)
+{
+	struct gsm_mux *gsm;
+	unsigned long flags;
+
+	if (!gsd || !gsd->gsm)
+		return;
+
+	gsm = gsd->gsm;
+
+	spin_lock_irqsave(&gsm->tx_lock, flags);
+	gsm_data_kick(gsm);
+	spin_unlock_irqrestore(&gsm->tx_lock, flags);
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_data_kick);
+
+/**
+ * gsm_serdev_register_dlci - register a ts 27.010 channel
+ * @gsd:	serdev-gsm instance
+ * @ops:	channel ops
+ */
+int gsm_serdev_register_dlci(struct gsm_serdev *gsd,
+			     struct gsm_serdev_dlci *ops)
+{
+	struct gsm_dlci *dlci;
+	struct gsm_mux *gsm;
+	int retries;
+
+	if (!gsd || !gsd->gsm || !gsd->serdev)
+		return -ENODEV;
+
+	gsm = gsd->gsm;
+
+	if (!ops || !ops->line || !ops->receive_buf)
+		return -EINVAL;
+
+	dlci = gsd_dlci_get(gsd, ops->line, true);
+	if (IS_ERR(dlci))
+		return PTR_ERR(dlci);
+
+	if (dlci->state == DLCI_OPENING || dlci->state == DLCI_OPEN ||
+	    dlci->state == DLCI_CLOSING)
+		return -EBUSY;
+
+	mutex_lock(&dlci->mutex);
+	dlci->ops = ops;
+	dlci->modem_rx = 0;
+	dlci->prev_data = dlci->data;
+	dlci->data = gsd_dlci_data;
+	mutex_unlock(&dlci->mutex);
+
+	gsm_dlci_begin_open(dlci);
+
+	/*
+	 * Allow some time for dlci to move to DLCI_OPEN state. Otherwise
+	 * the serdev consumer driver can start sending data too early during
+	 * the setup, and the response will be missed by gms_queue() if we
+	 * still have DLCI_CLOSED state.
+	 */
+	for (retries = 10; retries > 0; retries--) {
+		if (dlci->state == DLCI_OPEN)
+			break;
+		msleep(100);
+	}
+
+	if (!retries)
+		dev_dbg(&gsd->serdev->dev, "dlci%i not currently active\n",
+			dlci->addr);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_register_dlci);
+
+/**
+ * gsm_serdev_unregister_dlci - unregister a ts 27.010 channel
+ * @gsd:	serdev-gsm instance
+ * @ops:	channel ops
+ */
+void gsm_serdev_unregister_dlci(struct gsm_serdev *gsd,
+				struct gsm_serdev_dlci *ops)
+{
+	struct gsm_mux *gsm;
+	struct gsm_dlci *dlci;
+
+	if (!gsd || !gsd->gsm || !gsd->serdev)
+		return;
+
+	gsm = gsd->gsm;
+
+	if (!ops || !ops->line)
+		return;
+
+	dlci = gsd_dlci_get(gsd, ops->line, false);
+	if (IS_ERR(dlci))
+		return;
+
+	mutex_lock(&dlci->mutex);
+	gsm_destroy_network(dlci);
+	dlci->data = dlci->prev_data;
+	dlci->ops = NULL;
+	mutex_unlock(&dlci->mutex);
+
+	gsm_dlci_begin_close(dlci);
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_unregister_dlci);
+
+static int gsm_serdev_output(struct gsm_mux *gsm, u8 *data, int len)
+{
+	struct gsm_serdev *gsd = gsm->gsd;
+	struct serdev_device *serdev = gsm->gsd->serdev;
+	bool asleep;
+
+	asleep = atomic_read(&gsd->asleep);
+	if (asleep)
+		return -ENOSPC;
+
+	if (gsm->gsd->output)
+		return gsm->gsd->output(gsm->gsd, data, len);
+	else
+		return serdev_device_write_buf(serdev, data, len);
+}
+
+static int gsd_receive_buf(struct serdev_device *serdev, const u8 *data,
+			   size_t count)
+{
+	struct gsm_serdev *gsd = serdev_device_get_drvdata(serdev);
+	struct gsm_mux *gsm;
+	const unsigned char *dp;
+	int i;
+
+	if (WARN_ON(!gsd))
+		return 0;
+
+	gsm = gsd->gsm;
+
+	if (debug & 4)
+		print_hex_dump_bytes("gsd_receive_buf: ",
+				     DUMP_PREFIX_OFFSET,
+				     data, count);
+
+	for (i = count, dp = data; i; i--, dp++)
+		gsm->receive(gsm, *dp);
+
+	return count;
+}
+
+static void gsd_write_wakeup(struct serdev_device *serdev)
+{
+	serdev_device_write_wakeup(serdev);
+}
+
+static struct serdev_device_ops gsd_client_ops = {
+	.receive_buf = gsd_receive_buf,
+	.write_wakeup = gsd_write_wakeup,
+};
+
+int gsm_serdev_register_device(struct gsm_serdev *gsd)
+{
+	struct gsm_mux *gsm;
+	int error;
+
+	if (WARN(!gsd || !gsd->serdev || !gsd->output,
+		 "serdev and output must be initialized\n"))
+		return -EINVAL;
+
+	serdev_device_set_client_ops(gsd->serdev, &gsd_client_ops);
+
+	gsm = gsm_alloc_mux();
+	if (!gsm)
+		return -ENOMEM;
+
+	gsm->encoding = 1;
+	gsm->tty = NULL;
+	gsm->gsd = gsd;
+	gsm->output = gsm_serdev_output;
+	atomic_set(&gsd->asleep, 0);
+	gsd->gsm = gsm;
+	mux_get(gsd->gsm);
+
+	error = gsm_activate_mux(gsd->gsm);
+	if (error) {
+		gsm_cleanup_mux(gsd->gsm);
+		mux_put(gsd->gsm);
+
+		return error;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_register_device);
+
+void gsm_serdev_unregister_device(struct gsm_serdev *gsd)
+{
+	gsm_cleanup_mux(gsd->gsm);
+	mux_put(gsd->gsm);
+	gsd->gsm = NULL;
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_unregister_device);
+
+#endif	/* CONFIG_SERIAL_DEV_BUS */
+
 /**
  *	gsmld_output		-	write to link
  *	@gsm: our mux
include/linux/serdev-gsm.h new file +168 -0

168 lines not on this page · raw message

Signature · 1 line
2.26.2
#2 lore raw

PATCH v6 2/4 serdev: ngsm-motmdm: Add Motorola TS 27.010 serdev modem driver for droid4

In reply to Tony Lindgren

Many Motorola phones are controlling the modem using a custom variant of TS 27.010 serial line discipline. Devices on these modems have a dedicated TS 27.010 channel for features like audio mixer, GNSS, voice modem, SIM card reader and so on.

This serdev protocol driver allows using various devices on the modem. In order to do that, we need to take care of the following three things:

1. Provide /dev/motmdm* character devices for apps to use for talking to the various devices on the modem

2. Handle Motorola custom protocol over TS 27.010 to make the channels usable for userspace

3. Coordinate PM runtime with the USB PHY because of shared GPIO pins with the USB PHY

With this patch, folks with droid4 can place a voice call with just:

$ printf "ATD%s,0\r" "${phone_number}" > /dev/motmdm1
D:OK
~+CIEV=1,1,0
...
$ printf "ATH\r" > /dev/motmdm1
H:OK

Also SMS can be sent with this patch using /dev/motmdm3 for sending, and /dev/motmdm9 for receiving messages, and /dev/motmdm10 can be used for SIM access.

Note that the audio mixer needs additional patches though. I will be sending those as a separate series of patches.

---
 drivers/tty/serdev/Kconfig                    |    2 +
 drivers/tty/serdev/Makefile                   |    2 +
 drivers/tty/serdev/protocol/Kconfig           |   14 +
 drivers/tty/serdev/protocol/Makefile          |    3 +
 .../tty/serdev/protocol/serdev-ngsm-motmdm.c  | 1191 +++++++++++++++++
 5 files changed, 1212 insertions(+)
 create mode 100644 drivers/tty/serdev/protocol/Kconfig
 create mode 100644 drivers/tty/serdev/protocol/Makefile
 create mode 100644 drivers/tty/serdev/protocol/serdev-ngsm-motmdm.c
drivers/tty/serdev/Kconfig +2 -0
@@ -22,4 +22,6 @@ config SERIAL_DEV_CTRL_TTYPORT
 	depends on SERIAL_DEV_BUS != m
 	default y
 
+source "drivers/tty/serdev/protocol/Kconfig"
+
 endif
drivers/tty/serdev/Makefile +2 -0
@@ -4,3 +4,5 @@ serdev-objs := core.o
 obj-$(CONFIG_SERIAL_DEV_BUS) += serdev.o
 
 obj-$(CONFIG_SERIAL_DEV_CTRL_TTYPORT) += serdev-ttyport.o
+
+obj-y += protocol/
drivers/tty/serdev/protocol/Kconfig new file +14 -0
new file mode 100644
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Serial bus device driver protocol specific configuration
+#
+
+config SERIAL_DEV_NGSM_MOTMDM
+	tristate "Motorola Modem TS 27.010 Serdev Protocol Driver"
+	depends on N_GSM && PHY_MAPPHONE_MDM6600
+	help
+	  Select this for Motorola modems using TS 27.010 serial line
+	  discipline such as MDM6600 modem found on Motorola Mapphone
+	  devices like Droid4.
+
+	  If unsure, say N.
drivers/tty/serdev/protocol/Makefile new file +3 -0
new file mode 100644
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+
+obj-$(CONFIG_SERIAL_DEV_NGSM_MOTMDM) += serdev-ngsm-motmdm.o
drivers/tty/serdev/protocol/serdev-ngsm-motmdm.c new file +1191 -0

1,191 lines not on this page · raw message

Signature · 1 line
2.26.2
#3 lore raw

PATCH v6 3/4 dt-bindings: serdev: motmdm: Add binding for motorola-mdm

In reply to Tony Lindgren

Add a binding document for Motorola modems controllable by TS 27.010 UART line discipline using serdev drivers.

---
 .../serdev/motorola,mapphone-mdm6600.yaml     | 34 +++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serdev/motorola,mapphone-mdm6600.yaml
Documentation/devicetree/bindings/serdev/motorola,mapphone-mdm6600.yaml new file +34 -0
new file mode 100644
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/serdev/motorola,mapphone-mdm6600.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Motorola Mapphone MDM6600 Modem
+
+maintainers:
+  - Tony Lindgren <[email protected]>
+
+properties:
+  compatible:
+    items:
+      - const: motorola,mapphone-mdm6600-serial
+
+  phys:
+    maxItems: 1
+
+  phy-names:
+    const: usb
+
+required:
+  - compatible
+  - phys
+  - phy-names
+
+examples:
+  - |
+    modem {
+        compatible = "motorola,mapphone-mdm6600-serial";
+        phys = <&fsusb1_phy>;
+        phy-names = "usb";
+    };
Signature · 1 line
2.26.2
#4 lore raw

PATCH v6 4/4 ARM: dts: omap4-droid4: Enable basic modem support

In reply to Tony Lindgren

This allows apps to use /dev/motmdm1 for voice call AT commands, /dev/motmdm3 for sending SMS, and /dev/motmdm9 for reading SMS.

Voice call audio mixer and GNSS are not yet supported.

---
 arch/arm/boot/dts/motorola-mapphone-common.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/boot/dts/motorola-mapphone-common.dtsi +6 -0
@@ -698,6 +698,12 @@ &uart1 {
 	pinctrl-0 = <&uart1_pins>;
 	interrupts-extended = <&wakeupgen GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH
 			       &omap4_pmx_core 0xfc>;
+
+	modem {
+		compatible = "motorola,mapphone-mdm6600-serial";
+		phys = <&fsusb1_phy>;
+		phy-names = "usb";
+	};
 };
 
 &uart3 {
Signature · 1 line
2.26.2
maintainer
#5 lore raw
In reply to Tony Lindgren

Hi Tony,

Quoted 9 lines · Tony Lindgren

Hi all,

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

I'm still missing an architectural (design) overview here -- reviewer time is a scarce resource.

I also suggested earlier that you include, at least as an RFC, one or more of your child-device drivers so that we can see how this ends up being used in the end (including an example devicetree).

Some high-level comments until then:

I'm not sure that a plain chardev interface for the mux channels is the right interface. The n_gsm ldisc exposes tty devices and I think your serdev adaptation should continue to do that.

On that note; you're not actually adding general TS 27.010 serdev support, but rather some hooks and a custom driver and interface (mfd + /dev/motmdmN) for one particular modem.

I'd rather see a generic implementation which can be used with other modems and that continues to expose a /dev/gsmttyN interface to which we could attach serdev clients instead (and not create a motmdm serdev replica of sorts).

I know the location of this driver has been up for discussion already, but drivers/tty/serdev/protocol still isn't right (e.g. we don't have an drivers/i2c/protocol directory where we stuff random i2c client drivers).

It's an mfd + custom chardev driver for a modem and related to n_gsm (even more if you add generic serdev support). Currently, drivers/mfd or drivers/misc appear to be better choices. Otherwise, n_gsm lives in drivers/tty since it's a line discipline, but it could be moved to a new drivers/modem if needed (cf. the bluetooth hci ldisc).

Last, it seems you've based the serdev-ngsm-motmdm.c chardev implementation on a more or less verbatim copy of drivers/gnss/core.c. I'd appreciate if you could mention that in the file header and reproduce the copyright notice if you end up keeping that interface.

Quoted 7 lines

Tony Lindgren (4):
tty: n_gsm: Add support for serdev drivers
serdev: ngsm-motmdm: Add Motorola TS 27.010 serdev modem driver for
droid4
dt-bindings: serdev: motmdm: Add binding for motorola-mdm
ARM: dts: omap4-droid4: Enable basic modem support

Quoted 15 lines
 .../serdev/motorola,mapphone-mdm6600.yaml     |   34 +
 .../boot/dts/motorola-mapphone-common.dtsi    |    6 +
 drivers/tty/n_gsm.c                           |  372 +++++
 drivers/tty/serdev/Kconfig                    |    2 +
 drivers/tty/serdev/Makefile                   |    2 +
 drivers/tty/serdev/protocol/Kconfig           |   14 +
 drivers/tty/serdev/protocol/Makefile          |    3 +
 .../tty/serdev/protocol/serdev-ngsm-motmdm.c  | 1191 +++++++++++++++++
 include/linux/serdev-gsm.h                    |  168 +++
 9 files changed, 1792 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/serdev/motorola,mapphone-mdm6600.yaml
 create mode 100644 drivers/tty/serdev/protocol/Kconfig
 create mode 100644 drivers/tty/serdev/protocol/Makefile
 create mode 100644 drivers/tty/serdev/protocol/serdev-ngsm-motmdm.c
 create mode 100644 include/linux/serdev-gsm.h

Johan

#6 lore raw
Quoted 9 lines · Johan Hovold

Hi Tony,

Quoted 6 lines · Tony Lindgren

Hi all,

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

Quoted 6 lines
Quoted 3 lines

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

I'm still missing an architectural (design) overview here -- reviewer time is a scarce resource.

OK, so for this series it would be roughly:

1. Allow serdev drivers configure and use n_gsm for TS 27.010

2. Add support for a motorola modem with a custom protocol on top of TS 27.010 with only chardev support initially

3. Start adding TS 27.010 channel specific device drivers as regular Linux device drivers later on

Quoted 3 lines

I also suggested earlier that you include, at least as an RFC, one or more of your child-device drivers so that we can see how this ends up being used in the end (including an example devicetree).

Well I left that out intentionally to keep the series smaller. But yeah, I guess that part is really what people want. I'll add a basic GNSS driver for the next version.

Quoted 5 lines

Some high-level comments until then:

I'm not sure that a plain chardev interface for the mux channels is the right interface. The n_gsm ldisc exposes tty devices and I think your serdev adaptation should continue to do that.

That's what I started with, but was not happy at all because of the custom motorola protocol layer on top of TS 27.010.

A generic n_gsm serdev driver should work easily though. Roughly, the n_gsm serdev driver(s) wanting to use just the n_gsm tty devices would just call the n_gsm config functions only, and configure no custom callbacks. Maybe some flag is needed for n_gsm tty. This needs to be checked again though as I have not done that for a while.

Then for the custom n_gsm serdev implementations, like this modem, we have packet data from n_gsm. I don't think stuffing the packet data back into tty devices helps for these cases.

Quoted 3 lines

On that note; you're not actually adding general TS 27.010 serdev support, but rather some hooks and a custom driver and interface (mfd + /dev/motmdmN) for one particular modem.

A generic n_gsm serdev driver would just use a subset of these same functions.

Quoted 4 lines

I'd rather see a generic implementation which can be used with other modems and that continues to expose a /dev/gsmttyN interface to which we could attach serdev clients instead (and not create a motmdm serdev replica of sorts).

Yeah this should be doable quite easily actually without really any of the motorola driver code. It's a separate driver though, and not usable for this case because of the custom layer.

Quoted 4 lines

I know the location of this driver has been up for discussion already, but drivers/tty/serdev/protocol still isn't right (e.g. we don't have an drivers/i2c/protocol directory where we stuff random i2c client drivers).

Argh, the location of driver again.. So we do have the custom motorola layer to deal with on top of TS 27.010, but the custom handling is contained within the driver. So maybe just drivers/serial for the custom driver then.

Quoted 5 lines

It's an mfd + custom chardev driver for a modem and related to n_gsm (even more if you add generic serdev support). Currently, drivers/mfd or drivers/misc appear to be better choices. Otherwise, n_gsm lives in drivers/tty since it's a line discipline, but it could be moved to a new drivers/modem if needed (cf. the bluetooth hci ldisc).

The n_gsm suport is not limited to modems only. Probably best to not move it. And I'd avoid drivers/modem until we actually have three similar use cases based on the late David "Mr.Bus" Brownell rule of thumb :)

Quoted 4 lines

Last, it seems you've based the serdev-ngsm-motmdm.c chardev implementation on a more or less verbatim copy of drivers/gnss/core.c. I'd appreciate if you could mention that in the file header and reproduce the copyright notice if you end up keeping that interface.

Oh yes indeed, thanks for pointing that out. I'll add it to the next version. The chardev code is for sure based on drivers/gnss.

To explain my ignorance, I added the chardev support initially as an experiment to see if I can handle the motorola packet layer better that way compared to the n_gsm ttys and userspace handling. It ended up working quite nicely, so I kept it but then I accidentally left out references to the source. Sorry about that.

Regards,

Tony

#7 lore raw
Quoted 9 lines · Tony Lindgren
Quoted 4 lines · Johan Hovold

I'd rather see a generic implementation which can be used with other modems and that continues to expose a /dev/gsmttyN interface to which we could attach serdev clients instead (and not create a motmdm serdev replica of sorts).

Yeah this should be doable quite easily actually without really any of the motorola driver code. It's a separate driver though, and not usable for this case because of the custom layer.

Well here's a first take at the such a generic serdev-ngsm driver that depends on patch 1/4 of this series. All this does is configure a serial port for TS 27.010 adaption1, and brings up 16 /dev/gsmtty* devices. So no custom options for the binding so far, and no support for adding channel specific device drivers. But all that can be added naturally later on.

I've briefly tested it with my droid4 instead of the custom driver in this series to make sure things work with the following steps:

I added modem to arch/arm/boot/dts/motorola-mapphone-common.dtsi under uart1:

	modem {
		compatible = "3gpp,ts27010-adaption1";
	};

And then I had to disable the shared gpio PM pin toggling for the USB PHY to prevent the modem from idling:

# echo on > /sys/devices/platform/usb-phy@1/power/control

And then I was able to talk with the modem by prepending custom packet numbering to the messages:

# cat /dev/gsmtty10 &
# printf "U1234AT+MSIM?\r" > /dev/gsmtty10
# U1234+MSIM=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

Hmm. Maybe we could just handle the droid4 PM needs with a custom compatible here too. And deal with the motorola packet layer somewhere.

Then the only difference to the custom driver in this series really is that we would be using the /dev/gsmtty* tty devices for userspace isntead of the custom /dev/motmdm* char devices.

Regards,

Tony

8< --------------------

 drivers/tty/n_gsm.c              |  65 ++++++++++++-
 drivers/tty/serdev/Kconfig       |  10 ++
 drivers/tty/serdev/Makefile      |   1 +
 drivers/tty/serdev/serdev-ngsm.c | 156 +++++++++++++++++++++++++++++++
 include/linux/serdev-gsm.h       |  11 +++
 5 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 drivers/tty/serdev/serdev-ngsm.c
drivers/tty/n_gsm.c +64 -1
@@ -2438,6 +2438,19 @@ static struct gsm_dlci *gsd_dlci_get(struct gsm_serdev *gsd, int line,
 	return dlci;
 }
 
+static int gsd_dlci_receive_buf(struct gsm_dlci *dlci,
+				const unsigned char *buf,
+				size_t len)
+{
+	struct tty_port *port;
+
+	port = &dlci->port;
+	tty_insert_flip_string(port, buf, len);
+	tty_flip_buffer_push(port);
+
+	return 0;
+}
+
 static void gsd_dlci_data(struct gsm_dlci *dlci, const u8 *buf, int len)
 {
 	struct gsm_mux *gsm = dlci->gsm;
@@ -2451,6 +2464,8 @@ static void gsd_dlci_data(struct gsm_dlci *dlci, const u8 *buf, int len)
 	case 1:
 		if (dlci->ops->receive_buf)
 			dlci->ops->receive_buf(dlci->ops, buf, len);
+		else
+			gsd_dlci_receive_buf(dlci, buf, len);
 		break;
 	default:
 		pr_warn("dlci%i adaption %i not yet implemented\n",
@@ -2550,7 +2565,7 @@ int gsm_serdev_register_dlci(struct gsm_serdev *gsd,
 
 	gsm = gsd->gsm;
 
-	if (!ops || !ops->line || !ops->receive_buf)
+	if (!ops || !ops->line)
 		return -EINVAL;
 
 	dlci = gsd_dlci_get(gsd, ops->line, true);
@@ -2673,6 +2688,54 @@ static struct serdev_device_ops gsd_client_ops = {
 	.write_wakeup = gsd_write_wakeup,
 };
 
+int gsm_serdev_register_tty_port(struct gsm_serdev *gsd, int line)
+{
+	struct gsm_serdev_dlci *ops;
+	unsigned int base;
+	int error;
+
+	if (line < 1)
+		return -EINVAL;
+
+	ops = kzalloc(sizeof(*ops), GFP_KERNEL);
+	if (!ops)
+		return -ENOMEM;
+
+	ops->line = line;
+
+	error = gsm_serdev_register_dlci(gsd, ops);
+	if (error) {
+		kfree(ops);
+
+		return error;
+	}
+
+	base = mux_num_to_base(gsd->gsm);
+	tty_register_device(gsm_tty_driver, base + ops->line, NULL);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_register_tty_port);
+
+void gsm_serdev_unregister_tty_port(struct gsm_serdev *gsd, int line)
+{
+	struct gsm_dlci *dlci;
+	unsigned int base;
+
+	if (line < 1)
+		return;
+
+	dlci = gsd_dlci_get(gsd, line, false);
+	if (IS_ERR(dlci))
+		return;
+
+	base = mux_num_to_base(gsd->gsm);
+	tty_unregister_device(gsm_tty_driver, base + line);
+	gsm_serdev_unregister_dlci(gsd, dlci->ops);
+	kfree(dlci->ops);
+}
+EXPORT_SYMBOL_GPL(gsm_serdev_unregister_tty_port);
+
 int gsm_serdev_register_device(struct gsm_serdev *gsd)
 {
 	struct gsm_mux *gsm;
drivers/tty/serdev/Kconfig +10 -0
@@ -22,4 +22,14 @@ config SERIAL_DEV_CTRL_TTYPORT
 	depends on SERIAL_DEV_BUS != m
 	default y
 
+config SERIAL_DEV_N_GSM
+	tristate "Serial device TS 27.010 support"
+	help
+	  Select this if you want to use the TS 27.010 with a serial port with
+	  devices such as modems and GNSS devices.
+
+	  If unsure, say N.
+	depends on N_GSM
+	depends on SERIAL_DEV_CTRL_TTYPORT
+
 endif
drivers/tty/serdev/Makefile +1 -0
@@ -4,3 +4,4 @@ serdev-objs := core.o
 obj-$(CONFIG_SERIAL_DEV_BUS) += serdev.o
 
 obj-$(CONFIG_SERIAL_DEV_CTRL_TTYPORT) += serdev-ttyport.o
+obj-$(CONFIG_SERIAL_DEV_N_GSM) += serdev-ngsm.o
drivers/tty/serdev/serdev-ngsm.c new file +156 -0

156 lines not on this page · raw message

include/linux/serdev-gsm.h +11 -0
@@ -45,6 +45,8 @@ struct gsm_serdev_dlci {
 
 int gsm_serdev_register_device(struct gsm_serdev *gsd);
 void gsm_serdev_unregister_device(struct gsm_serdev *gsd);
+int gsm_serdev_register_tty_port(struct gsm_serdev *gsd, int line);
+void gsm_serdev_unregister_tty_port(struct gsm_serdev *gsd, int line);
 
 static inline void *gsm_serdev_get_drvdata(struct device *dev)
 {
@@ -108,6 +110,15 @@ void gsm_serdev_unregister_device(struct gsm_serdev *gsd)
 {
 }
 
+int gsm_serdev_register_tty_port(struct gsm_serdev *gsd, int line);
+{
+	return -ENODEV;
+}
+
+void gsm_serdev_unregister_tty_port(struct gsm_serdev *gsd, int line);
+{
+}
+
 static inline void *gsm_serdev_get_drvdata(struct device *dev)
 {
 	return NULL;
Signature · 1 line
2.26.2
#8 lore raw
Quoted 11 lines · Tony Lindgren
Quoted 9 lines · Tony Lindgren
Quoted 4 lines · Johan Hovold

I'd rather see a generic implementation which can be used with other modems and that continues to expose a /dev/gsmttyN interface to which we could attach serdev clients instead (and not create a motmdm serdev replica of sorts).

Yeah this should be doable quite easily actually without really any of the motorola driver code. It's a separate driver though, and not usable for this case because of the custom layer.

Quoted 6 lines

Well here's a first take at the such a generic serdev-ngsm driver that depends on patch 1/4 of this series. All this does is configure a serial port for TS 27.010 adaption1, and brings up 16 /dev/gsmtty* devices. So no custom options for the binding so far, and no support for adding channel specific device drivers. But all that can be added naturally later on.

Just to clarify the difference between the generic serdev-ngsm case and this modem..

In the generic case, channel specific Linux device drivers can just use gsm_serdev_write() directly for things like GNSS driver, SIM file system, audio and whatever the modems might have on separate channels.

This Motorola modem needs custom read and write functions because of the custom Motorola packet format on top of TS 27.010. So for example, the motmdm_write() function stuffs the packet header, and then just calls gsm_serdev_write().

So for the generic channel specific drivers, the driver just needs to be able to do something like:

Configure devicetree for the drivers/tty/serdev/serdev-ngsm.c to bring up the TS 27.010 port based on the compatible and whatever port specific properties we may want use.

And then have the channel specific device drivers do something like this:

gsm_serdev_ngsm_register(); /* TBD to add to serdev-ngsm.c */
gsm_serdev_register_dlci(); /* Already patched for n_gsm.c */
gsm_serdev_write(); /* Already patched for n_gsm.c */
...
gsm_serdev_unregister_dlci(); /* Already patched for n_gsm.c */
gsm_serdev_ngsm_unregister(); /* TBD to add to serdev-ngsm.c */

So I think we can limit the code in the generic serdev-ngsm.c to bring up the TS 27.010, and then allow whatever channel specific device drivers to register with it. I guess that should do for the generic API.

Anybody got better suggestions?

Regards,

Tony

maintainer
#9 lore raw
In reply to Tony Lindgren

Hi Tony,

Sorry about the late reply on this.

Quoted 11 lines · Tony Lindgren
Quoted 4 lines · Johan Hovold

I know the location of this driver has been up for discussion already, but drivers/tty/serdev/protocol still isn't right (e.g. we don't have an drivers/i2c/protocol directory where we stuff random i2c client drivers).

Argh, the location of driver again.. So we do have the custom motorola layer to deal with on top of TS 27.010, but the custom handling is contained within the driver. So maybe just drivers/serial for the custom driver then.

Yeah, that should do for now; n_gsm is a serial driver (exposing tty devices) after all.

Quoted 5 lines
Quoted 4 lines

Last, it seems you've based the serdev-ngsm-motmdm.c chardev implementation on a more or less verbatim copy of drivers/gnss/core.c. I'd appreciate if you could mention that in the file header and reproduce the copyright notice if you end up keeping that interface.

Quoted 8 lines

Oh yes indeed, thanks for pointing that out. I'll add it to the next version. The chardev code is for sure based on drivers/gnss.

To explain my ignorance, I added the chardev support initially as an experiment to see if I can handle the motorola packet layer better that way compared to the n_gsm ttys and userspace handling. It ended up working quite nicely, so I kept it but then I accidentally left out references to the source. Sorry about that.

No worries.

Johan

#10 lore raw

Hi!

Quoted 1 line

Sorry about the late reply on this.

I'm afraid I'll need some more answers in near future, but for now:

Tony, do you remember / can you figure out what gsmtty GPS is on? I never used it on that interface, and I can't seem to figure it out.

My notes say:

/dev/motmdm1 -- basic support, calls, on/off
/dev/motmdm3 -- send sms interface
/dev/motmdm9 -- receive sms interface

(and gsmtty numbering is same)

For now I converted gnss driver to use serdev interface, and n_gsm to provide it... Not yet finished but I believe I'm walking in the right direction.

Best regards,
Pavel

arch/arm/boot/dts/motorola-mapphone-common.dtsi +14 -1
index f5e7ec8e1028..ce907aa40a28 100644
@@ -761,9 +761,22 @@
 		};
 
 		gnss@4 {
-			compatible = "motorola,mapphone-mdm6600-gnss";
+			compatible = "disabled-old,motorola,mapphone-mdm6600-gnss";
 			reg = <4>;
 		};
+
+		port@1 {
+			compatible = "gsmmux,port";
+			reg = <1>;
+			subdev@1 {
+				 compatible = "motorola,mapphone-mdm6600-gnss";
+			};
+		};
+
+		port@3 {
+			compatible = "disabled,gsmmux,port";
+			reg = <3>;
+		};
 	};
 };
 
drivers/gnss/motmdm.c +93 -23

257 lines not on this page · raw message

drivers/tty/n_gsm.c +110 -114

377 lines not on this page · raw message

drivers/tty/serdev/core.c +23 -5
index c5f0d936b003..081702d5479d 100644
@@ -121,7 +121,7 @@ int serdev_device_add(struct serdev_device *serdev)
 		goto err_clear_serdev;
 	}
 
-	dev_dbg(&serdev->dev, "device %s registered\n", dev_name(&serdev->dev));
+	dev_info(&serdev->dev, "device %s registered, %p controller %p\n", dev_name(&serdev->dev), serdev, ctrl);
 
 	return 0;
 
@@ -509,7 +509,15 @@ struct serdev_controller *serdev_controller_alloc(struct device *parent,
 	pm_runtime_no_callbacks(&ctrl->dev);
 	pm_suspend_ignore_children(&ctrl->dev, true);
 
-	dev_dbg(&ctrl->dev, "allocated controller 0x%p id %d\n", ctrl, id);
+	/* /sys/bus/serial/drivers/serdev_ngsm/serial0-0 ?
+
+4806a000.serial:modem:audio-codec@2  modalias  subsystem
+4806a000.serial:modem:gnss@4	     of_node   supplier:[email protected]
+driver				     power     uevent
+
+	*/
+	dev_info(&ctrl->dev, "allocated controller 0x%p 0x%p id %d [%d]\n",
+		 ctrl, &ctrl->dev, id, ctrl->nr);
 	return ctrl;
 
 err_free:
@@ -527,10 +535,12 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
 	bool found = false;
 
 	for_each_available_child_of_node(ctrl->dev.of_node, node) {
+		dev_info(&ctrl->dev, "of_serdev_register_device: considering %pOF\n", node);
+		
 		if (!of_get_property(node, "compatible", NULL))
 			continue;
 
-		dev_dbg(&ctrl->dev, "adding child %pOF\n", node);
+		dev_info(&ctrl->dev, "adding child %pOF\n", node);
 
 		serdev = serdev_device_alloc(ctrl);
 		if (!serdev)
@@ -740,26 +750,34 @@ int serdev_controller_add(struct serdev_controller *ctrl)
 {
 	int ret_of, ret_acpi, ret;
 
+	printk("serdev_controller_add...\n");
+
 	/* Can't register until after driver model init */
 	if (WARN_ON(!is_registered))
 		return -EAGAIN;
 
+	printk("serdev_controller_add 1... %pOF\n", ctrl->dev.of_node);
+	
 	ret = device_add(&ctrl->dev);
 	if (ret)
 		return ret;
 
+	printk("serdev_controller_add 2...\n");	
 	pm_runtime_enable(&ctrl->dev);
 
 	ret_of = of_serdev_register_devices(ctrl);
 	ret_acpi = acpi_serdev_register_devices(ctrl);
 	if (ret_of && ret_acpi) {
-		dev_dbg(&ctrl->dev, "no devices registered: of:%pe acpi:%pe\n",
+		dev_info(&ctrl->dev, "no devices registered: of:%pe acpi:%pe\n",
 			ERR_PTR(ret_of), ERR_PTR(ret_acpi));
+#if 0
 		ret = -ENODEV;
 		goto err_rpm_disable;
+#endif		
 	}
 
-	dev_dbg(&ctrl->dev, "serdev%d registered: dev:%p\n",
+	printk("serdev_controller_add all ok?...\n");		
+	dev_info(&ctrl->dev, "serdev%d registered: dev:%p\n",
 		ctrl->nr, &ctrl->dev);
 	return 0;
 
drivers/tty/serdev/serdev-ngsm.c +7 -68

123 lines not on this page · raw message

drivers/tty/serdev/serdev-ttyport.c +5 -0
index d367803e2044..6f02a1546560 100644
@@ -272,6 +272,8 @@ struct device *serdev_tty_port_register(struct tty_port *port,
 	if (!port || !drv || !parent)
 		return ERR_PTR(-ENODEV);
 
+	printk("serdev_tty_port_register: %p, %d\n", port, idx);
+
 	ctrl = serdev_controller_alloc(parent, sizeof(struct serport));
 	if (!ctrl)
 		return ERR_PTR(-ENOMEM);
@@ -291,9 +293,12 @@ struct device *serdev_tty_port_register(struct tty_port *port,
 		goto err_reset_data;
 
 	dev_info(&ctrl->dev, "tty port %s%d registered\n", drv->name, idx);
+	printk("serdev_tty_port_register: controller is  %p, serdev %p\n", ctrl, ctrl->serdev);
+	
 	return &ctrl->dev;
 
 err_reset_data:
+	printk("serdev_tty_port_register: error?\n");
 	port->client_data = NULL;
 	port->client_ops = &tty_port_default_client_ops;
 	serdev_controller_put(ctrl);
include/linux/serdev-gsm.h +16 -16
index 4fa819a6e366..5bdc8143b7df 100644
@@ -7,7 +7,7 @@
 #include <linux/serdev.h>
 #include <linux/types.h>
 
-struct gsm_serdev_dlci;
+struct gsm_serdev_dlci_operations;
 struct gsm_config;
 
 /**
@@ -28,16 +28,16 @@ struct gsm_serdev {
 };
 
 /**
- * struct gsm_serdev_dlci - serdev-gsm ts 27.010 channel data
+ * struct gsm_serdev_dlci_operations - serdev-gsm ts 27.010 channel data
  * @gsd:		serdev-gsm instance
  * @line:		ts 27.010 channel, control channel 0 is not available
  * @receive_buf:	function to handle data received for the channel
  * @drvdata:		dlci specific consumer driver data
  */
-struct gsm_serdev_dlci {
+struct gsm_serdev_dlci_operations {
 	struct gsm_serdev *gsd;
 	int line;
-	int (*receive_buf)(struct gsm_serdev_dlci *ops,
+	int (*receive_buf)(struct gsm_serdev_dlci_operations *ops,
 			   const unsigned char *buf,
 			   size_t len);
 	void *drvdata;
@@ -48,12 +48,12 @@ struct gsm_serdev_dlci {
 /* TS 27.010 channel specific functions for consumer drivers */
 #if IS_ENABLED(CONFIG_SERIAL_DEV_N_GSM)
 extern int
-serdev_ngsm_register_dlci(struct device *dev, struct gsm_serdev_dlci *dlci);
+serdev_ngsm_register_dlci(struct device *dev, struct gsm_serdev_dlci_operations *dlci);
 extern void serdev_ngsm_unregister_dlci(struct device *dev,
-					struct gsm_serdev_dlci *dlci);
-extern int serdev_ngsm_write(struct device *dev, struct gsm_serdev_dlci *ops,
+					struct gsm_serdev_dlci_operations *dlci);
+extern int serdev_ngsm_write(struct device *dev, struct gsm_serdev_dlci_operations *ops,
 			     const u8 *buf, int len);
-extern struct gsm_serdev_dlci *
+extern struct gsm_serdev_dlci_operations *
 serdev_ngsm_get_dlci(struct device *dev, int line);
 #endif
 
@@ -62,7 +62,7 @@ extern int gsm_serdev_register_device(struct gsm_serdev *gsd);
 extern void gsm_serdev_unregister_device(struct gsm_serdev *gsd);
 extern int gsm_serdev_register_tty_port(struct gsm_serdev *gsd, int line);
 extern void gsm_serdev_unregister_tty_port(struct gsm_serdev *gsd, int line);
-extern struct gsm_serdev_dlci *
+extern struct gsm_serdev_dlci_operations *
 gsm_serdev_tty_port_get_dlci(struct gsm_serdev *gsd, int line);
 
 static inline void *gsm_serdev_get_drvdata(struct device *dev)
@@ -88,10 +88,10 @@ static inline void gsm_serdev_set_drvdata(struct device *dev, void *drvdata)
 extern int gsm_serdev_get_config(struct gsm_serdev *gsd, struct gsm_config *c);
 extern int gsm_serdev_set_config(struct gsm_serdev *gsd, struct gsm_config *c);
 extern int
-gsm_serdev_register_dlci(struct gsm_serdev *gsd, struct gsm_serdev_dlci *ops);
+gsm_serdev_register_dlci(struct gsm_serdev *gsd, struct gsm_serdev_dlci_operations *ops);
 extern void
-gsm_serdev_unregister_dlci(struct gsm_serdev *gsd, struct gsm_serdev_dlci *ops);
-extern int gsm_serdev_write(struct gsm_serdev *gsd, struct gsm_serdev_dlci *ops,
+gsm_serdev_unregister_dlci(struct gsm_serdev *gsd, struct gsm_serdev_dlci_operations *ops);
+extern int gsm_serdev_write(struct gsm_serdev *gsd, struct gsm_serdev_dlci_operations *ops,
 			    const u8 *buf, int len);
 extern void gsm_serdev_data_kick(struct gsm_serdev *gsd);
 
@@ -118,7 +118,7 @@ void gsm_serdev_unregister_tty_port(struct gsm_serdev *gsd, int line)
 {
 }
 
-static inline struct gsm_serdev_dlci *
+static inline struct gsm_serdev_dlci_operations *
 gsm_serdev_tty_port_get_dlci(struct gsm_serdev *gsd, int line)
 {
 	return NULL;
@@ -148,19 +148,19 @@ int gsm_serdev_set_config(struct gsm_serdev *gsd, struct gsm_config *c)
 
 static inline
 int gsm_serdev_register_dlci(struct gsm_serdev *gsd,
-			     struct gsm_serdev_dlci *ops)
+			     struct gsm_serdev_dlci_operations *ops)
 {
 	return -ENODEV;
 }
 
 static inline
 void gsm_serdev_unregister_dlci(struct gsm_serdev *gsd,
-				struct gsm_serdev_dlci *ops)
+				struct gsm_serdev_dlci_operations *ops)
 {
 }
 
 static inline
-int gsm_serdev_write(struct gsm_serdev *gsd, struct gsm_serdev_dlci *ops,
+int gsm_serdev_write(struct gsm_serdev *gsd, struct gsm_serdev_dlci_operations *ops,
 		     const u8 *buf, int len)
 {
 	return -ENODEV;
include/linux/serdev.h +3 -0
index 9f14f9c12ec4..efdffe34a9b5 100644
@@ -128,6 +128,7 @@ static inline void serdev_device_set_drvdata(struct serdev_device *serdev, void
  */
 static inline void serdev_device_put(struct serdev_device *serdev)
 {
+	printk("serdev_device_put... %p\n", serdev);
 	if (serdev)
 		put_device(&serdev->dev);
 }
@@ -156,6 +157,8 @@ static inline void serdev_controller_set_drvdata(struct serdev_controller *ctrl,
  */
 static inline void serdev_controller_put(struct serdev_controller *ctrl)
 {
+	printk("serdev_controller_put... %p\n", ctrl);
+	WARN_ON(1);
 	if (ctrl)
 		put_device(&ctrl->dev);
 }
lib/vsprintf.c +1 -1
index afb9521ddf91..530a0146893c 100644
@@ -802,7 +802,7 @@ static char *ptr_to_id(char *buf, char *end, const void *ptr,
 	 * Print the real pointer value for NULL and error pointers,
 	 * as they are not actual addresses.
 	 */
-	if (IS_ERR_OR_NULL(ptr))
+//	if (IS_ERR_OR_NULL(ptr))
 		return pointer_string(buf, end, ptr, spec);
 
 	/* When debugging early boot use non-cryptographically secure hash. */
sound/soc/codecs/motmdm.c +8 -8
index 325a860ef665..1528c89d9d57 100644
@@ -28,7 +28,7 @@ struct motmdm_driver_data {
 	struct snd_soc_component *component;
 	struct snd_soc_dai *master_dai;
 	struct device *modem;
-	struct gsm_serdev_dlci dlci;
+	struct gsm_serdev_dlci_operations dlci;
 	struct regmap *regmap;
 	unsigned char *buf;
 	size_t len;
@@ -38,7 +38,7 @@ struct motmdm_driver_data {
 	struct mutex mutex;	/* for sending commands */
 	wait_queue_head_t read_queue;
 
-	int (*receive_buf_orig)(struct gsm_serdev_dlci *ops,
+	int (*receive_buf_orig)(struct gsm_serdev_dlci_operations *ops,
 				const unsigned char *buf,
 				size_t len);
 	unsigned int dtmf_val;
@@ -121,7 +121,7 @@ static int motmdm_send_command(struct motmdm_driver_data *ddata,
 }
 
 /* Handle U1234+XXXX= style command response */
-static int motmdm_receive_data(struct gsm_serdev_dlci *dlci,
+static int motmdm_receive_data(struct gsm_serdev_dlci_operations *dlci,
 			       const unsigned char *buf,
 			       size_t len)
 {
@@ -569,7 +569,7 @@ static void motmdm_voice_get_state(struct motmdm_driver_data *ddata,
 		motmdm_disable_primary_dai(ddata->component);
 }
 
-static int receive_buf_voice(struct gsm_serdev_dlci *ops,
+static int receive_buf_voice(struct gsm_serdev_dlci_operations *ops,
 			     const unsigned char *buf,
 			     size_t len)
 {
@@ -585,7 +585,7 @@ static int receive_buf_voice(struct gsm_serdev_dlci *ops,
 /* Read the voice status from dlci1 and let user space handle rest */
 static int motmdm_init_voice_dlci(struct motmdm_driver_data *ddata)
 {
-	struct gsm_serdev_dlci *dlci;
+	struct gsm_serdev_dlci_operations *dlci;
 
 	dlci = serdev_ngsm_get_dlci(ddata->modem, MOTMDM_VOICE_DLCI);
 	if (!dlci)
@@ -600,7 +600,7 @@ static int motmdm_init_voice_dlci(struct motmdm_driver_data *ddata)
 
 static void motmdm_free_voice_dlci(struct motmdm_driver_data *ddata)
 {
-	struct gsm_serdev_dlci *dlci;
+	struct gsm_serdev_dlci_operations *dlci;
 
 	dlci = serdev_ngsm_get_dlci(ddata->modem, MOTMDM_VOICE_DLCI);
 	if (!dlci)
@@ -613,7 +613,7 @@ static void motmdm_free_voice_dlci(struct motmdm_driver_data *ddata)
 static int motmdm_soc_probe(struct snd_soc_component *component)
 {
 	struct motmdm_driver_data *ddata;
-	struct gsm_serdev_dlci *dlci;
+	struct gsm_serdev_dlci_operations *dlci;
 	const unsigned char *cmd = "AT+CMUT=0";
 	int error;
 	u32 line;
@@ -690,7 +690,7 @@ static int motmdm_soc_probe(struct snd_soc_component *component)
 static void motmdm_soc_remove(struct snd_soc_component *component)
 {
 	struct motmdm_driver_data *ddata;
-	struct gsm_serdev_dlci *dlci;
+	struct gsm_serdev_dlci_operations *dlci;
 
 	ddata = snd_soc_component_get_drvdata(component);
 	dlci = &ddata->dlci;
sound/soc/generic/audio-graph-card.c +11 -0
index 97b4f5480a31..31ff426226ef 100644
@@ -631,6 +631,8 @@ static int graph_probe(struct platform_device *pdev)
 	struct link_info li;
 	int ret;
 
+	printk("audio-graph: probe starts\n");
+
 	/* Allocate the private data and the DAI link array */
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -648,19 +650,24 @@ static int graph_probe(struct platform_device *pdev)
 	if (!li.link || !li.dais)
 		return -EINVAL;
 
+	printk("audio-graph: 2\n");
+
 	ret = asoc_simple_init_priv(priv, &li);
 	if (ret < 0)
 		return ret;
 
 	priv->pa_gpio = devm_gpiod_get_optional(dev, "pa", GPIOD_OUT_LOW);
 	if (IS_ERR(priv->pa_gpio)) {
+		printk("audio-graph: optional pa failed\n");
 		ret = PTR_ERR(priv->pa_gpio);
 		dev_err(dev, "failed to get amplifier gpio: %d\n", ret);
 		return ret;
 	}
 
+	printk("audio-graph: parsing of\n");	
 	ret = graph_parse_of(priv);
 	if (ret < 0) {
+		printk("audio-graph: parsing of failed: %d\n", ret);	
 		if (ret != -EPROBE_DEFER)
 			dev_err(dev, "parse error %d\n", ret);
 		goto err;
@@ -670,9 +677,13 @@ static int graph_probe(struct platform_device *pdev)
 
 	asoc_simple_debug_info(priv);
 
+		printk("audio-graph: registering card\n");	
+	
+
 	ret = devm_snd_soc_register_card(dev, card);
 	if (ret < 0)
 		goto err;
+		printk("audio-graph: all ok\n");	
 
 	return 0;
 err:
Signature · 1 line
http://www.livejournal.com/~pavelmachek
#11 lore raw

Hi,

Quoted 9 lines · Pavel Machek

Hi!

Quoted 1 line

Sorry about the late reply on this.

I'm afraid I'll need some more answers in near future, but for now:

Tony, do you remember / can you figure out what gsmtty GPS is on? I never used it on that interface, and I can't seem to figure it out.

Quoted 7 lines

My notes say:

/dev/motmdm1 -- basic support, calls, on/off
/dev/motmdm3 -- send sms interface
/dev/motmdm9 -- receive sms interface

(and gsmtty numbering is same)

Yes I have not had a chance to look at these for several months now, but have the latest set in droid4-pending-v5.10 branch in my github tree.

The gnss device is at /dev/gsmtty6, see the current droid4-agps tool to upload the almanac also on github. That's has turned out to be a pretty good gsm serdev test too :)

Quoted 3 lines

For now I converted gnss driver to use serdev interface, and n_gsm to provide it... Not yet finished but I believe I'm walking in the right direction.

Great, sounds good to me if you got things working with just serdev calls :) I'll try to take a look at this stuff again after I have the other pending droid4 issues out of the way like v5.12 charger and keyboard stuff.

Regards,

Tony

#12 lore raw

Hi!

Quoted 8 lines
Quoted 7 lines

My notes say:

/dev/motmdm1 -- basic support, calls, on/off
/dev/motmdm3 -- send sms interface
/dev/motmdm9 -- receive sms interface

(and gsmtty numbering is same)

Quoted 7 lines

Yes I have not had a chance to look at these for several months now, but have the latest set in droid4-pending-v5.10 branch in my github tree.

The gnss device is at /dev/gsmtty6, see the current droid4-agps tool to upload the almanac also on github. That's has turned out to be a pretty good gsm serdev test too :)

Thanks a lot for the info! Is it this one?
https://github.com/tmlind/droid4-agps . GPS worked for me even w/o AGPS support, but I broke even that, so I need to fix that first.

Quoted 8 lines
Quoted 3 lines

For now I converted gnss driver to use serdev interface, and n_gsm to provide it... Not yet finished but I believe I'm walking in the right direction.

Great, sounds good to me if you got things working with just serdev calls :) I'll try to take a look at this stuff again after I have the other pending droid4 issues out of the way like v5.12 charger and keyboard stuff.

Just ask for latest code :-). I still believe I'm going right direction, but now I understand why you did it the way you did. Sound code needs to listen on gsmtty1, with the data still being provided for userspace.

Best regards,
Pavel

Signature · 1 line
http://www.livejournal.com/~pavelmachek
#13 lore raw
In reply to Tony Lindgren

Hi!

Quoted 13 lines
Quoted 5 lines

I'm afraid I'll need some more answers in near future, but for now:

Tony, do you remember / can you figure out what gsmtty GPS is on? I never used it on that interface, and I can't seem to figure it out.

Quoted 7 lines

My notes say:

/dev/motmdm1 -- basic support, calls, on/off
/dev/motmdm3 -- send sms interface
/dev/motmdm9 -- receive sms interface

(and gsmtty numbering is same)

Quoted 7 lines

Yes I have not had a chance to look at these for several months now, but have the latest set in droid4-pending-v5.10 branch in my github tree.

The gnss device is at /dev/gsmtty6, see the current droid4-agps tool to upload the almanac also on github. That's has turned out to be a pretty good gsm serdev test too :)

Treason uncloaked!

While A-GPS is at gsmtty6 I guess, NMEA data are on gsmtty4. And I could not access that one, due to bitmask reserving it for gnss.

But now I have figured it out, and should have something reviewable soon.

Thanks for support,

Pavel

Signature · 1 line
http://www.livejournal.com/~pavelmachek
#14 lore raw
In reply to Johan Hovold

Hi!

Quoted 8 lines
Quoted 7 lines

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

Quoted 6 lines

I'm still missing an architectural (design) overview here -- reviewer time is a scarce resource.

I also suggested earlier that you include, at least as an RFC, one or more of your child-device drivers so that we can see how this ends up being used in the end (including an example devicetree).

Note that this is useful on its own: we have ofonod running on the top of this doing calls and SMSes.

Tony: I know you have drivers depending on this somewhere (audio routing and GPS), but I can't find them. It is not droid4-pending-v5.6 AFAICT. Do you have a pointer / could you publish them somewhere?

Best regards,
Pavel

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

Hi!

Quoted 11 lines
Quoted 7 lines

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

I'm still missing an architectural (design) overview here -- reviewer time is a scarce resource.

Quoted 6 lines
Quoted 3 lines

I also suggested earlier that you include, at least as an RFC, one or more of your child-device drivers so that we can see how this ends up being used in the end (including an example devicetree).

Note that this is useful on its own: we have ofonod running on the top of this doing calls and SMSes.

Yup.

Quoted 3 lines

Tony: I know you have drivers depending on this somewhere (audio routing and GPS), but I can't find them. It is not droid4-pending-v5.6 AFAICT. Do you have a pointer / could you publish them somewhere?

Hmm they should be there in droid4-pending-v5.6 branch [0]:

$ git log --abbrev=12 --pretty=format:"%h (\"%s\")" \
	v5.6..droid4-pending-v5.6 | grep -i -e gsm -e mot -e mdm
e09590a260a4 ("mfd: motmdm: Fix oops on unload of motorola-mdm")
f9252f9ff6bd ("mfd: motmdm: Revert bad list change")
d733dcaf4416 ("mfd: motmdm: Fix issue with receiving data before ddata is set")
452d2b5d4c95 ("n_gsm: Build fixes for make randconfig build")
6882b27ea92a ("phy: mapphone-mdm6600: Fix write timeouts with shorter GPIO toggle interval")
58ff58c4b520 ("mfd: motmdm: Add basic DTMF support")
e92b6f30e5ae ("ASoC: audio-graph-card: Add audio mixer for motorold mdm6600")
c2caea5767d5 ("gnss: mot-mdm6600: Add support for Motorola Mapphone MDM6600 modem")
a5f73b7b06f6 ("mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4")
6c311d5aeb0a ("dt-bindings: mfd: motmdm: Add binding for motorola-mdm")
cd02274b920e ("tty: n_gsm: Add support for serdev drivers")
a73a48321c98 ("phy: mapphone-mdm6600: Fix timeouts by adding wake-up handling")

Regards,

Tony

[0] https://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git/log/?h=droid4-pending-v5.6

#16 lore raw

Hi!

Quoted 26 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

I'm still missing an architectural (design) overview here -- reviewer time is a scarce resource.

Quoted 6 lines
Quoted 3 lines

I also suggested earlier that you include, at least as an RFC, one or more of your child-device drivers so that we can see how this ends up being used in the end (including an example devicetree).

Note that this is useful on its own: we have ofonod running on the top of this doing calls and SMSes.

Yup.

Quoted 3 lines

Tony: I know you have drivers depending on this somewhere (audio routing and GPS), but I can't find them. It is not droid4-pending-v5.6 AFAICT. Do you have a pointer / could you publish them somewhere?

Hmm they should be there in droid4-pending-v5.6 branch [0]:

Quoted 14 lines
$ git log --abbrev=12 --pretty=format:"%h (\"%s\")" \
	v5.6..droid4-pending-v5.6 | grep -i -e gsm -e mot -e mdm
e09590a260a4 ("mfd: motmdm: Fix oops on unload of motorola-mdm")
f9252f9ff6bd ("mfd: motmdm: Revert bad list change")
d733dcaf4416 ("mfd: motmdm: Fix issue with receiving data before ddata is set")
452d2b5d4c95 ("n_gsm: Build fixes for make randconfig build")
6882b27ea92a ("phy: mapphone-mdm6600: Fix write timeouts with shorter GPIO toggle interval")
58ff58c4b520 ("mfd: motmdm: Add basic DTMF support")
e92b6f30e5ae ("ASoC: audio-graph-card: Add audio mixer for motorold mdm6600")
c2caea5767d5 ("gnss: mot-mdm6600: Add support for Motorola Mapphone MDM6600 modem")
a5f73b7b06f6 ("mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4")
6c311d5aeb0a ("dt-bindings: mfd: motmdm: Add binding for motorola-mdm")
cd02274b920e ("tty: n_gsm: Add support for serdev drivers")
a73a48321c98 ("phy: mapphone-mdm6600: Fix timeouts by adding wake-up handling")

Thanks for pointers, I was lost in all the git trees. Port is not quite trivial :-(.

I tried to port GPS and codec support over to new version of base patches, but I get oops when I try to open the GPS:

Best regards,

								Pavel
    
    [  182.877014] bfe0: 00000005 bed23af8 b6f279cf b6eb46f6 00070030
    bed23ea7 00000000 00000000
    [  182.901672] [<c06e7ba8>] (motmdm_gnss_open) from [<c06e71d4>]
    (gnss_open+0x7c/0xb0)
    [  182.901672] [<c06e71d4>] (gnss_open) from [<c0221fe0>]
    (chrdev_open+0x9c/0x194)
    [  182.901672] [<c0221fe0>] (chrdev_open) from [<c0219524>]
    (do_dentry_open+0x21c/0x3e8)
    [  182.901672] [<c0219524>] (do_dentry_open) from [<c022b424>]
    (path_openat+0x8b0/0xc1c)
    [  182.901672] [<c022b424>] (path_openat) from [<c022d0ac>]
    (do_filp_open+0x60/0xb4)
    [  182.940002] [<c022d0ac>] (do_filp_open) from [<c0219958>]
    (do_sys_openat2+0x1f0/0x2f4)
    [  182.940002] [<c0219958>] (do_sys_openat2) from [<c021ada8>]
    (do_sys_open+0x98:
drivers/gnss/Kconfig +0 -1
index 960178dfad47..13b91034e3ea 100644
@@ -15,7 +15,6 @@ if GNSS
 
 config GNSS_MOTMDM
 	tristate "Motorola Modem TS 27.010 serdev GNSS receiver support"
-	depends on MFD_MOTMDM
 	---help---
 	  Say Y here if you have a Motorola modem using TS 27.010 line
 	  discipline for GNSS such as a Motorola Mapphone series device
drivers/tty/serdev/protocol/serdev-ngsm-motmdm.c +2 -2
index 97eb349f5f13..f234a0cd2fb7 100644
@@ -477,7 +477,7 @@ static int motmdm_send_command(struct device *dev,
 	return err;
 }
 
-static int motmdm_register_dlci(struct device *dev,
+int motmdm_register_dlci(struct device *dev,
 				struct motmdm_dlci *mot_dlci)
 {
 	struct motmdm *ddata;
@@ -522,7 +522,7 @@ static int motmdm_register_dlci(struct device *dev,
 	return err;
 }
 
-static void motmdm_unregister_dlci(struct device *dev,
+void motmdm_unregister_dlci(struct device *dev,
 				   struct motmdm_dlci *mot_dlci)
 {
 	struct motmdm *ddata;
include/linux/mfd/motorola-mdm.h new file +84 -0

84 lines not on this page · raw message

sound/soc/codecs/Kconfig +0 -1
index 3635fc0ab2a6..63d8d3e731ff 100644
@@ -878,7 +878,6 @@ config SND_SOC_MAX9860
 
 config SND_SOC_MOTMDM
 	tristate "Motorola Modem TS 27.010 Voice Call Codec"
-	depends on MFD_MOTMDM
 	help
 	  Enable support for Motorola TS 27.010 line discipline serdev
 	  voice call codec driver for Motorola Mapphone series of devices
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#17 lore raw
In reply to Tony Lindgren

Hi!

Quoted 26 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

I'm still missing an architectural (design) overview here -- reviewer time is a scarce resource.

Quoted 6 lines
Quoted 3 lines

I also suggested earlier that you include, at least as an RFC, one or more of your child-device drivers so that we can see how this ends up being used in the end (including an example devicetree).

Note that this is useful on its own: we have ofonod running on the top of this doing calls and SMSes.

Yup.

Quoted 3 lines

Tony: I know you have drivers depending on this somewhere (audio routing and GPS), but I can't find them. It is not droid4-pending-v5.6 AFAICT. Do you have a pointer / could you publish them somewhere?

Hmm they should be there in droid4-pending-v5.6 branch [0]:

Quoted 14 lines
$ git log --abbrev=12 --pretty=format:"%h (\"%s\")" \
	v5.6..droid4-pending-v5.6 | grep -i -e gsm -e mot -e mdm
e09590a260a4 ("mfd: motmdm: Fix oops on unload of motorola-mdm")
f9252f9ff6bd ("mfd: motmdm: Revert bad list change")
d733dcaf4416 ("mfd: motmdm: Fix issue with receiving data before ddata is set")
452d2b5d4c95 ("n_gsm: Build fixes for make randconfig build")
6882b27ea92a ("phy: mapphone-mdm6600: Fix write timeouts with shorter GPIO toggle interval")
58ff58c4b520 ("mfd: motmdm: Add basic DTMF support")
e92b6f30e5ae ("ASoC: audio-graph-card: Add audio mixer for motorold mdm6600")
c2caea5767d5 ("gnss: mot-mdm6600: Add support for Motorola Mapphone MDM6600 modem")
a5f73b7b06f6 ("mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4")
6c311d5aeb0a ("dt-bindings: mfd: motmdm: Add binding for motorola-mdm")
cd02274b920e ("tty: n_gsm: Add support for serdev drivers")
a73a48321c98 ("phy: mapphone-mdm6600: Fix timeouts by adding wake-up handling")

Here's better try at getting gnss to work on top of linux-next... but still no luck.

drivers/gnss/Kconfig +0 -1
index 960178dfad47..13b91034e3ea 100644
@@ -15,7 +15,6 @@ if GNSS
 
 config GNSS_MOTMDM
 	tristate "Motorola Modem TS 27.010 serdev GNSS receiver support"
-	depends on MFD_MOTMDM
 	---help---
 	  Say Y here if you have a Motorola modem using TS 27.010 line
 	  discipline for GNSS such as a Motorola Mapphone series device
drivers/gnss/motmdm.c +4 -0
index 5ec2fa25df6f..426e9da6bb12 100644
@@ -21,6 +21,8 @@
 
 #include <linux/mfd/motorola-mdm.h>
 
+#define DEBUG
+
 #define MOTMDM_GNSS_TIMEOUT	1000
 #define MOTMDM_GNSS_RATE	1000
 
@@ -197,6 +199,8 @@ static int motmdm_gnss_receive_data(struct motmdm_dlci *mot_dlci,
 	if (len <= MOTMDM_GNSS_MPD_LEN)
 		return 0;
 
+	printk("gnss: Have %d bytes of data\n", len);
+
 	switch (buf[MOTMDM_GNSS_MPD_LEN]) {
 	case 'N':	/* UNNNN~+MPDNMEA=NN, */
 		msg = buf + MOTMDM_GNSS_NMEA_LEN;
drivers/tty/serdev/protocol/serdev-ngsm-motmdm.c +10 -33

85 lines not on this page · raw message

include/linux/mfd/motorola-mdm.h new file +59 -0

59 lines not on this page · raw message

sound/soc/codecs/Kconfig +0 -1
index 3635fc0ab2a6..63d8d3e731ff 100644
@@ -878,7 +878,6 @@ config SND_SOC_MAX9860
 
 config SND_SOC_MOTMDM
 	tristate "Motorola Modem TS 27.010 Voice Call Codec"
-	depends on MFD_MOTMDM
 	help
 	  Enable support for Motorola TS 27.010 line discipline serdev
 	  voice call codec driver for Motorola Mapphone series of devices
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#18 lore raw
Quoted 43 lines · Pavel Machek

Hi!

Quoted 26 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines

Here's v4 set of n_gsm serdev support patches, and the related protocol driver for the modem found on Motorola Mapphone phones and tablets like droid4.

This series only adds basic character device support for the serdev driver. Other serdev consumer drivers for specific devices will be posted separately.

I'm still missing an architectural (design) overview here -- reviewer time is a scarce resource.

Quoted 6 lines
Quoted 3 lines

I also suggested earlier that you include, at least as an RFC, one or more of your child-device drivers so that we can see how this ends up being used in the end (including an example devicetree).

Note that this is useful on its own: we have ofonod running on the top of this doing calls and SMSes.

Yup.

Quoted 3 lines

Tony: I know you have drivers depending on this somewhere (audio routing and GPS), but I can't find them. It is not droid4-pending-v5.6 AFAICT. Do you have a pointer / could you publish them somewhere?

Hmm they should be there in droid4-pending-v5.6 branch [0]:

Quoted 14 lines
$ git log --abbrev=12 --pretty=format:"%h (\"%s\")" \
	v5.6..droid4-pending-v5.6 | grep -i -e gsm -e mot -e mdm
e09590a260a4 ("mfd: motmdm: Fix oops on unload of motorola-mdm")
f9252f9ff6bd ("mfd: motmdm: Revert bad list change")
d733dcaf4416 ("mfd: motmdm: Fix issue with receiving data before ddata is set")
452d2b5d4c95 ("n_gsm: Build fixes for make randconfig build")
6882b27ea92a ("phy: mapphone-mdm6600: Fix write timeouts with shorter GPIO toggle interval")
58ff58c4b520 ("mfd: motmdm: Add basic DTMF support")
e92b6f30e5ae ("ASoC: audio-graph-card: Add audio mixer for motorold mdm6600")
c2caea5767d5 ("gnss: mot-mdm6600: Add support for Motorola Mapphone MDM6600 modem")
a5f73b7b06f6 ("mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4")
6c311d5aeb0a ("dt-bindings: mfd: motmdm: Add binding for motorola-mdm")
cd02274b920e ("tty: n_gsm: Add support for serdev drivers")
a73a48321c98 ("phy: mapphone-mdm6600: Fix timeouts by adding wake-up handling")
Quoted 2 lines

Here's better try at getting gnss to work on top of linux-next... but still no luck.

Hmm that's about all it should take. Presumably you already tried diffing the related files against droid4-pending-v5.6 branch.

I'm moving around things to work with a generic serdev-ngsm.c driver so I'm inbetween patches right now and don't have it working either probably for a few more days.

Regards,

Tony