2018-03-09 02:39:35

by Tony Lindgren

[permalink] [raw]
Subject: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Let's add support for the GPIO controlled USB PHY on the MDM6600 modem.
It is used on some Motorola Mapphone series of phones and tablets such
as Droid 4.

The MDM6600 is hardwired to the first OHCI port in the Droid 4 case, and
is controlled by several GPIOs. The USB PHY is integrated into the MDM6600
device it seems. We know this as we get L3 errors from omap-usb-host if
trying to use the PHY before MDM6600 is configured.

The GPIOs controlling MDM6600 are used to power device on and off, to
configure the USB start-up mode (normal mode versus USB flashing), and
they also tell the state of the MDM6600 device.

The two start-up mode GPIOs are dual-purposed and used for out of band
(OOB) wake-up for USB and TS 27.010 serial mux. But we need to configure
the USB start-up mode first to get MDM6600 booted in the right mode to
be usable in the first place.

Note that the Motorola Mapphone Linux kernel tree has a "radio-ctrl"
driver for modems. But it really does not control the radio at all, it
just controls the modem power and start-up mode for USB. So I came to
the conclusion that we're better off having this done in the USB PHY
driver. For adding support for USB flashing mode, we can later on add
a kernel module option for flash_mode=1 or something similar.

Also note that currently there is no PM runtime support for the OHCI
on omap variant SoCs. So for low(er) power idle states, currenty both
ohci-platform and phy-mapphone-mdm6600 must be unloaded or unbound.

For reference here is what I measured for total power consumption on
an idle Droid 4 with and without USB related MDM6600 modules:

idle lcd off phy-mapphone-mdm6600 ohci-platform
153mW 284mW 344mW

So it seems that MDM6600 is currently not yet idling even with it's
radio turned off, but that's something that is beyond the control of
this USB PHY driver. This patch does get us to the point where modem
data and GPS are usable with libqmi and ModemManager for example.
Voice calls need more audio driver work.

Cc: [email protected]
Cc: Mark Rutland <[email protected]>
Cc: Marcel Partap <[email protected]>
Cc: Michael Scott <[email protected]>
Cc: Rob Herring <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
Signed-off-by: Tony Lindgren <[email protected]>
---

Changes since v3:
- Dropped unneeded usb_phy related parts as suggested by Kishon

Changes since v2:
- Dropped OTG as suggested by Kishon
- Added Rob's Reviewed-by

Changes since v1:
- Fixed up issues noticed by Rob and Sebastian
- Implemented wake irq handler (for debug use only for now)
- Improved error handling based on more testing

---
.../bindings/phy/phy-mapphone-mdm6600.txt | 30 ++
drivers/phy/motorola/Kconfig | 8 +
drivers/phy/motorola/Makefile | 1 +
drivers/phy/motorola/phy-mapphone-mdm6600.c | 542 +++++++++++++++++++++
4 files changed, 581 insertions(+)
create mode 100644 Documentation/devicetree/bindings/phy/phy-mapphone-mdm6600.txt
create mode 100644 drivers/phy/motorola/phy-mapphone-mdm6600.c

diff --git a/Documentation/devicetree/bindings/phy/phy-mapphone-mdm6600.txt b/Documentation/devicetree/bindings/phy/phy-mapphone-mdm6600.txt
new file mode 100644
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/phy-mapphone-mdm6600.txt
@@ -0,0 +1,30 @@
+Device tree binding documentation for Motorola Mapphone MDM6600 USB PHY
+
+Required properties:
+- compatible Must be "motorola,mapphone-mdm6600"
+- enable-gpios GPIO to enable the USB PHY
+- power-gpios GPIO to power on the device
+- reset-gpios GPIO to reset the device
+- motorola,mode-gpios Two GPIOs to configure MDM6600 USB start-up mode for
+ normal mode versus USB flashing mode
+- motorola,cmd-gpios Three GPIOs to control the power state of the MDM6600
+- motorola,status-gpios Three GPIOs to read the power state of the MDM6600
+
+Example:
+
+usb-phy {
+ compatible = "motorola,mapphone-mdm6600";
+ enable-gpios = <&gpio3 31 GPIO_ACTIVE_LOW>;
+ power-gpios = <&gpio2 22 GPIO_ACTIVE_HIGH>;
+ reset-gpios = <&gpio2 17 GPIO_ACTIVE_HIGH>;
+ motorola,mode-gpios = <&gpio5 20 GPIO_ACTIVE_HIGH>,
+ <&gpio5 21 GPIO_ACTIVE_HIGH>;
+ motorola,cmd-gpios = <&gpio4 7 GPIO_ACTIVE_HIGH>,
+ <&gpio4 8 GPIO_ACTIVE_HIGH>,
+ <&gpio5 14 GPIO_ACTIVE_HIGH>;
+ motorola,status-gpios = <&gpio2 20 GPIO_ACTIVE_HIGH>,
+ <&gpio2 21 GPIO_ACTIVE_HIGH>,
+ <&gpio2 23 GPIO_ACTIVE_HIGH>;
+ #phy-cells = <0>;
+};
+
diff --git a/drivers/phy/motorola/Kconfig b/drivers/phy/motorola/Kconfig
--- a/drivers/phy/motorola/Kconfig
+++ b/drivers/phy/motorola/Kconfig
@@ -10,3 +10,11 @@ config PHY_CPCAP_USB
help
Enable this for USB to work on Motorola phones and tablets
such as Droid 4.
+
+config PHY_MAPPHONE_MDM6600
+ tristate "Motorola Mapphone MDM6600 modem USB PHY driver"
+ depends on OF && USB_SUPPORT
+ select GENERIC_PHY
+ help
+ Enable this for MDM6600 USB modem to work on Motorola phones
+ and tablets such as Droid 4.
diff --git a/drivers/phy/motorola/Makefile b/drivers/phy/motorola/Makefile
--- a/drivers/phy/motorola/Makefile
+++ b/drivers/phy/motorola/Makefile
@@ -3,3 +3,4 @@
#

obj-$(CONFIG_PHY_CPCAP_USB) += phy-cpcap-usb.o
+obj-$(CONFIG_PHY_MAPPHONE_MDM6600) += phy-mapphone-mdm6600.o
diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c
new file mode 100644
--- /dev/null
+++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c
@@ -0,0 +1,542 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Motorola Mapphone MDM6600 modem GPIO controlled USB PHY driver
+ * Copyright (C) 2018 Tony Lindgren <[email protected]>
+ */
+
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#include <linux/gpio/consumer.h>
+#include <linux/of_platform.h>
+#include <linux/phy/phy.h>
+
+#define PHY_MDM6600_PHY_DELAY_MS 4000 /* PHY enable 2.2s to 3.5s */
+#define PHY_MDM6600_ENABLED_DELAY_MS 8000 /* 8s more total for MDM6600 */
+
+enum phy_mdm6600_ctrl_lines {
+ PHY_MDM6600_ENABLE, /* USB PHY enable */
+ PHY_MDM6600_POWER, /* Device power */
+ PHY_MDM6600_RESET, /* Device reset */
+ PHY_MDM6600_NR_CTRL_LINES,
+};
+
+enum phy_mdm6600_bootmode_lines {
+ PHY_MDM6600_MODE0, /* out USB mode0 and OOB wake */
+ PHY_MDM6600_MODE1, /* out USB mode1, in OOB wake */
+ PHY_MDM6600_NR_MODE_LINES,
+};
+
+enum phy_mdm6600_cmd_lines {
+ PHY_MDM6600_CMD0,
+ PHY_MDM6600_CMD1,
+ PHY_MDM6600_CMD2,
+ PHY_MDM6600_NR_CMD_LINES,
+};
+
+enum phy_mdm6600_status_lines {
+ PHY_MDM6600_STATUS0,
+ PHY_MDM6600_STATUS1,
+ PHY_MDM6600_STATUS2,
+ PHY_MDM6600_NR_STATUS_LINES,
+};
+
+/*
+ * MDM6600 command codes. These are based on Motorola Mapphone Linux
+ * kernel tree.
+ */
+enum phy_mdm6600_cmd {
+ PHY_MDM6600_CMD_BP_PANIC_ACK,
+ PHY_MDM6600_CMD_DATA_ONLY_BYPASS, /* Reroute USB to CPCAP PHY */
+ PHY_MDM6600_CMD_FULL_BYPASS, /* Reroute USB to CPCAP PHY */
+ PHY_MDM6600_CMD_NO_BYPASS, /* Request normal USB mode */
+ PHY_MDM6600_CMD_BP_SHUTDOWN_REQ, /* Request device power off */
+ PHY_MDM6600_CMD_BP_UNKNOWN_5,
+ PHY_MDM6600_CMD_BP_UNKNOWN_6,
+ PHY_MDM6600_CMD_UNDEFINED,
+};
+
+/*
+ * MDM6600 status codes. These are based on Motorola Mapphone Linux
+ * kernel tree.
+ */
+enum phy_mdm6600_status {
+ PHY_MDM6600_STATUS_PANIC, /* Seems to be really off */
+ PHY_MDM6600_STATUS_PANIC_BUSY_WAIT,
+ PHY_MDM6600_STATUS_QC_DLOAD,
+ PHY_MDM6600_STATUS_RAM_DOWNLOADER, /* MDM6600 USB flashing mode */
+ PHY_MDM6600_STATUS_PHONE_CODE_AWAKE, /* MDM6600 normal USB mode */
+ PHY_MDM6600_STATUS_PHONE_CODE_ASLEEP,
+ PHY_MDM6600_STATUS_SHUTDOWN_ACK,
+ PHY_MDM6600_STATUS_UNDEFINED,
+};
+
+static const char * const
+phy_mdm6600_status_name[] = {
+ "off", "busy", "qc_dl", "ram_dl", "awake",
+ "asleep", "shutdown", "undefined",
+};
+
+struct phy_mdm6600 {
+ struct device *dev;
+ struct phy *generic_phy;
+ struct phy_provider *phy_provider;
+ struct gpio_desc *ctrl_gpios[PHY_MDM6600_NR_CTRL_LINES];
+ struct gpio_descs *mode_gpios;
+ struct gpio_descs *status_gpios;
+ struct gpio_descs *cmd_gpios;
+ struct delayed_work bootup_work;
+ struct delayed_work status_work;
+ struct completion ack;
+ bool enabled; /* mdm6600 phy enabled */
+ bool running; /* mdm6600 boot done */
+ int status;
+};
+
+static int phy_mdm6600_init(struct phy *x)
+{
+ struct phy_mdm6600 *ddata = phy_get_drvdata(x);
+ struct gpio_desc *enable_gpio = ddata->ctrl_gpios[PHY_MDM6600_ENABLE];
+
+ if (!ddata->enabled)
+ return -EPROBE_DEFER;
+
+ gpiod_set_value_cansleep(enable_gpio, 0);
+
+ return 0;
+}
+
+static int phy_mdm6600_power_on(struct phy *x)
+{
+ struct phy_mdm6600 *ddata = phy_get_drvdata(x);
+ struct gpio_desc *enable_gpio = ddata->ctrl_gpios[PHY_MDM6600_ENABLE];
+
+ if (!ddata->enabled)
+ return -ENODEV;
+
+ gpiod_set_value_cansleep(enable_gpio, 1);
+
+ return 0;
+}
+
+static int phy_mdm6600_power_off(struct phy *x)
+{
+ struct phy_mdm6600 *ddata = phy_get_drvdata(x);
+ struct gpio_desc *enable_gpio = ddata->ctrl_gpios[PHY_MDM6600_ENABLE];
+
+ if (!ddata->enabled)
+ return -ENODEV;
+
+ gpiod_set_value_cansleep(enable_gpio, 0);
+
+ return 0;
+}
+
+static const struct phy_ops gpio_usb_ops = {
+ .init = phy_mdm6600_init,
+ .power_on = phy_mdm6600_power_on,
+ .power_off = phy_mdm6600_power_off,
+ .owner = THIS_MODULE,
+};
+
+/**
+ * phy_mdm6600_cmd() - send a command request to mdm6600
+ * @ddata: device driver data
+ *
+ * Configures the three command request GPIOs to the specified value.
+ */
+static void phy_mdm6600_cmd(struct phy_mdm6600 *ddata, int val)
+{
+ int values[PHY_MDM6600_NR_CMD_LINES];
+ int i;
+
+ val &= (1 << PHY_MDM6600_NR_CMD_LINES) - 1;
+ for (i = 0; i < PHY_MDM6600_NR_CMD_LINES; i++)
+ values[i] = (val & BIT(i)) >> i;
+
+ gpiod_set_array_value_cansleep(PHY_MDM6600_NR_CMD_LINES,
+ ddata->cmd_gpios->desc, values);
+}
+
+/**
+ * phy_mdm6600_status() - read mdm6600 status lines
+ * @ddata: device driver data
+ */
+static void phy_mdm6600_status(struct work_struct *work)
+{
+ struct phy_mdm6600 *ddata;
+ struct device *dev;
+ int values[PHY_MDM6600_NR_STATUS_LINES];
+ int error, i, val = 0;
+
+ ddata = container_of(work, struct phy_mdm6600, status_work.work);
+ dev = ddata->dev;
+
+ error = gpiod_get_array_value_cansleep(PHY_MDM6600_NR_CMD_LINES,
+ ddata->status_gpios->desc,
+ values);
+ if (error)
+ return;
+
+ for (i = 0; i < PHY_MDM6600_NR_CMD_LINES; i++) {
+ val |= values[i] << i;
+ dev_dbg(ddata->dev, "XXX %s: i: %i values[i]: %i val: %i\n",
+ __func__, i, values[i], val);
+ }
+ ddata->status = val;
+
+ dev_info(dev, "modem status: %i %s\n",
+ ddata->status,
+ phy_mdm6600_status_name[ddata->status & 7]);
+ complete(&ddata->ack);
+}
+
+static irqreturn_t phy_mdm6600_irq_thread(int irq, void *data)
+{
+ struct phy_mdm6600 *ddata = data;
+
+ schedule_delayed_work(&ddata->status_work, msecs_to_jiffies(10));
+
+ return IRQ_HANDLED;
+}
+
+/**
+ * phy_mdm6600_wakeirq_thread - handle mode1 line OOB wake after booting
+ * @irq: interrupt
+ * @data: interrupt handler data
+ *
+ * GPIO mode1 is used initially as output to configure the USB boot
+ * mode for mdm6600. After booting it is used as input for OOB wake
+ * signal from mdm6600 to the SoC. Just use it for debug info only
+ * for now.
+ */
+static irqreturn_t phy_mdm6600_wakeirq_thread(int irq, void *data)
+{
+ struct phy_mdm6600 *ddata = data;
+ struct gpio_desc *mode_gpio1;
+
+ mode_gpio1 = ddata->mode_gpios->desc[PHY_MDM6600_MODE1];
+ dev_dbg(ddata->dev, "OOB wake on mode_gpio1: %i\n",
+ gpiod_get_value(mode_gpio1));
+
+ return IRQ_HANDLED;
+}
+
+/**
+ * phy_mdm6600_init_irq() - initialize mdm6600 status IRQ lines
+ * @ddata: device driver data
+ */
+static void phy_mdm6600_init_irq(struct phy_mdm6600 *ddata)
+{
+ struct device *dev = ddata->dev;
+ int i, error, irq;
+
+ for (i = PHY_MDM6600_STATUS0;
+ i <= PHY_MDM6600_STATUS2; i++) {
+ struct gpio_desc *gpio = ddata->status_gpios->desc[i];
+
+ irq = gpiod_to_irq(gpio);
+ if (irq <= 0)
+ continue;
+
+ error = devm_request_threaded_irq(dev, irq, NULL,
+ phy_mdm6600_irq_thread,
+ IRQF_TRIGGER_RISING |
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ "mdm6600",
+ ddata);
+ if (error)
+ dev_warn(dev, "no modem status irq%i: %i\n",
+ irq, error);
+ }
+}
+
+struct phy_mdm6600_map {
+ const char *name;
+ int direction;
+};
+
+static const struct phy_mdm6600_map
+phy_mdm6600_ctrl_gpio_map[PHY_MDM6600_NR_CTRL_LINES] = {
+ { "enable", GPIOD_OUT_LOW, }, /* low = phy disabled */
+ { "power", GPIOD_OUT_LOW, }, /* low = off */
+ { "reset", GPIOD_OUT_HIGH, }, /* high = reset */
+};
+
+/**
+ * phy_mdm6600_init_lines() - initialize mdm6600 GPIO lines
+ * @ddata: device driver data
+ */
+static int phy_mdm6600_init_lines(struct phy_mdm6600 *ddata)
+{
+ struct device *dev = ddata->dev;
+ int i;
+
+ /* MDM6600 control lines */
+ for (i = 0; i < ARRAY_SIZE(phy_mdm6600_ctrl_gpio_map); i++) {
+ const struct phy_mdm6600_map *map =
+ &phy_mdm6600_ctrl_gpio_map[i];
+ struct gpio_desc **gpio = &ddata->ctrl_gpios[i];
+
+ *gpio = devm_gpiod_get(dev, map->name, map->direction);
+ if (IS_ERR(*gpio)) {
+ dev_info(dev, "gpio %s error %li\n",
+ map->name, PTR_ERR(*gpio));
+ return PTR_ERR(*gpio);
+ }
+ }
+
+ /* MDM6600 USB start-up mode output lines */
+ ddata->mode_gpios = devm_gpiod_get_array(dev, "motorola,mode",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(ddata->mode_gpios))
+ return PTR_ERR(ddata->mode_gpios);
+
+ if (ddata->mode_gpios->ndescs != PHY_MDM6600_NR_MODE_LINES)
+ return -EINVAL;
+
+ /* MDM6600 status input lines */
+ ddata->status_gpios = devm_gpiod_get_array(dev, "motorola,status",
+ GPIOD_IN);
+ if (IS_ERR(ddata->status_gpios))
+ return PTR_ERR(ddata->status_gpios);
+
+ if (ddata->status_gpios->ndescs != PHY_MDM6600_NR_STATUS_LINES)
+ return -EINVAL;
+
+ /* MDM6600 cmd output lines */
+ ddata->cmd_gpios = devm_gpiod_get_array(dev, "motorola,cmd",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(ddata->cmd_gpios))
+ return PTR_ERR(ddata->cmd_gpios);
+
+ if (ddata->cmd_gpios->ndescs != PHY_MDM6600_NR_CMD_LINES)
+ return -EINVAL;
+
+ return 0;
+}
+
+/**
+ * phy_mdm6600_device_power_on() - power on mdm6600 device
+ * @ddata: device driver data
+ *
+ * To get the integrated USB phy in MDM6600 takes some hoops. We must ensure
+ * the shared USB bootmode GPIOs are configured, then request modem start-up,
+ * reset and power-up.. And then we need to recycle the shared USB bootmode
+ * GPIOs as they are also used for Out of Band (OOB) wake for the USB and
+ * TS 27.010 serial mux.
+ */
+static int phy_mdm6600_device_power_on(struct phy_mdm6600 *ddata)
+{
+ struct gpio_desc *mode_gpio0, *mode_gpio1, *reset_gpio, *power_gpio;
+ int error = 0, wakeirq;
+
+ mode_gpio0 = ddata->mode_gpios->desc[PHY_MDM6600_MODE0];
+ mode_gpio1 = ddata->mode_gpios->desc[PHY_MDM6600_MODE1];
+ reset_gpio = ddata->ctrl_gpios[PHY_MDM6600_RESET];
+ power_gpio = ddata->ctrl_gpios[PHY_MDM6600_POWER];
+
+ /*
+ * Shared GPIOs must be low for normal USB mode. After booting
+ * they are used for OOB wake signaling. These can be also used
+ * to configure USB flashing mode later on based on a module
+ * parameter.
+ */
+ gpiod_set_value_cansleep(mode_gpio0, 0);
+ gpiod_set_value_cansleep(mode_gpio1, 0);
+
+ /* Request start-up mode */
+ phy_mdm6600_cmd(ddata, PHY_MDM6600_CMD_NO_BYPASS);
+
+ /* Request a reset first */
+ gpiod_set_value_cansleep(reset_gpio, 0);
+ msleep(100);
+
+ /* Toggle power GPIO to request mdm6600 to start */
+ gpiod_set_value_cansleep(power_gpio, 1);
+ msleep(100);
+ gpiod_set_value_cansleep(power_gpio, 0);
+
+ /*
+ * Looks like the USB PHY needs between 2.2 to 4 seconds.
+ * If we try to use it before that, we will get L3 errors
+ * from omap-usb-host trying to access the PHY. See also
+ * phy_mdm6600_init() for -EPROBE_DEFER.
+ */
+ msleep(PHY_MDM6600_PHY_DELAY_MS);
+ ddata->enabled = true;
+
+ /* Booting up the rest of MDM6600 will take total about 8 seconds */
+ dev_info(ddata->dev, "Waiting for power up request to complete..\n");
+ if (wait_for_completion_timeout(&ddata->ack,
+ msecs_to_jiffies(PHY_MDM6600_ENABLED_DELAY_MS))) {
+ if (ddata->status > PHY_MDM6600_STATUS_PANIC &&
+ ddata->status < PHY_MDM6600_STATUS_SHUTDOWN_ACK)
+ dev_info(ddata->dev, "Powered up OK\n");
+ } else {
+ ddata->enabled = false;
+ error = -ETIMEDOUT;
+ dev_err(ddata->dev, "Timed out powering up\n");
+ }
+
+ /* Reconfigure mode1 GPIO as input for OOB wake */
+ gpiod_direction_input(mode_gpio1);
+
+ wakeirq = gpiod_to_irq(mode_gpio1);
+ if (wakeirq <= 0)
+ return wakeirq;
+
+ error = devm_request_threaded_irq(ddata->dev, wakeirq, NULL,
+ phy_mdm6600_wakeirq_thread,
+ IRQF_TRIGGER_RISING |
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ "mdm6600-wake",
+ ddata);
+ if (error)
+ dev_warn(ddata->dev, "no modem wakeirq irq%i: %i\n",
+ wakeirq, error);
+
+ ddata->running = true;
+
+ return error;
+}
+
+/**
+ * phy_mdm6600_device_power_off() - power off mdm6600 device
+ * @ddata: device driver data
+ */
+static void phy_mdm6600_device_power_off(struct phy_mdm6600 *ddata)
+{
+ struct gpio_desc *reset_gpio =
+ ddata->ctrl_gpios[PHY_MDM6600_RESET];
+
+ ddata->enabled = false;
+ phy_mdm6600_cmd(ddata, PHY_MDM6600_CMD_BP_SHUTDOWN_REQ);
+ msleep(100);
+
+ gpiod_set_value_cansleep(reset_gpio, 1);
+
+ dev_info(ddata->dev, "Waiting for power down request to complete.. ");
+ if (wait_for_completion_timeout(&ddata->ack,
+ msecs_to_jiffies(5000))) {
+ if (ddata->status == PHY_MDM6600_STATUS_PANIC)
+ dev_info(ddata->dev, "Powered down OK\n");
+ } else {
+ dev_err(ddata->dev, "Timed out powering down\n");
+ }
+}
+
+static void phy_mdm6600_deferred_power_on(struct work_struct *work)
+{
+ struct phy_mdm6600 *ddata;
+ int error;
+
+ ddata = container_of(work, struct phy_mdm6600, bootup_work.work);
+
+ error = phy_mdm6600_device_power_on(ddata);
+ if (error)
+ dev_err(ddata->dev, "Device not functional\n");
+}
+
+static const struct of_device_id phy_mdm6600_id_table[] = {
+ { .compatible = "motorola,mapphone-mdm6600", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, phy_mdm6600_id_table);
+
+static int phy_mdm6600_probe(struct platform_device *pdev)
+{
+ struct phy_mdm6600 *ddata;
+ int error;
+
+ ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
+ if (!ddata)
+ return -ENOMEM;
+
+ INIT_DELAYED_WORK(&ddata->bootup_work,
+ phy_mdm6600_deferred_power_on);
+ INIT_DELAYED_WORK(&ddata->status_work, phy_mdm6600_status);
+ init_completion(&ddata->ack);
+
+ ddata->dev = &pdev->dev;
+ platform_set_drvdata(pdev, ddata);
+
+ error = phy_mdm6600_init_lines(ddata);
+ if (error)
+ return error;
+
+ phy_mdm6600_init_irq(ddata);
+
+ ddata->generic_phy = devm_phy_create(ddata->dev, NULL, &gpio_usb_ops);
+ if (IS_ERR(ddata->generic_phy)) {
+ error = PTR_ERR(ddata->generic_phy);
+ goto cleanup;
+ }
+
+ phy_set_drvdata(ddata->generic_phy, ddata);
+
+ ddata->phy_provider =
+ devm_of_phy_provider_register(ddata->dev,
+ of_phy_simple_xlate);
+ if (IS_ERR(ddata->phy_provider)) {
+ error = PTR_ERR(ddata->phy_provider);
+ goto cleanup;
+ }
+
+ schedule_delayed_work(&ddata->bootup_work, 0);
+
+ /*
+ * See phy_mdm6600_device_power_on(). We should be able
+ * to remove this eventually when ohci-platform can deal
+ * with -EPROBE_DEFER.
+ */
+ msleep(PHY_MDM6600_PHY_DELAY_MS + 500);
+
+ return 0;
+
+cleanup:
+ phy_mdm6600_device_power_off(ddata);
+ return error;
+}
+
+static int phy_mdm6600_remove(struct platform_device *pdev)
+{
+ struct phy_mdm6600 *ddata = platform_get_drvdata(pdev);
+ struct gpio_desc *reset_gpio = ddata->ctrl_gpios[PHY_MDM6600_RESET];
+
+ if (!ddata->running)
+ wait_for_completion_timeout(&ddata->ack,
+ msecs_to_jiffies(PHY_MDM6600_ENABLED_DELAY_MS));
+
+ gpiod_set_value_cansleep(reset_gpio, 1);
+ phy_mdm6600_device_power_off(ddata);
+
+ cancel_delayed_work_sync(&ddata->bootup_work);
+ cancel_delayed_work_sync(&ddata->status_work);
+
+ return 0;
+}
+
+static struct platform_driver phy_mdm6600_driver = {
+ .probe = phy_mdm6600_probe,
+ .remove = phy_mdm6600_remove,
+ .driver = {
+ .name = "phy-mapphone-mdm6600",
+ .of_match_table = of_match_ptr(phy_mdm6600_id_table),
+ },
+};
+
+module_platform_driver(phy_mdm6600_driver);
+
+MODULE_ALIAS("platform:gpio_usb");
+MODULE_AUTHOR("Tony Lindgren <[email protected]>");
+MODULE_DESCRIPTION("mdm6600 gpio usb phy driver");
+MODULE_LICENSE("GPL v2");
--
2.16.2


2018-03-09 09:45:53

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi!

> Let's add support for the GPIO controlled USB PHY on the MDM6600 modem.
> It is used on some Motorola Mapphone series of phones and tablets such
> as Droid 4.
...
> So it seems that MDM6600 is currently not yet idling even with it's
> radio turned off, but that's something that is beyond the control of
> this USB PHY driver. This patch does get us to the point where modem
> data and GPS are usable with libqmi and ModemManager for example.
> Voice calls need more audio driver work.

Thanks for the good work. Looks like I'll need to get droid
4... fortunately it is not available in czech republic so I don't get
excuse to get another toy.

Oh.. no. It is available in Czech republic. Is Motorola Droid 4 XT894
the right one? Hmm, and LTE modem is useless in Europe, while the GSM
one does not work, right?

Best regards,
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (0.99 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-09 14:54:44

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Pavel Machek <[email protected]> [180309 09:45]:
> Hi!
>
> > Let's add support for the GPIO controlled USB PHY on the MDM6600 modem.
> > It is used on some Motorola Mapphone series of phones and tablets such
> > as Droid 4.
> ...
> > So it seems that MDM6600 is currently not yet idling even with it's
> > radio turned off, but that's something that is beyond the control of
> > this USB PHY driver. This patch does get us to the point where modem
> > data and GPS are usable with libqmi and ModemManager for example.
> > Voice calls need more audio driver work.
>
> Thanks for the good work. Looks like I'll need to get droid
> 4... fortunately it is not available in czech republic so I don't get
> excuse to get another toy.
>
> Oh.. no. It is available in Czech republic. Is Motorola Droid 4 XT894
> the right one? Hmm, and LTE modem is useless in Europe, while the GSM
> one does not work, right?

Yup xt894 is the model number for droid 4.

Regards,

Tony



2018-03-22 13:58:55

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi!

> idle lcd off phy-mapphone-mdm6600 ohci-platform
> 153mW 284mW 344mW
>
> So it seems that MDM6600 is currently not yet idling even with it's
> radio turned off, but that's something that is beyond the control of
> this USB PHY driver. This patch does get us to the point where modem
> data and GPS are usable with libqmi and ModemManager for example.
> Voice calls need more audio driver work.

Ok, let me try. I believe I should see the modem device on lsusb, but
I don't.

user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
sudo lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
zcat /proc/config.gz | grep MAPPH
CONFIG_PHY_MAPPHONE_MDM6600=y
user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
zcat /proc/config.gz | grep OHCI_
CONFIG_USB_OHCI_LITTLE_ENDIAN=y
CONFIG_USB_OHCI_HCD=y
CONFIG_USB_OHCI_HCD_OMAP3=y
CONFIG_USB_OHCI_HCD_PLATFORM=y
user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$

As far as I can tell,

+CONFIG_USB_WDM=y
+CONFIG_USB_SERIAL=y
+CONFIG_USB_SERIAL_QUALCOMM=y
+CONFIG_USB_SERIAL_WWAN=y

should be enabled to enable the drivers (and I did that), but without
device showing on the bus...

Any ideas?

Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.51 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-22 16:48:02

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Pavel Machek <[email protected]> [180322 13:57]:
> Hi!
>
> > idle lcd off phy-mapphone-mdm6600 ohci-platform
> > 153mW 284mW 344mW
> >
> > So it seems that MDM6600 is currently not yet idling even with it's
> > radio turned off, but that's something that is beyond the control of
> > this USB PHY driver. This patch does get us to the point where modem
> > data and GPS are usable with libqmi and ModemManager for example.
> > Voice calls need more audio driver work.
>
> Ok, let me try. I believe I should see the modem device on lsusb, but
> I don't.
>
> user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
> sudo lsusb
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
> zcat /proc/config.gz | grep MAPPH
> CONFIG_PHY_MAPPHONE_MDM6600=y
> user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
> zcat /proc/config.gz | grep OHCI_
> CONFIG_USB_OHCI_LITTLE_ENDIAN=y
> CONFIG_USB_OHCI_HCD=y
> CONFIG_USB_OHCI_HCD_OMAP3=y
> CONFIG_USB_OHCI_HCD_PLATFORM=y
> user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
>
> As far as I can tell,
>
> +CONFIG_USB_WDM=y
> +CONFIG_USB_SERIAL=y
> +CONFIG_USB_SERIAL_QUALCOMM=y
> +CONFIG_USB_SERIAL_WWAN=y
>
> should be enabled to enable the drivers (and I did that), but without
> device showing on the bus...
>
> Any ideas?

Do you have the related dts patches picked from next?

fdd192037fce ("ARM: dts: omap4-droid4: Fix USB PHY port naming")
e5b9fd7bdeb5 ("ARM: dts: omap4-droid4: Configure MDM6600 USB PHY")

But yeah all you need to do is have phy-mapphone-mdm6600 and
ohci-platform loaded and then ifconfig should show four wwan
interfaces being added.

Regards,

Tony


Attachments:
(No filename) (1.82 kB)
signature.asc (849.00 B)
Download all attachments

2018-03-22 19:29:54

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi!

> > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
> > sudo lsusb
> > Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> > Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
> > zcat /proc/config.gz | grep MAPPH
> > CONFIG_PHY_MAPPHONE_MDM6600=y
> > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
> > zcat /proc/config.gz | grep OHCI_
> > CONFIG_USB_OHCI_LITTLE_ENDIAN=y
> > CONFIG_USB_OHCI_HCD=y
> > CONFIG_USB_OHCI_HCD_OMAP3=y
> > CONFIG_USB_OHCI_HCD_PLATFORM=y
> > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost$
> >
> > As far as I can tell,
> >
> > +CONFIG_USB_WDM=y
> > +CONFIG_USB_SERIAL=y
> > +CONFIG_USB_SERIAL_QUALCOMM=y
> > +CONFIG_USB_SERIAL_WWAN=y
> >
> > should be enabled to enable the drivers (and I did that), but without
> > device showing on the bus...
> >
> > Any ideas?
>
> Do you have the related dts patches picked from next?
>
> fdd192037fce ("ARM: dts: omap4-droid4: Fix USB PHY port naming")
> e5b9fd7bdeb5 ("ARM: dts: omap4-droid4: Configure MDM6600 USB PHY")
>
> But yeah all you need to do is have phy-mapphone-mdm6600 and
> ohci-platform loaded and then ifconfig should show four wwan
> interfaces being added.

ifconfig? I thought I should get /dev/ttyUSB0..3?

Anyway, that does not seem to work. Something is detected now:

[ 10.819549] ALSA device list:
[ 10.831787] #0: HDMI 58006000.encoder
[ 10.841186] Waiting 10 sec before mounting root device...
[ 10.887573] usb 2-1: New USB device found, idVendor=22b8,
idProduct=2a70
[ 10.897521] usb 2-1: New USB device strings: Mfr=1, Product=2,
SerialNumber=0
[ 10.907684] usb 2-1: Product: Flash MZ600
[ 10.914611] usb 2-1: Manufacturer: Motorola, Incorporated
[ 20.967193] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to
feature incompatibilities

But qcserial driver does not bind to that. If I attempt to force it:

root@devuan:/sys/bus/usb-serial/drivers/qcserial# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 22b8:2a70 Motorola PCS
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
root@devuan:/sys/bus/usb-serial/drivers/qcserial# echo "22b8 2a70" >
new_id
[ 2059.267730] usb 2-1: unknown number of interfaces: 9
[ 2059.272949] usb 2-1: unknown number of interfaces: 9
[ 2059.278045] usb 2-1: unknown number of interfaces: 9
[ 2059.283233] usb 2-1: unknown number of interfaces: 9
[ 2059.288330] usb 2-1: unknown number of interfaces: 9
[ 2059.293457] usb 2-1: unknown number of interfaces: 9
[ 2059.298553] usb 2-1: unknown number of interfaces: 9
[ 2059.303680] usb 2-1: unknown number of interfaces: 9
[ 2059.308776] usb 2-1: unknown number of interfaces: 9

I don't get anything useful. Do I need to boot android before booting
Linux or something? How does your lsusb look like?

Thanks,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (3.08 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-22 22:24:36

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

On Thu, 2018-03-22 at 20:28 +0100, Pavel Machek wrote:
> Hi!
>
> > > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost
> > > $
> > > sudo lsusb
> > > Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> > > Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> > > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost
> > > $
> > > zcat /proc/config.gz | grep MAPPH
> > > CONFIG_PHY_MAPPHONE_MDM6600=y
> > > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost
> > > $
> > > zcat /proc/config.gz | grep OHCI_
> > > CONFIG_USB_OHCI_LITTLE_ENDIAN=y
> > > CONFIG_USB_OHCI_HCD=y
> > > CONFIG_USB_OHCI_HCD_OMAP3=y
> > > CONFIG_USB_OHCI_HCD_PLATFORM=y
> > > user@devuan:/sys/devices/platform/44000000.ocp/4a064000.usbhshost
> > > $
> > >
> > > As far as I can tell,
> > >
> > > +CONFIG_USB_WDM=y
> > > +CONFIG_USB_SERIAL=y
> > > +CONFIG_USB_SERIAL_QUALCOMM=y
> > > +CONFIG_USB_SERIAL_WWAN=y
> > >
> > > should be enabled to enable the drivers (and I did that), but
> > > without
> > > device showing on the bus...
> > >
> > > Any ideas?
> >
> > Do you have the related dts patches picked from next?
> >
> > fdd192037fce ("ARM: dts: omap4-droid4: Fix USB PHY port naming")
> > e5b9fd7bdeb5 ("ARM: dts: omap4-droid4: Configure MDM6600 USB PHY")
> >
> > But yeah all you need to do is have phy-mapphone-mdm6600 and
> > ohci-platform loaded and then ifconfig should show four wwan
> > interfaces being added.
>
> ifconfig? I thought I should get /dev/ttyUSB0..3?

I believe they are QMI via qmi_wwan, not TTYs.

Dan

> Anyway, that does not seem to work. Something is detected now:
>
> [ 10.819549] ALSA device list:
> [ 10.831787] #0: HDMI 58006000.encoder
> [ 10.841186] Waiting 10 sec before mounting root device...
> [ 10.887573] usb 2-1: New USB device found, idVendor=22b8,
> idProduct=2a70
> [ 10.897521] usb 2-1: New USB device strings: Mfr=1, Product=2,
> SerialNumber=0
> [ 10.907684] usb 2-1: Product: Flash MZ600
> [ 10.914611] usb 2-1: Manufacturer: Motorola, Incorporated
> [ 20.967193] EXT4-fs (mmcblk0p2): couldn't mount as ext3 due to
> feature incompatibilities
>
> But qcserial driver does not bind to that. If I attempt to force it:
>
> root@devuan:/sys/bus/usb-serial/drivers/qcserial# lsusb
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 002 Device 002: ID 22b8:2a70 Motorola PCS
> Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> root@devuan:/sys/bus/usb-serial/drivers/qcserial# echo "22b8 2a70" >
> new_id
> [ 2059.267730] usb 2-1: unknown number of interfaces: 9
> [ 2059.272949] usb 2-1: unknown number of interfaces: 9
> [ 2059.278045] usb 2-1: unknown number of interfaces: 9
> [ 2059.283233] usb 2-1: unknown number of interfaces: 9
> [ 2059.288330] usb 2-1: unknown number of interfaces: 9
> [ 2059.293457] usb 2-1: unknown number of interfaces: 9
> [ 2059.298553] usb 2-1: unknown number of interfaces: 9
> [ 2059.303680] usb 2-1: unknown number of interfaces: 9
> [ 2059.308776] usb 2-1: unknown number of interfaces: 9
>
> I don't get anything useful. Do I need to boot android before booting
> Linux or something? How does your lsusb look like?
>
> Thanks,
> Pavel

2018-03-23 10:57:17

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi!

> > > Do you have the related dts patches picked from next?
> > >
> > > fdd192037fce ("ARM: dts: omap4-droid4: Fix USB PHY port naming")
> > > e5b9fd7bdeb5 ("ARM: dts: omap4-droid4: Configure MDM6600 USB PHY")
> > >
> > > But yeah all you need to do is have phy-mapphone-mdm6600 and
> > > ohci-platform loaded and then ifconfig should show four wwan
> > > interfaces being added.
> >
> > ifconfig? I thought I should get /dev/ttyUSB0..3?
>
> I believe they are QMI via qmi_wwan, not TTYs.

Well, qmicli expects device path... and I see nothing on ifconfig. Any
idea how the device would be named?

But I believe it just does not work, see the qcserial experiment with
new_id below.

Best regards,
Pavel

> > But qcserial driver does not bind to that. If I attempt to force it:
> >
> > root@devuan:/sys/bus/usb-serial/drivers/qcserial# lsusb
> > Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> > Bus 002 Device 002: ID 22b8:2a70 Motorola PCS
> > Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> > root@devuan:/sys/bus/usb-serial/drivers/qcserial# echo "22b8 2a70" >
> > new_id
> > [ 2059.267730] usb 2-1: unknown number of interfaces: 9
> > [ 2059.272949] usb 2-1: unknown number of interfaces: 9
> > [ 2059.278045] usb 2-1: unknown number of interfaces: 9
> > [ 2059.283233] usb 2-1: unknown number of interfaces: 9
> > [ 2059.288330] usb 2-1: unknown number of interfaces: 9
> > [ 2059.293457] usb 2-1: unknown number of interfaces: 9
> > [ 2059.298553] usb 2-1: unknown number of interfaces: 9
> > [ 2059.303680] usb 2-1: unknown number of interfaces: 9
> > [ 2059.308776] usb 2-1: unknown number of interfaces: 9
> >
> > I don't get anything useful. Do I need to boot android before booting
> > Linux or something? How does your lsusb look like?
> >
> > Thanks,
> > Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.98 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-23 11:36:31

by Sebastian Reichel

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi,

On Fri, Mar 23, 2018 at 11:54:55AM +0100, Pavel Machek wrote:
> Hi!
>
> > > > Do you have the related dts patches picked from next?
> > > >
> > > > fdd192037fce ("ARM: dts: omap4-droid4: Fix USB PHY port naming")
> > > > e5b9fd7bdeb5 ("ARM: dts: omap4-droid4: Configure MDM6600 USB PHY")
> > > >
> > > > But yeah all you need to do is have phy-mapphone-mdm6600 and
> > > > ohci-platform loaded and then ifconfig should show four wwan
> > > > interfaces being added.
> > >
> > > ifconfig? I thought I should get /dev/ttyUSB0..3?
> >
> > I believe they are QMI via qmi_wwan, not TTYs.
>
> Well, qmicli expects device path... and I see nothing on ifconfig. Any
> idea how the device would be named?
>
> But I believe it just does not work, see the qcserial experiment with
> new_id below.

Dan is right, you need qmi_wwan driver. qmicli expects
/dev/cdc-wdm<num> device. I use this on Droid 4:

qmicli -d /dev/cdc-wdm0 --some-other-option

-- Sebastian

>
> Best regards,
> Pavel
>
> > > But qcserial driver does not bind to that. If I attempt to force it:
> > >
> > > root@devuan:/sys/bus/usb-serial/drivers/qcserial# lsusb
> > > Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> > > Bus 002 Device 002: ID 22b8:2a70 Motorola PCS
> > > Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> > > root@devuan:/sys/bus/usb-serial/drivers/qcserial# echo "22b8 2a70" >
> > > new_id
> > > [ 2059.267730] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.272949] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.278045] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.283233] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.288330] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.293457] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.298553] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.303680] usb 2-1: unknown number of interfaces: 9
> > > [ 2059.308776] usb 2-1: unknown number of interfaces: 9
> > >
> > > I don't get anything useful. Do I need to boot android before booting
> > > Linux or something? How does your lsusb look like?
> > >
> > > Thanks,
> > > Pavel
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html



Attachments:
(No filename) (2.33 kB)
signature.asc (849.00 B)
Download all attachments

2018-03-23 20:15:35

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

On Fri 2018-03-23 12:35:21, Sebastian Reichel wrote:
> Hi,
>
> On Fri, Mar 23, 2018 at 11:54:55AM +0100, Pavel Machek wrote:
> > Hi!
> >
> > > > > Do you have the related dts patches picked from next?
> > > > >
> > > > > fdd192037fce ("ARM: dts: omap4-droid4: Fix USB PHY port naming")
> > > > > e5b9fd7bdeb5 ("ARM: dts: omap4-droid4: Configure MDM6600 USB PHY")
> > > > >
> > > > > But yeah all you need to do is have phy-mapphone-mdm6600 and
> > > > > ohci-platform loaded and then ifconfig should show four wwan
> > > > > interfaces being added.
> > > >
> > > > ifconfig? I thought I should get /dev/ttyUSB0..3?
> > >
> > > I believe they are QMI via qmi_wwan, not TTYs.
> >
> > Well, qmicli expects device path... and I see nothing on ifconfig. Any
> > idea how the device would be named?
> >
> > But I believe it just does not work, see the qcserial experiment with
> > new_id below.
>
> Dan is right, you need qmi_wwan driver. qmicli expects
> /dev/cdc-wdm<num> device. I use this on Droid 4:
>
> qmicli -d /dev/cdc-wdm0 --some-other-option

Aha, there's ./drivers/usb/serial/usb_wwan.c and there's
./drivers/net/usb/qmi_wwan.o . That confused me.

qmicli now works for me, thanks!

Tested-by: Pavel Machek <[email protected]>

Does ofonod work for you? I could not get that one to work...

ofonod[4083]: plugins/udevng.c:create_modem()
/sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/usb2/2-1
ofonod[4083]: plugins/udevng.c:create_modem() driver=gobi
ofonod[4083]: src/modem.c:ofono_modem_create() name: (null), type:
gobi
ofonod[4083]: plugins/udevng.c:setup_gobi()
/sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/usb2/2-1
ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm0 255/251/255
05 (null) (null) usbmisc
ofonod[4083]: plugins/udevng.c:setup_gobi() wwan0 255/251/255 05
(null) (null) net
ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm1 255/251/255
06 (null) (null) usbmisc
ofonod[4083]: plugins/udevng.c:setup_gobi() wwan1 255/251/255 06
(null) (null) net
ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm2 255/251/255
07 (null) (null) usbmisc
ofonod[4083]: plugins/udevng.c:setup_gobi() wwan2 255/251/255 07
(null) (null) net
ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm3 255/251/255
08 (null) (null) usbmisc
ofonod[4083]: plugins/udevng.c:setup_gobi() wwan3 255/251/255 08
(null) (null) net
ofonod[4083]: plugins/udevng.c:destroy_modem()
/sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/usb2/2-1
ofonod[4083]: src/modem.c:ofono_modem_remove() 0x5eb380
ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm0
ofonod[4083]: plugins/udevng.c:destroy_modem() wwan0
ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm1
ofonod[4083]: plugins/udevng.c:destroy_modem() wwan1
ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm2
ofonod[4083]: plugins/udevng.c:destroy_modem() wwan2
ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm3
ofonod[4083]: plugins/udevng.c:destroy_modem() wwan3
ofonod[4083]: plugins/upower.c:upower_connect() upower connect
ofonod[4083]: plugins/hfp_hf_bluez5.c:connect_handler() Registering
External Profile handler ...

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (3.34 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-24 14:00:42

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

On Fri, 2018-03-23 at 21:13 +0100, Pavel Machek wrote:
> On Fri 2018-03-23 12:35:21, Sebastian Reichel wrote:
> > Hi,
> >
> > On Fri, Mar 23, 2018 at 11:54:55AM +0100, Pavel Machek wrote:
> > > Hi!
> > >
> > > > > > Do you have the related dts patches picked from next?
> > > > > >
> > > > > > fdd192037fce ("ARM: dts: omap4-droid4: Fix USB PHY port
> > > > > > naming")
> > > > > > e5b9fd7bdeb5 ("ARM: dts: omap4-droid4: Configure MDM6600
> > > > > > USB PHY")
> > > > > >
> > > > > > But yeah all you need to do is have phy-mapphone-mdm6600
> > > > > > and
> > > > > > ohci-platform loaded and then ifconfig should show four
> > > > > > wwan
> > > > > > interfaces being added.
> > > > >
> > > > > ifconfig? I thought I should get /dev/ttyUSB0..3?
> > > >
> > > > I believe they are QMI via qmi_wwan, not TTYs.
> > >
> > > Well, qmicli expects device path... and I see nothing on
> > > ifconfig. Any
> > > idea how the device would be named?
> > >
> > > But I believe it just does not work, see the qcserial experiment
> > > with
> > > new_id below.
> >
> > Dan is right, you need qmi_wwan driver. qmicli expects
> > /dev/cdc-wdm<num> device. I use this on Droid 4:
> >
> > qmicli -d /dev/cdc-wdm0 --some-other-option
>
> Aha, there's ./drivers/usb/serial/usb_wwan.c and there's
> ./drivers/net/usb/qmi_wwan.o . That confused me.
>
> qmicli now works for me, thanks!
>
> Tested-by: Pavel Machek <[email protected]>
>
> Does ofonod work for you? I could not get that one to work...

Because it's looking for a Gobi modem but the MDM6600 isn't one and
doesn't expose that layout (and doesn't really need to anyway). I
don't think ofono has a generic QMI driver, so you'd either need to for
ce it to use the telitqmi or quectelqmi drivers, or write your own
generic QMI one.

Dan

> ofonod[4083]: plugins/udevng.c:create_modem()
> /sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/u
> sb2/2-1
> ofonod[4083]: plugins/udevng.c:create_modem() driver=gobi
> ofonod[4083]: src/modem.c:ofono_modem_create() name: (null), type:
> gobi
> ofonod[4083]: plugins/udevng.c:setup_gobi()
> /sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/u
> sb2/2-1
> ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm0 255/251/255
> 05 (null) (null) usbmisc
> ofonod[4083]: plugins/udevng.c:setup_gobi() wwan0 255/251/255 05
> (null) (null) net
> ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm1 255/251/255
> 06 (null) (null) usbmisc
> ofonod[4083]: plugins/udevng.c:setup_gobi() wwan1 255/251/255 06
> (null) (null) net
> ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm2 255/251/255
> 07 (null) (null) usbmisc
> ofonod[4083]: plugins/udevng.c:setup_gobi() wwan2 255/251/255 07
> (null) (null) net
> ofonod[4083]: plugins/udevng.c:setup_gobi() /dev/cdc-wdm3 255/251/255
> 08 (null) (null) usbmisc
> ofonod[4083]: plugins/udevng.c:setup_gobi() wwan3 255/251/255 08
> (null) (null) net
> ofonod[4083]: plugins/udevng.c:destroy_modem()
> /sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/u
> sb2/2-1
> ofonod[4083]: src/modem.c:ofono_modem_remove() 0x5eb380
> ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm0
> ofonod[4083]: plugins/udevng.c:destroy_modem() wwan0
> ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm1
> ofonod[4083]: plugins/udevng.c:destroy_modem() wwan1
> ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm2
> ofonod[4083]: plugins/udevng.c:destroy_modem() wwan2
> ofonod[4083]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm3
> ofonod[4083]: plugins/udevng.c:destroy_modem() wwan3
> ofonod[4083]: plugins/upower.c:upower_connect() upower connect
> ofonod[4083]: plugins/hfp_hf_bluez5.c:connect_handler() Registering
> External Profile handler ...
>
>
> Pavel

2018-03-24 14:26:37

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Dan Williams <[email protected]> [180324 14:00]:
> On Fri, 2018-03-23 at 21:13 +0100, Pavel Machek wrote:
> > Does ofonod work for you? I could not get that one to work...
>
> Because it's looking for a Gobi modem but the MDM6600 isn't one and
> doesn't expose that layout (and doesn't really need to anyway). I
> don't think ofono has a generic QMI driver, so you'd either need to for
> ce it to use the telitqmi or quectelqmi drivers, or write your own
> generic QMI one.

We also get five USB uarts if we add the device id with something
like the patch below. I don't quite get why we get five UARTS?

Also not sure if we should be using drivers/usb/serial/qcaux.c
instead of qcserial.c?

And from what I recall trying it out, adding the USB UARTs
somehow confused ModemManager I think, that needs to be retested
though :)

And the USB UARTs added do not offer the same set of AT commands
as the n_gsm serial mux.

Regards,

Tony

8< ------------------
diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
--- a/drivers/usb/serial/qcserial.c
+++ b/drivers/usb/serial/qcserial.c
@@ -181,6 +181,9 @@ static const struct usb_device_id id_table[] = {
/* Huawei devices */
{DEVICE_HWI(0x03f0, 0x581d)}, /* HP lt4112 LTE/HSPA+ Gobi 4G Modem (Huawei me906e) */

+ /* Motorola devices */
+ {DEVICE_HWI(0x22b8, 0x2a70)}, /* Droid 4 mdm6600 */
+
{ } /* Terminating entry */
};
MODULE_DEVICE_TABLE(usb, id_table);
--
2.16.2

2018-03-24 20:03:38

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

On Sat 2018-03-24 07:25:17, Tony Lindgren wrote:
> * Dan Williams <[email protected]> [180324 14:00]:
> > On Fri, 2018-03-23 at 21:13 +0100, Pavel Machek wrote:
> > > Does ofonod work for you? I could not get that one to work...
> >
> > Because it's looking for a Gobi modem but the MDM6600 isn't one and
> > doesn't expose that layout (and doesn't really need to anyway). I
> > don't think ofono has a generic QMI driver, so you'd either need to for
> > ce it to use the telitqmi or quectelqmi drivers, or write your own
> > generic QMI one.
>
> We also get five USB uarts if we add the device id with something
> like the patch below. I don't quite get why we get five UARTS?

Not sure, either. Often more than one uart is useful, you get AT
commands on one, while GPRS data flow on some other.

> Also not sure if we should be using drivers/usb/serial/qcaux.c
> instead of qcserial.c?
>
> And from what I recall trying it out, adding the USB UARTs
> somehow confused ModemManager I think, that needs to be retested
> though :)
>
> And the USB UARTs added do not offer the same set of AT commands
> as the n_gsm serial mux.

Hmm. Interesting. Anyway, for me ttyUSB4 is interesting, as it seems
to react to AT commands, and in particular reacts to ADT123; (; is
important).

AT+CMGF=1
AT+CMGS="123"
foo^Z

Works for SMS sending. Good.

(And... Thanks!)

Now, if someone knows what needs to be done to get GSM audio working,
let me know. That's something I'd really like.

Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.65 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-25 15:46:29

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Pavel Machek <[email protected]> [180324 20:03]:
> On Sat 2018-03-24 07:25:17, Tony Lindgren wrote:
> > * Dan Williams <[email protected]> [180324 14:00]:
> > > On Fri, 2018-03-23 at 21:13 +0100, Pavel Machek wrote:
> > > > Does ofonod work for you? I could not get that one to work...
> > >
> > > Because it's looking for a Gobi modem but the MDM6600 isn't one and
> > > doesn't expose that layout (and doesn't really need to anyway). I
> > > don't think ofono has a generic QMI driver, so you'd either need to for
> > > ce it to use the telitqmi or quectelqmi drivers, or write your own
> > > generic QMI one.
> >
> > We also get five USB uarts if we add the device id with something
> > like the patch below. I don't quite get why we get five UARTS?
>
> Not sure, either. Often more than one uart is useful, you get AT
> commands on one, while GPRS data flow on some other.
>
> > Also not sure if we should be using drivers/usb/serial/qcaux.c
> > instead of qcserial.c?
> >
> > And from what I recall trying it out, adding the USB UARTs
> > somehow confused ModemManager I think, that needs to be retested
> > though :)
> >
> > And the USB UARTs added do not offer the same set of AT commands
> > as the n_gsm serial mux.
>
> Hmm. Interesting. Anyway, for me ttyUSB4 is interesting, as it seems
> to react to AT commands, and in particular reacts to ADT123; (; is
> important).

Is that to dial a voice call?

> AT+CMGF=1
> AT+CMGS="123"
> foo^Z
>
> Works for SMS sending. Good.

So what do you use for reading notifying and reading sms?

> Now, if someone knows what needs to be done to get GSM audio working,
> let me know. That's something I'd really like.

I think it's the cpcap based config to route voice call audio
to SoC, Sebastian knows the details :)

The way to figure that one out is to dump the cpcap registers
before and during voice call on android with cpcaprw, then
diff the output for the audio registers. Probably some SoC
registers need to be diffed too with rwmem or similar tool
for the mcbsp instance(s) used.

Regards,

Tony


2018-03-25 19:00:52

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi!

> > Hmm. Interesting. Anyway, for me ttyUSB4 is interesting, as it seems
> > to react to AT commands, and in particular reacts to ADT123; (; is
> > important).
>
> Is that to dial a voice call?

Yes. And it is ATD123; not ATD.

> > AT+CMGF=1
> > AT+CMGS="123"
> > foo^Z
> >
> > Works for SMS sending. Good.
>
> So what do you use for reading notifying and reading sms?

Well, did not try that, but they should just be displayed in the
serial terminal.

Anyway, "good" solution is to get ofonod running, then use ofone from
here: https://github.com/pavelmachek/unicsy_demo

But parsing AT commands is easy enough that I can probably hack it
together in few days if neccessary.

> > Now, if someone knows what needs to be done to get GSM audio working,
> > let me know. That's something I'd really like.
>
> I think it's the cpcap based config to route voice call audio
> to SoC, Sebastian knows the details :)
>
> The way to figure that one out is to dump the cpcap registers
> before and during voice call on android with cpcaprw, then
> diff the output for the audio registers. Probably some SoC
> registers need to be diffed too with rwmem or similar tool
> for the mcbsp instance(s) used.

That sounds like hard way to do it. There's source available, I'm now
trying to understand it / fit it into Sebastian's driver.

https://raw.githubusercontent.com/NotKit/android_kernel_motorola_omap4-common/hybris-11.0/sound/soc/codecs/cpcap.c

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.61 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-25 20:53:53

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Pavel Machek <[email protected]> [180325 19:00]:
> Hi!
>
> > > Hmm. Interesting. Anyway, for me ttyUSB4 is interesting, as it seems
> > > to react to AT commands, and in particular reacts to ADT123; (; is
> > > important).
> >
> > Is that to dial a voice call?
>
> Yes. And it is ATD123; not ATD.

Strange, no semicolon is needed when using /dev/gsmtty to
dial a voice call with my current pile of pending changes,
just doing ATD123 dials..

Anyways, looks like qmi_wwan needs to be loaded before
qcserial module, otherwise we get nine ttyUSB instances
and ModemManager can't find any modems.

With qcserial module loaded after qmi_wwan, it still takes
a long time for ModemManager to find the modem.

Then unrelated to the qcserial module, also looks like I can
no longer use the GPS with ModemManager:

$ mmcli -m 0 --enable
$ mmcli -m 0 --location-enable-gps-raw

And then chmod a+r /dev/cdc-wdm0 and pointing gpsd to use
/dev/cdc-wdm0 used to work, but now it seems that gpsd
can no longer read it. Trying to start gpsd manually produces:

# gpsd -b -n -N /dev/cdc-wdm0
gpsd:ERROR: SER: /dev/cdc-wdm0 already opened by another process
gpsd:ERROR: initial GPS device /dev/cdc-wdm0 open failed
gpsd:ERROR: can't run with neither control socket nor devices open

And lsof shows /usr/libexec/qmi-proxy having it open.

Anybody know what I might be doing wrong? Sounds like something
now needs to be done with qmi-proxy to get access to GPS?

> > Anyway, "good" solution is to get ofonod running, then use ofone from
> > here: https://github.com/pavelmachek/unicsy_demo

Thanks I'll take a look.

> > I think it's the cpcap based config to route voice call audio
> > to SoC, Sebastian knows the details :)
> >
> > The way to figure that one out is to dump the cpcap registers
> > before and during voice call on android with cpcaprw, then
> > diff the output for the audio registers. Probably some SoC
> > registers need to be diffed too with rwmem or similar tool
> > for the mcbsp instance(s) used.
>
> That sounds like hard way to do it. There's source available, I'm now
> trying to understand it / fit it into Sebastian's driver.
>
> https://raw.githubusercontent.com/NotKit/android_kernel_motorola_omap4-common/hybris-11.0/sound/soc/codecs/cpcap.c

Sure that hopefully helps too :)

Tony

2018-03-25 22:57:18

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi!

> > > > Hmm. Interesting. Anyway, for me ttyUSB4 is interesting, as it seems
> > > > to react to AT commands, and in particular reacts to ADT123; (; is
> > > > important).
> > >
> > > Is that to dial a voice call?
> >
> > Yes. And it is ATD123; not ATD.
>
> Strange, no semicolon is needed when using /dev/gsmtty to
> dial a voice call with my current pile of pending changes,
> just doing ATD123 dials..

Interesting. Maybe I made some mistake in experiment.

> Anyways, looks like qmi_wwan needs to be loaded before
> qcserial module, otherwise we get nine ttyUSB instances
> and ModemManager can't find any modems.
>
> With qcserial module loaded after qmi_wwan, it still takes
> a long time for ModemManager to find the modem.
>
> Then unrelated to the qcserial module, also looks like I can
> no longer use the GPS with ModemManager:
>
> $ mmcli -m 0 --enable
> $ mmcli -m 0 --location-enable-gps-raw
>
> And then chmod a+r /dev/cdc-wdm0 and pointing gpsd to use
> /dev/cdc-wdm0 used to work, but now it seems that gpsd
> can no longer read it. Trying to start gpsd manually produces:

Thanks for hints, it would not be bad to get gps working. But .. voice
calls. Those are important :-).

> # gpsd -b -n -N /dev/cdc-wdm0
> gpsd:ERROR: SER: /dev/cdc-wdm0 already opened by another process
> gpsd:ERROR: initial GPS device /dev/cdc-wdm0 open failed
> gpsd:ERROR: can't run with neither control socket nor devices open
>
> And lsof shows /usr/libexec/qmi-proxy having it open.
>
> Anybody know what I might be doing wrong? Sounds like something
> now needs to be done with qmi-proxy to get access to GPS?

Maybe kill the proxy and then look at cdc-wdm0 by hand? NMEA can be
parsed by hand... quite easily.

Good night,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (1.90 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments

2018-03-26 00:25:02

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Pavel Machek <[email protected]> [180325 22:57]:
> Hi!
>
> > > > > Hmm. Interesting. Anyway, for me ttyUSB4 is interesting, as it seems
> > > > > to react to AT commands, and in particular reacts to ADT123; (; is
> > > > > important).
> > > >
> > > > Is that to dial a voice call?
> > >
> > > Yes. And it is ATD123; not ATD.
> >
> > Strange, no semicolon is needed when using /dev/gsmtty to
> > dial a voice call with my current pile of pending changes,
> > just doing ATD123 dials..
>
> Interesting. Maybe I made some mistake in experiment.

Looks like on /dev/ttyUSB4 doing AT+COPS? or AT+CREG? won't work
while on /dev/gsmtty1 they work. So /dev/ttyUSB4 seems to a subset of
what's available over n_gsm on ch1. Anyways, good to hear that
/dev/ttyUSB4 can be used to debug voice calls :)

> Thanks for hints, it would not be bad to get gps working. But .. voice
> calls. Those are important :-).

Yup, please keep us posted :) Meanwhile, I'll slowly continue
getting the n_gsm stuff working.

Tony

2018-03-26 00:31:42

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Tony Lindgren <[email protected]> [180326 00:24]:
> Looks like on /dev/ttyUSB4 doing AT+COPS? or AT+CREG? won't work
> while on /dev/gsmtty1 they work. So /dev/ttyUSB4 seems to a subset of
> what's available over n_gsm on ch1. Anyways, good to hear that
> /dev/ttyUSB4 can be used to debug voice calls :)

Hmm and now they work on /dev/ttyUSB4. Maybe I had SIM card
poorly connected..

Tony

2018-03-26 15:18:17

by Dan Williams

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

On Sun, 2018-03-25 at 13:52 -0700, Tony Lindgren wrote:
> * Pavel Machek <[email protected]> [180325 19:00]:
> > Hi!
> >
> > > > Hmm. Interesting. Anyway, for me ttyUSB4 is interesting, as it
> > > > seems
> > > > to react to AT commands, and in particular reacts to ADT123; (;
> > > > is
> > > > important).
> > >
> > > Is that to dial a voice call?
> >
> > Yes. And it is ATD123; not ATD.
>
> Strange, no semicolon is needed when using /dev/gsmtty to
> dial a voice call with my current pile of pending changes,
> just doing ATD123 dials..
>
> Anyways, looks like qmi_wwan needs to be loaded before
> qcserial module, otherwise we get nine ttyUSB instances
> and ModemManager can't find any modems.

Use qcaux.c or option, unless the 6600 actually *does* have the same
layout as Gobi 1K/2K/etc devices.

If you're going to use qcaux or optoin, then you need to use some
variant of USB_DEVICE_AND_INTERFACE_INFO to lock the serial driver to
the specific USB interfaces that expose the TTYs and to ignore the QMI
interfaces and netdevs.

Dan

> With qcserial module loaded after qmi_wwan, it still takes
> a long time for ModemManager to find the modem.
>
> Then unrelated to the qcserial module, also looks like I can
> no longer use the GPS with ModemManager:
>
> $ mmcli -m 0 --enable
> $ mmcli -m 0 --location-enable-gps-raw
>
> And then chmod a+r /dev/cdc-wdm0 and pointing gpsd to use
> /dev/cdc-wdm0 used to work, but now it seems that gpsd
> can no longer read it. Trying to start gpsd manually produces:
>
> # gpsd -b -n -N /dev/cdc-wdm0
> gpsd:ERROR: SER: /dev/cdc-wdm0 already opened by another process
> gpsd:ERROR: initial GPS device /dev/cdc-wdm0 open failed
> gpsd:ERROR: can't run with neither control socket nor devices open
>
> And lsof shows /usr/libexec/qmi-proxy having it open.
>
> Anybody know what I might be doing wrong? Sounds like something
> now needs to be done with qmi-proxy to get access to GPS?
>
> > > Anyway, "good" solution is to get ofonod running, then use ofone
> > > from
> > > here: https://github.com/pavelmachek/unicsy_demo
>
> Thanks I'll take a look.
>
> > > I think it's the cpcap based config to route voice call audio
> > > to SoC, Sebastian knows the details :)
> > >
> > > The way to figure that one out is to dump the cpcap registers
> > > before and during voice call on android with cpcaprw, then
> > > diff the output for the audio registers. Probably some SoC
> > > registers need to be diffed too with rwmem or similar tool
> > > for the mcbsp instance(s) used.
> >
> > That sounds like hard way to do it. There's source available, I'm
> > now
> > trying to understand it / fit it into Sebastian's driver.
> >
> > https://raw.githubusercontent.com/NotKit/android_kernel_motorola_om
> > ap4-common/hybris-11.0/sound/soc/codecs/cpcap.c
>
> Sure that hopefully helps too :)
>
> Tony
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb"
> in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2018-03-27 00:46:48

by Tony Lindgren

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

* Dan Williams <[email protected]> [180326 15:18]:
> On Sun, 2018-03-25 at 13:52 -0700, Tony Lindgren wrote:
> > Anyways, looks like qmi_wwan needs to be loaded before
> > qcserial module, otherwise we get nine ttyUSB instances
> > and ModemManager can't find any modems.
>
> Use qcaux.c or option, unless the 6600 actually *does* have the same
> layout as Gobi 1K/2K/etc devices.

OK yeah I don't think it's Gobi.

> If you're going to use qcaux or optoin, then you need to use some
> variant of USB_DEVICE_AND_INTERFACE_INFO to lock the serial driver to
> the specific USB interfaces that expose the TTYs and to ignore the QMI
> interfaces and netdevs.

OK thanks I'll take a look and post a patch after some testing.

Regards,

Tony

2018-03-29 19:45:42

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCHv4] phy: mapphone-mdm6600: Add USB PHY driver for MDM6600 on Droid 4

Hi!

> > Does ofonod work for you? I could not get that one to work...
>
> Because it's looking for a Gobi modem but the MDM6600 isn't one and
> doesn't expose that layout (and doesn't really need to anyway). I
> don't think ofono has a generic QMI driver, so you'd either need to for
> ce it to use the telitqmi or quectelqmi drivers, or write your own
> generic QMI one.

You are right, it is detected as gobi now:

user@devuan:/my/ofono$ sudo python2 test/list-modems
[ /gobi_0 ]
SystemPath =
/sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/usb2/2-1
Features =
Emergency = 0
Powered = 0
Lockdown = 0
Interfaces =
Online = 0
Type = hardware

...and nothing works.

commit db9b292f9290b97c87a8d4b4836af4763c06a39c
Author: Bassem Boubaker <[email protected]>
Date: Mon Mar 19 17:57:31 2018 +0100

I tried this:

diff --git a/plugins/udevng.c b/plugins/udevng.c
index ff5d41af..6b103254 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -1578,8 +1578,6 @@ static struct {
{ "mbm", "cdc_ether", "0930" },
{ "mbm", "cdc_ncm", "0930" },
{ "hso", "hso" },
- { "gobi", "qmi_wwan" },
- { "gobi", "qcserial" },
{ "sierra", "qmi_wwan", "1199" },
{ "sierra", "qcserial", "1199" },
{ "sierra", "sierra" },
@@ -1602,6 +1600,8 @@ static struct {
{ "telit", "cdc_acm", "1bc7", "0021" },
{ "telitqmi", "qmi_wwan", "1bc7", "1201" },
{ "telitqmi", "option", "1bc7", "1201" },
+ { "telitqmi", "qmi_wwan", "22b8", "2a70" },
+ { "telitqmi", "option", "22b8", "2a70" },
{ "nokia", "option", "0421", "060e" },
{ "nokia", "option", "0421", "0623" },
{ "samsung", "option", "04e8", "6889" },

But no luck:

ofonod[15879]: plugins/udevng.c:create_modem()
/sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/usb2/2-1
ofonod[15879]: plugins/udevng.c:create_modem() driver=telitqmi
ofonod[15879]: src/modem.c:ofono_modem_create() name: (null), type:
telitqmi
ofonod[15879]: plugins/udevng.c:setup_telitqmi()
/sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/usb2/2-1
ofonod[15879]: plugins/udevng.c:setup_telitqmi() /dev/cdc-wdm0
255/251/255 05 (null) usbmisc
ofonod[15879]: plugins/udevng.c:setup_telitqmi() wwan0 255/251/255 05
(null) net
ofonod[15879]: plugins/udevng.c:setup_telitqmi() /dev/cdc-wdm1
255/251/255 06 (null) usbmisc
ofonod[15879]: plugins/udevng.c:setup_telitqmi() wwan1 255/251/255 06
(null) net
ofonod[15879]: plugins/udevng.c:setup_telitqmi() /dev/cdc-wdm2
255/251/255 07 (null) usbmisc
ofonod[15879]: plugins/udevng.c:setup_telitqmi() wwan2 255/251/255 07
(null) net
ofonod[15879]: plugins/udevng.c:setup_telitqmi() /dev/cdc-wdm3
255/251/255 08 (null) usbmisc
ofonod[15879]: plugins/udevng.c:setup_telitqmi() wwan3 255/251/255 08
(null) net
ofonod[15879]: plugins/udevng.c:destroy_modem()
/sys/devices/platform/44000000.ocp/4a064000.usbhshost/4a064800.ohci/usb2/2-1
ofonod[15879]: src/modem.c:ofono_modem_remove() 0x596480
ofonod[15879]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm0
ofonod[15879]: plugins/udevng.c:destroy_modem() wwan0
ofonod[15879]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm1
ofonod[15879]: plugins/udevng.c:destroy_modem() wwan1
ofonod[15879]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm2
ofonod[15879]: plugins/udevng.c:destroy_modem() wwan2
ofonod[15879]: plugins/udevng.c:destroy_modem() /dev/cdc-wdm3
ofonod[15879]: plugins/udevng.c:destroy_modem() wwan3
ofonod[15879]: plugins/upower.c:upower_connect() upower connect
ofonod[15879]: plugins/hfp_hf_bluez5.c:connect_handler() Registering
External Profile handler ...

With quectelqmi result was similar.

I know there are AT commands available at /dev/ttyUSB4. Is there easy
way to make ofonod connect to that?

Thanks,
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


Attachments:
(No filename) (3.88 kB)
signature.asc (188.00 B)
Digital signature
Download all attachments