linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
@ 2018-12-17  0:44 Tony Lindgren
  2018-12-18 12:46 ` Pavel Machek
                   ` (3 more replies)
  0 siblings, 4 replies; 25+ messages in thread
From: Tony Lindgren @ 2018-12-17  0:44 UTC (permalink / raw)
  To: linux-kernel, linux-arm-kernel, linux-omap
  Cc: Jarkko Nikula, Johan Hovold, Kuninori Morimoto, Marcel Partap,
	Merlijn Wajer, Michael Scott, NeKit, omerlle, Pavel Machek,
	Sebastian Reichel, Peter Ujfalusi, Rob Herring

Hi all,

So the little elves have been slowly working to get voice calls
working on droid 4 with the mainline kernel. And just in time for the
upcoming holidays, it might be possible to call friends and relatives.

I've pushed out an experimental branch containing serdev ts 27.010
UART multiplexing support. That contains a serdev core driver for the
mdm6600 modem (that also now idles the modem for PM), support for Alsa
ASoC voice codec and mixer, and a GNSS driver for the GPS.

Where it does not make sense to do a kernel serdev driver, I've
exposed the rest of the available 27.010 channels as ten /dev/motmdm*
character devices. There's /dev/motmdm1 for AT commands to dial voice
calls, /dev/motmdm3 for SMS eventually, and I think there's also a SIM
card reader at /dev/motmdm10. Then /dev/motmdm7 seems to be just an
echo channel. The other channels are still a bit of a mystery.

I'll be cleaning up these patches and submitting them for review
when ready. If anybody feels like helping, I've added some REVISIT
comments to the patches. The patches are in a git branch at [0][1]
below based on a few Alsa ASoC patches for v4.21 from Linux next.

Thanks everybody for helping with comments and code to get the
various pieces working, below are some brief instructions too :)

Cheers,

Tony

[0] https://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap.git/log/?h=droid4-pending-mdm-v4.20
[1] git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap droid4-pending-mdm-v4.20


8< ----------------------
Serdev voice call and GNSS instructions for droid 4

1. Configure alsamixer

Speaker Right -> Voice
Call Noise Cancellation -> Unmute
Call Output -> Handset
Call -> 100
Mic2 -> 40
Left -> Mic 2
Voice -> 55

Voice call should get automatically enabled for the duration of
voice calls

2. Test a voice call

$ minicom -D /dev/motmdm1	# Then Ctrl-a-e to enable local echo
AT				# Case sensitive AT commands..
:OK				# Response uses : as separator..
AT+CFUN=1			# Enable radio
+CFUN:OK
~+RSSI=1,9,108,99,0,0,0
...
ATD1234567890			# Dial some phone number
D:OK
...
ATH				# Hang up
H:OK

3. Test GNSS

$ cat /dev/gnss0
$GPGSV,3,1,11,03,,,,05,14,313,,07,66,322,,08,32,106,*43
...

4. Known pending issues

There's an issue with gpsd not parsing $GNGNS packets, see
https://lists.gnu.org/archive/html/gpsd-dev/2016-05/msg00298.html

Sending SMS should be doable by writing to /dev/motmdm3 but I have
not quite figured out the message format

I have not tested with built-in modules.. There may be some
deferred probe issues remaining.

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-17  0:44 WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver Tony Lindgren
@ 2018-12-18 12:46 ` Pavel Machek
  2018-12-18 15:36   ` Tony Lindgren
  2018-12-22 23:05 ` Pavel Machek
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2018-12-18 12:46 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 2994 bytes --]

Hi!

> So the little elves have been slowly working to get voice calls
> working on droid 4 with the mainline kernel. And just in time for the
> upcoming holidays, it might be possible to call friends and relatives.
> 
> I've pushed out an experimental branch containing serdev ts 27.010
> UART multiplexing support. That contains a serdev core driver for the
> mdm6600 modem (that also now idles the modem for PM), support for Alsa
> ASoC voice codec and mixer, and a GNSS driver for the GPS.

Thanks for doing the work.

I'm quite busy these days, but...

# commit	 64cf2bf6b7614da35028a11974acb5a445dcc535 (patch)
# n_gsm: Use const unsigned char * and size_t
# We can use const unsigned char * and size_t. This makes things
# a bit easier for adding serdev support.
# 
# Note that gsm_control_modem() gsm_control_rls() read the data
# for tty control characters and then call gsm_control_reply()
# that allocates a new reply and copies the data.
# 
# REVISIT: Check size_t usage vs int
# 
# Signed-off-by: Tony Lindgren <tony@atomide.com>

Dunno, I see that you might want const there, but u8 -> unsigned char
seems like a step in wrong direction.

# commit	   cd16272060d8100ef0388349cf88f42a1dc667fc (patch)
# tty: n_gsm: Add support for serdev

Is it worth putting those in separate file? n_gsm_serdev.c?

# commit	    0c1bc81ba976bcd480d6e3c3009a28589f8427c0 (patch)
# mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4

Oh, that is a lot of fun. Especially state machine for parsing modem
responses. I wonder how well it is going to work when modem is
accessed over USB... 

motmdm_read_state(... size_t len)

I applied it over my tree (I still need patches for display,
right?). I'm getting

/data/fast/l/k/drivers/mfd/motorola-mdm.c:1132:3: error: initializer
element is not constant
/data/fast/l/k/drivers/mfd/motorola-mdm.c:1132:3: error: (near
initialization for 'motmdm_driver.driver.name')
/data/fast/l/k/scripts/Makefile.build:291: recipe for target
'drivers/mfd/motorola-mdm.o' failed

Oh and that mdelay(3000) is going to hurt... especially because
console is initialized very late or d4.

I did a quick test in my config... and it did not break my old setup
-- voice calls still work when set up over USB and with manual mixer
setup. That was good surprise.

Thanks,
									Pavel

diff --git a/drivers/mfd/motorola-mdm.c b/drivers/mfd/motorola-mdm.c
index eea754d..2b7c324 100644
--- a/drivers/mfd/motorola-mdm.c
+++ b/drivers/mfd/motorola-mdm.c
@@ -1129,7 +1129,7 @@ static void motmdm_remove(struct serdev_device *serdev)
 
 static struct serdev_device_driver motmdm_driver = {
 	.driver = {
-		.name = motmdm_driver_name,
+		.name = "motmdm",
 		.of_match_table = of_match_ptr(motmdm_id_table),
 		.pm = &motmdm_pm_ops,
 	},


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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-18 12:46 ` Pavel Machek
@ 2018-12-18 15:36   ` Tony Lindgren
  2018-12-18 20:22     ` Pavel Machek
  0 siblings, 1 reply; 25+ messages in thread
From: Tony Lindgren @ 2018-12-18 15:36 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

Hi,

* Pavel Machek <pavel@ucw.cz> [181218 12:46]:
> Dunno, I see that you might want const there, but u8 -> unsigned char
> seems like a step in wrong direction.

Well I was just trying to follow what the serdev core is doing
nowadays.. I'll see if I can just constify.

> # commit	   cd16272060d8100ef0388349cf88f42a1dc667fc (patch)
> # tty: n_gsm: Add support for serdev
> 
> Is it worth putting those in separate file? n_gsm_serdev.c?

Yes that's the plan but that needs some refactoring to be done
and I did not want to get into that until I had things working
to prevent regressions.

> # commit	    0c1bc81ba976bcd480d6e3c3009a28589f8427c0 (patch)
> # mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4
> 
> Oh, that is a lot of fun. Especially state machine for parsing modem
> responses. I wonder how well it is going to work when modem is
> accessed over USB... 
> 
> motmdm_read_state(... size_t len)

That's a bit of a layering violation yeah :) But we still need to
do that somewhere for notifiers. And the notifications are separate
from the commands and start with a ~ character so from that point of
view it should not be too bad.

In general, motorola-mdm should just deal with the custom packet
numbering layer and pass data to channel specific serdev drivers
or to the channel specific /dev/motmdm* char devices.

> I applied it over my tree (I still need patches for display,
> right?). I'm getting
> 
> /data/fast/l/k/drivers/mfd/motorola-mdm.c:1132:3: error: initializer
> element is not constant
> /data/fast/l/k/drivers/mfd/motorola-mdm.c:1132:3: error: (near
> initialization for 'motmdm_driver.driver.name')
> /data/fast/l/k/scripts/Makefile.build:291: recipe for target
> 'drivers/mfd/motorola-mdm.o' failed

Hmm OK thanks for letting me know. Yes Sebastian has updated
branches for the LCD.

> Oh and that mdelay(3000) is going to hurt... especially because
> console is initialized very late or d4.

It's msleep() not mdelay(). Sorry I have not figured out a better
way so far to get the n_gsm initialized other than spamming the
device with retries for a while on start-up.

> I did a quick test in my config... and it did not break my old setup
> -- voice calls still work when set up over USB and with manual mixer
> setup. That was good surprise.

OK good to hear. Using the n_gsm port instead of USB during idle
has a major PM advantage as the SoC can hit retention during idle
while still connected to the modem and getting notifications.

So looks like during idle we can keep USB in autosuspend mode with
something like the below shell script function.

Regards,

Tony

8< -----------------------
# It's OK to keep to keep ohci device on auto and qmi_wwan and cdc_wd loaded.
# Probably musb and ehci modules need to be currently unloaded for SoC idle.
suspend_usb() {
        ohci=$(find /sys/bus/platform/devices -name \*.ohci)
        if [ "${ohci}" = "" ]; then
                return
        fi

        devices=$(find "${ohci}/" -type f -name control)

        for device in ${devices}; do
                echo -n "${device}: "
                cat ${device}
        done

        for device in ${devices}; do
                echo -n "auto" > ${device}
        done

        for device in ${devices}; do
                echo -n "${device}: "
                cat ${device}
        done
}

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-18 15:36   ` Tony Lindgren
@ 2018-12-18 20:22     ` Pavel Machek
  2018-12-18 21:53       ` Tony Lindgren
  0 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2018-12-18 20:22 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1668 bytes --]

Hi!

> > # commit	    0c1bc81ba976bcd480d6e3c3009a28589f8427c0 (patch)
> > # mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4
> > 
> > Oh, that is a lot of fun. Especially state machine for parsing modem
> > responses. I wonder how well it is going to work when modem is
> > accessed over USB... 
> > 
> > motmdm_read_state(... size_t len)
> 
> That's a bit of a layering violation yeah :) But we still need to
> do that somewhere for notifiers. And the notifications are separate
> from the commands and start with a ~ character so from that point of
> view it should not be too bad.

Plus, you seem to assume that data will always come in suitably sized
chunks. Aha, and as it is not plain serial but packet protocol over
serial... I guess that is going to work?

> > I did a quick test in my config... and it did not break my old setup
> > -- voice calls still work when set up over USB and with manual mixer
> > setup. That was good surprise.
> 
> OK good to hear. Using the n_gsm port instead of USB during idle
> has a major PM advantage as the SoC can hit retention during idle
> while still connected to the modem and getting notifications.
> 
> So looks like during idle we can keep USB in autosuspend mode with
> something like the below shell script function.

Yes, I should really start using serials instead of USB. But... I have
working ofono there, and was using that phone and am little short on
time at the moment.

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-18 20:22     ` Pavel Machek
@ 2018-12-18 21:53       ` Tony Lindgren
  2019-01-16 13:48         ` Pavel Machek
  0 siblings, 1 reply; 25+ messages in thread
From: Tony Lindgren @ 2018-12-18 21:53 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

* Pavel Machek <pavel@ucw.cz> [181218 20:22]:
> Hi!
> 
> > > # commit	    0c1bc81ba976bcd480d6e3c3009a28589f8427c0 (patch)
> > > # mfd: motmdm: Add Motorola TS 27.010 serdev driver for devices like droid4
> > > 
> > > Oh, that is a lot of fun. Especially state machine for parsing modem
> > > responses. I wonder how well it is going to work when modem is
> > > accessed over USB... 
> > > 
> > > motmdm_read_state(... size_t len)
> > 
> > That's a bit of a layering violation yeah :) But we still need to
> > do that somewhere for notifiers. And the notifications are separate
> > from the commands and start with a ~ character so from that point of
> > view it should not be too bad.
> 
> Plus, you seem to assume that data will always come in suitably sized
> chunks. Aha, and as it is not plain serial but packet protocol over
> serial... I guess that is going to work?

Yeah it's just packet data out of the n_gsm.

> > > I did a quick test in my config... and it did not break my old setup
> > > -- voice calls still work when set up over USB and with manual mixer
> > > setup. That was good surprise.
> > 
> > OK good to hear. Using the n_gsm port instead of USB during idle
> > has a major PM advantage as the SoC can hit retention during idle
> > while still connected to the modem and getting notifications.
> > 
> > So looks like during idle we can keep USB in autosuspend mode with
> > something like the below shell script function.
> 
> Yes, I should really start using serials instead of USB. But... I have
> working ofono there, and was using that phone and am little short on
> time at the moment.

Hopefully adding support to ofono and modemmanager to use use
/dev/motmdm1 for calls should be quite trivial now.

Regards,

Tony

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-17  0:44 WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver Tony Lindgren
  2018-12-18 12:46 ` Pavel Machek
@ 2018-12-22 23:05 ` Pavel Machek
  2018-12-23 10:33 ` Pavel Machek
  2018-12-27 10:16 ` Pavel Machek
  3 siblings, 0 replies; 25+ messages in thread
From: Pavel Machek @ 2018-12-22 23:05 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1841 bytes --]

Hi, little elves!

> So the little elves have been slowly working to get voice calls
> working on droid 4 with the mainline kernel. And just in time for the
> upcoming holidays, it might be possible to call friends and relatives.
> 
> I've pushed out an experimental branch containing serdev ts 27.010
> UART multiplexing support. That contains a serdev core driver for the
> mdm6600 modem (that also now idles the modem for PM), support for Alsa
> ASoC voice codec and mixer, and a GNSS driver for the GPS.
> 
> Where it does not make sense to do a kernel serdev driver, I've
> exposed the rest of the available 27.010 channels as ten /dev/motmdm*
> character devices. There's /dev/motmdm1 for AT commands to dial voice
> calls, /dev/motmdm3 for SMS eventually, and I think there's also a SIM
> card reader at /dev/motmdm10. Then /dev/motmdm7 seems to be just an
> echo channel. The other channels are still a bit of a mystery.

I tried to get access at motmdm, but no:

root@devuan:/home/user# minicom -D /dev/motmdm1
minicom: cannot open /dev/motmdm1: No such file or directory
root@devuan:/home/user# ls -al /dev/motmdm1
ls: cannot access '/dev/motmdm1': No such file or directory
root@devuan:/home/user# dmesg | grep motmd
root@devuan:/home/user# zcat /proc/config.gz | grep MDM
CONFIG_MFD_MOTMDM=y
CONFIG_SND_SOC_MOTMDM=y
CONFIG_PHY_MAPPHONE_MDM6600=y
root@devuan:/home/user# uname -a
Linux devuan 4.20.0-rc7-00304-gde109fe #19 SMP Sat Dec 22 20:16:19 CET
2018 armv7l GNU/Linux
root@devuan:/home/user#

Let me try to enable CONFIG_GNSS_MOTMDM. N_GSM also seems enabled.
 
Is there anything else I need to enable in .config?

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-17  0:44 WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver Tony Lindgren
  2018-12-18 12:46 ` Pavel Machek
  2018-12-22 23:05 ` Pavel Machek
@ 2018-12-23 10:33 ` Pavel Machek
  2018-12-23 11:10   ` Pavel Machek
  2018-12-27 10:16 ` Pavel Machek
  3 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2018-12-23 10:33 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 3019 bytes --]

Hi!

> So the little elves have been slowly working to get voice calls
> working on droid 4 with the mainline kernel. And just in time for the
> upcoming holidays, it might be possible to call friends and relatives.
> 
> I've pushed out an experimental branch containing serdev ts 27.010
> UART multiplexing support. That contains a serdev core driver for the
> mdm6600 modem (that also now idles the modem for PM), support for Alsa
> ASoC voice codec and mixer, and a GNSS driver for the GPS.
> 
> Where it does not make sense to do a kernel serdev driver, I've
> exposed the rest of the available 27.010 channels as ten /dev/motmdm*
> character devices. There's /dev/motmdm1 for AT commands to dial voice
> calls, /dev/motmdm3 for SMS eventually, and I think there's also a SIM
> card reader at /dev/motmdm10. Then /dev/motmdm7 seems to be just an
> echo channel. The other channels are still a bit of a mystery.

I suspected it does not work in non-modular case, so I tried with
modules:

root@devuan:/my/ko# insmod gnss.ko
root@devuan:/my/ko# insmod gnss-motmdm.ko
insmod: ERROR: could not insert module gnss-motmdm.ko: Unknown symbol
in module
root@devuan:/my/ko# insmod n_gsm.ko
root@devuan:/my/ko# insmod snd-soc-motmdm.ko
insmod: ERROR: could not insert module snd-soc-motmdm.ko: Unknown
symbol in module
root@devuan:/my/ko# insmod motorola-mdm.ko
root@devuan:/my/ko# insmod snd-soc-motmdm.ko
root@devuan:/my/ko# insmod gnss-motmdm.ko
root@devuan:/my/ko#

But...

root@devuan:/my/ko# ls -al /dev/motmdm*
ls: cannot access '/dev/motmdm*': No such file or directory
root@devuan:/my/ko# ls -al /dev/gnss*
ls: cannot access '/dev/gnss*': No such file or directory
root@devuan:/my/ko#
[  116.244445] gnss: GNSS driver registered with major 242
[  119.892547] gnss_motmdm: Unknown symbol motmdm_register_dlci (err
-2)
[  119.899444] gnss_motmdm: Unknown symbol motmdm_unregister_dlci (err
-2)
[  129.145935] snd_soc_motmdm: Unknown symbol motmdm_register_dlci
(err -2)
[  129.153106] snd_soc_motmdm: Unknown symbol motmdm_unregister_dlci
(err -2)
[  131.120361] cpcap-usb-phy cpcap-usb-phy.0: connected to USB host
[  161.190216] cpcap-usb-phy cpcap-usb-phy.0: connected to USB host
[  191.270263] cpcap-usb-phy cpcap-usb-phy.0: connected to USB host
[  221.360107] cpcap-usb-phy cpcap-usb-phy.0: connected to USB host
[  251.429962] cpcap-usb-phy cpcap-usb-phy.0: connected to USB host
[  281.509643] cpcap-usb-phy cpcap-usb-phy.0: connected to USB host
[  292.816436] g_ether gadget: packet filter 0e
[  292.825256] g_ether gadget: ecm req21.43 v000e i0000 l0

...do I need to make devices manually or some udev rules?

user@devuan:~$ cat /proc/devices | grep motmdm
user@devuan:~$ cat /proc/devices | grep gnss
242 gnss
user@devuan:~$

Hmm, I suspect the driver just did not recognize the hw.
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-23 10:33 ` Pavel Machek
@ 2018-12-23 11:10   ` Pavel Machek
  2018-12-23 15:51     ` Tony Lindgren
  0 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2018-12-23 11:10 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]

Hi!

> > So the little elves have been slowly working to get voice calls
> > working on droid 4 with the mainline kernel. And just in time for the
> > upcoming holidays, it might be possible to call friends and relatives.
> > 
> > I've pushed out an experimental branch containing serdev ts 27.010
> > UART multiplexing support. That contains a serdev core driver for the
> > mdm6600 modem (that also now idles the modem for PM), support for Alsa
> > ASoC voice codec and mixer, and a GNSS driver for the GPS.
> > 
> > Where it does not make sense to do a kernel serdev driver, I've
> > exposed the rest of the available 27.010 channels as ten /dev/motmdm*
> > character devices. There's /dev/motmdm1 for AT commands to dial voice
> > calls, /dev/motmdm3 for SMS eventually, and I think there's also a SIM
> > card reader at /dev/motmdm10. Then /dev/motmdm7 seems to be just an
> > echo channel. The other channels are still a bit of a mystery.
> 
> I suspected it does not work in non-modular case, so I tried with
> modules:
> 
> root@devuan:/my/ko# insmod gnss.ko
> root@devuan:/my/ko# insmod gnss-motmdm.ko
> insmod: ERROR: could not insert module gnss-motmdm.ko: Unknown symbol
> in module
> root@devuan:/my/ko# insmod n_gsm.ko
> root@devuan:/my/ko# insmod snd-soc-motmdm.ko
> insmod: ERROR: could not insert module snd-soc-motmdm.ko: Unknown
> symbol in module
> root@devuan:/my/ko# insmod motorola-mdm.ko
> root@devuan:/my/ko# insmod snd-soc-motmdm.ko
> root@devuan:/my/ko# insmod gnss-motmdm.ko
> root@devuan:/my/ko#
...
> ...do I need to make devices manually or some udev rules?
> 
> user@devuan:~$ cat /proc/devices | grep motmdm
> user@devuan:~$ cat /proc/devices | grep gnss
> 242 gnss
> user@devuan:~$
> 
> Hmm, I suspect the driver just did not recognize the hw.

I added some printks to motmdm_probe, and they don't appear to be
called. I wonder if I'm missing something else in the config? I do
have serial

root@devuan:/my/ko# ls -al /dev/ttyS0
crw-rw---- 1 root dialout 4, 64 Dec 23 11:52 /dev/ttyS0

but not gsm multiplex:

root@devuan:/my/ko# ls -al /dev/gsm*
ls: cannot access '/dev/gsm*': No such file or directory

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-23 11:10   ` Pavel Machek
@ 2018-12-23 15:51     ` Tony Lindgren
  2018-12-23 19:59       ` Pavel Machek
  2018-12-26 21:16       ` Pavel Machek
  0 siblings, 2 replies; 25+ messages in thread
From: Tony Lindgren @ 2018-12-23 15:51 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

* Pavel Machek <pavel@ucw.cz> [181223 11:11]:
> I added some printks to motmdm_probe, and they don't appear to be
> called. I wonder if I'm missing something else in the config? I do
> have serial
> 
> root@devuan:/my/ko# ls -al /dev/ttyS0
> crw-rw---- 1 root dialout 4, 64 Dec 23 11:52 /dev/ttyS0
> 
> but not gsm multiplex:
> 
> root@devuan:/my/ko# ls -al /dev/gsm*
> ls: cannot access '/dev/gsm*': No such file or directory

Hmm with serdev you should not get /dev/ttyS0, so maybe you're missing:

CONFIG_SERIAL_DEV_BUS=y
CONFIG_SERIAL_DEV_CTRL_TTYPORT=y

Probably the Kconfig dependency should be for SERIAL_DEV_CTRL_TTYPORT
instead of SERIAL_DEV_BUS in these patches if that helps.

Or else you're missing the serdev related dts changes?

Regards,

Tony


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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-23 15:51     ` Tony Lindgren
@ 2018-12-23 19:59       ` Pavel Machek
  2018-12-26 21:16       ` Pavel Machek
  1 sibling, 0 replies; 25+ messages in thread
From: Pavel Machek @ 2018-12-23 19:59 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1908 bytes --]

On Sun 2018-12-23 07:51:47, Tony Lindgren wrote:
> * Pavel Machek <pavel@ucw.cz> [181223 11:11]:
> > I added some printks to motmdm_probe, and they don't appear to be
> > called. I wonder if I'm missing something else in the config? I do
> > have serial
> > 
> > root@devuan:/my/ko# ls -al /dev/ttyS0
> > crw-rw---- 1 root dialout 4, 64 Dec 23 11:52 /dev/ttyS0
> > 
> > but not gsm multiplex:
> > 
> > root@devuan:/my/ko# ls -al /dev/gsm*
> > ls: cannot access '/dev/gsm*': No such file or directory
> 
> Hmm with serdev you should not get /dev/ttyS0, so maybe you're missing:
> 
> CONFIG_SERIAL_DEV_BUS=y
> CONFIG_SERIAL_DEV_CTRL_TTYPORT=y

I had those enabled.

I also have

CONFIG_SERIAL_OMAP=y
CONFIG_SERIAL_OMAP_CONSOLE=y

> Probably the Kconfig dependency should be for SERIAL_DEV_CTRL_TTYPORT
> instead of SERIAL_DEV_BUS in these patches if that helps.
> 
> Or else you're missing the serdev related dts changes?

Thanks for the hints, but dts looks ok, too.

We still have
uart1: serial@0 {
   compatible = "ti,omap4-uart";

in omap4-l4.dtsi, right? ...

I see that CONFIG_SERIAL_OMAP=y and 8250_omap handles same
hardware. Let me try disabling CONFIG_SERIAL_OMAP=y.

Best regards,
								Pavel

Oh and you may want to apply this:

diff --git a/drivers/mfd/motorola-mdm.c b/drivers/mfd/motorola-mdm.c
index 2b7c324..2cdc9e8 100644
--- a/drivers/mfd/motorola-mdm.c
+++ b/drivers/mfd/motorola-mdm.c
@@ -1141,5 +1152,5 @@ module_serdev_device_driver(motmdm_driver);
 
 MODULE_ALIAS("platform:motorola-mdm");
 MODULE_DESCRIPTION("Motorola Modem TS 27.010 serdev driver");
-MODULE_AUTHOR("Tony Lindgren <tony@atomide.com");
+MODULE_AUTHOR("Tony Lindgren <tony@atomide.com>");
 MODULE_LICENSE("GPL v2");


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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-23 15:51     ` Tony Lindgren
  2018-12-23 19:59       ` Pavel Machek
@ 2018-12-26 21:16       ` Pavel Machek
  1 sibling, 0 replies; 25+ messages in thread
From: Pavel Machek @ 2018-12-26 21:16 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1060 bytes --]

Hi!

> > root@devuan:/my/ko# ls -al /dev/ttyS0
> > crw-rw---- 1 root dialout 4, 64 Dec 23 11:52 /dev/ttyS0
> > 
> > but not gsm multiplex:
> > 
> > root@devuan:/my/ko# ls -al /dev/gsm*
> > ls: cannot access '/dev/gsm*': No such file or directory
> 
> Hmm with serdev you should not get /dev/ttyS0, so maybe you're missing:
> 
> CONFIG_SERIAL_DEV_BUS=y
> CONFIG_SERIAL_DEV_CTRL_TTYPORT=y
> 
> Probably the Kconfig dependency should be for SERIAL_DEV_CTRL_TTYPORT
> instead of SERIAL_DEV_BUS in these patches if that helps.
> 
> Or else you're missing the serdev related dts changes?

Seems like I was missing the dts changes. I was using kexec (did not
want to replace a working kernel) and that seems to use the old dtb.

gnss0 now seems to work, and I do get some kind of replies from the AT
modem. Thanks!

I'll reply to the original email with bad news and more details...

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-17  0:44 WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver Tony Lindgren
                   ` (2 preceding siblings ...)
  2018-12-23 10:33 ` Pavel Machek
@ 2018-12-27 10:16 ` Pavel Machek
  2018-12-28 19:31   ` Tony Lindgren
  3 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2018-12-27 10:16 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1374 bytes --]

Hi!

> So the little elves have been slowly working to get voice calls
> working on droid 4 with the mainline kernel. And just in time for the
> upcoming holidays, it might be possible to call friends and
> relatives.

Thanks a lot for the Christmas present :-).

> 2. Test a voice call
> 
> $ minicom -D /dev/motmdm1	# Then Ctrl-a-e to enable local echo
> AT				# Case sensitive AT commands..
> :OK				# Response uses : as separator..
> AT+CFUN=1			# Enable radio
> +CFUN:OK
> ~+RSSI=1,9,108,99,0,0,0
> ...
> ATD1234567890			# Dial some phone number
> D:OK
> ...
> ATH				# Hang up
> H:OK

Ok, I really need SMS messages, too.

Fortunately, they are on /dev/motmdm9, in PDU format. Quite
logical. And you probably need to acknowledge them, using PDU,
too... (because otherwise you'll just get the same SMS over and over
and over). Which is also logical, but hard to do from shell/python.

Proper solution involves special support for ofonod...


Fortunately ttyUSB4 still works, so I can still use my old code... and
I started logging motmdm1 and 9 to a file as a backup... that should
be better than my existing solution. (But I don't get power benefits
etc.)

Best regards,

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-27 10:16 ` Pavel Machek
@ 2018-12-28 19:31   ` Tony Lindgren
  2018-12-28 20:46     ` Pavel Machek
  2019-01-16 13:58     ` Pavel Machek
  0 siblings, 2 replies; 25+ messages in thread
From: Tony Lindgren @ 2018-12-28 19:31 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

Hi,

* Pavel Machek <pavel@ucw.cz> [181227 10:17]:
> Ok, I really need SMS messages, too.
> 
> Fortunately, they are on /dev/motmdm9, in PDU format. Quite
> logical. And you probably need to acknowledge them, using PDU,
> too... (because otherwise you'll just get the same SMS over and over
> and over). Which is also logical, but hard to do from shell/python.

Yeah so I found that Ruby pdu_tools module allows decoding PDUs
properly while I did not have much luck with other tools.

So I wrote a hasty script to read SMS, copy it to a Maildir and
then ack it:

https://github.com/tmlind/droid4-sms-tools

> Proper solution involves special support for ofonod...

Yeah at least we're dealing with standard PDU format now for
incoming SMS.

Also looks like there is no status on the modem for these incoming
messages as checked with mmcli. I guess the idea with raw PDU
access is that the message is delivered directly to the client
and then acked instead of being queued in the modem?

> Fortunately ttyUSB4 still works, so I can still use my old code... and
> I started logging motmdm1 and 9 to a file as a backup... that should
> be better than my existing solution. (But I don't get power benefits
> etc.)

So what are you using to ack the received SMS over ttyUSB4?

My logs show that Android uses two different commands for ack.
Either AT+GCNMA=1 or AT+CNMA=0,0 gets used depending on something
that I have no idea of.. Maybe the network connected?

Sending SMS via /dev/motmdm3 needs move investigation, but at
least ModemManager mmcli can be used to create and send SMS.

Hmm or what are you using to send SMS over ttyUSB4?
I think you already replied with some of that info earlier
but I can't find it..

Oh one more thing, I noticed that on /dev/motmdm1, typing
AT+SCRN=0 supresses notifications except for WAKEUP, and then
1 is used to enable them again. That allows the UART to idle
instead of getting network status messages every few seconds :)

Regards,

Tony

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-28 19:31   ` Tony Lindgren
@ 2018-12-28 20:46     ` Pavel Machek
  2018-12-28 22:28       ` Tony Lindgren
  2019-01-16 13:58     ` Pavel Machek
  1 sibling, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2018-12-28 20:46 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 2993 bytes --]

Hi!

> Yeah so I found that Ruby pdu_tools module allows decoding PDUs
> properly while I did not have much luck with other tools.
> 
> So I wrote a hasty script to read SMS, copy it to a Maildir and
> then ack it:
> 
> https://github.com/tmlind/droid4-sms-tools

Aha, that was quick :-). Interesting, let me take a look.

> > Proper solution involves special support for ofonod...
> 
> Yeah at least we're dealing with standard PDU format now for
> incoming SMS.
> 
> Also looks like there is no status on the modem for these incoming
> messages as checked with mmcli. I guess the idea with raw PDU
> access is that the message is delivered directly to the client
> and then acked instead of being queued in the modem?

I'm not sure what "directly" and "client" is here, but yes, it seems
that motmdm9 just delivers messages, and if you don't ack them,
network will just keep retransmitting the message.

> > Fortunately ttyUSB4 still works, so I can still use my old code... and
> > I started logging motmdm1 and 9 to a file as a backup... that should
> > be better than my existing solution. (But I don't get power benefits
> > etc.)
> 
> So what are you using to ack the received SMS over ttyUSB4?

I have ofone with direct AT access --
https://github.com/pavelmachek/unicsy_demo/blob/master/ofone/at.py .

And then better solution using ofone + ofonod.

https://github.com/maemo-leste/bugtracker/issues/150

Now, ttyUSB4 provides quite a rich interface, and you can actually
select what if you want messages in text and PDU format, and if you
want modem to auto-acknowledge messages for you.

(But I don't think all options work).

It may be even possible to select if you want the messages to be
queued or delivered directly.

> My logs show that Android uses two different commands for ack.
> Either AT+GCNMA=1 or AT+CNMA=0,0 gets used depending on something
> that I have no idea of.. Maybe the network connected?

Not sure what goes on there.

> Sending SMS via /dev/motmdm3 needs move investigation, but at
> least ModemManager mmcli can be used to create and send SMS.
> 
> Hmm or what are you using to send SMS over ttyUSB4?
> I think you already replied with some of that info earlier
> but I can't find it..

Same as above -- in text mode sending messages is very easy (can be
done by hand in minicom, or at.py can do it), and ofonod can already
do PDU encoding etc.

> Oh one more thing, I noticed that on /dev/motmdm1, typing
> AT+SCRN=0 supresses notifications except for WAKEUP, and then
> 1 is used to enable them again. That allows the UART to idle
> instead of getting network status messages every few seconds :)

What kind of battery life do you get with all the optimalizations?
IIRC I was getting 7h with ttyUSB4 in use...

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-28 20:46     ` Pavel Machek
@ 2018-12-28 22:28       ` Tony Lindgren
  2018-12-28 23:25         ` Pavel Machek
  2018-12-31 22:20         ` Tony Lindgren
  0 siblings, 2 replies; 25+ messages in thread
From: Tony Lindgren @ 2018-12-28 22:28 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

Hi,

* Pavel Machek <pavel@ucw.cz> [181228 20:46]:
> I have ofone with direct AT access --
> https://github.com/pavelmachek/unicsy_demo/blob/master/ofone/at.py .

OK thanks, that shows some of the commands I was wondering about.

> Now, ttyUSB4 provides quite a rich interface, and you can actually
> select what if you want messages in text and PDU format, and if you
> want modem to auto-acknowledge messages for you.

So which AT command configures auto-ack of SMS? I don't need it,
just wondering what all these commands do.

> What kind of battery life do you get with all the optimalizations?
> IIRC I was getting 7h with ttyUSB4 in use...

With droid4-pending-mdm-v4.20 branch in the following state:

- UARTs idled
- LCD blanked (well no drivers yet droid4-sms-read.rb)
- MUSB and EHCI USB modules unloaded
- OHCI loaded with all the children in autosuspend via sysfs
- WLAN connected
- busybox acpid stopped (yup, it keeps polling something???)
- MDM6600 online with AT+CFUN=1 on /dev/motmdm1
- MDM6600 notifications disabled with AT+SCRN=0 on /motmdm1
- droid4-sms-read.rb running

I'm seeing droid 4 idle at 119mW according to my power supply.
So I guess theoretical battery life would currently be
(1785mWh * 3.8V) / 119mW = 57h. But in practise things are not
completely idle and monitoring sysfs POWER_SUPPLY_POWER_AVG
every 10 seconds I'm seeing something along these 10 samples:

POWER_SUPPLY_POWER_AVG=138938
POWER_SUPPLY_POWER_AVG=134571
POWER_SUPPLY_POWER_AVG=505802
POWER_SUPPLY_POWER_AVG=240412
POWER_SUPPLY_POWER_AVG=134252
POWER_SUPPLY_POWER_AVG=132694
POWER_SUPPLY_POWER_AVG=571569
POWER_SUPPLY_POWER_AVG=132694
POWER_SUPPLY_POWER_AVG=190456
POWER_SUPPLY_POWER_AVG=518288

So the average based on that sampling is about 270mW and the idle
time should be about 1785 * 3.8 / 270 = 25h, which is quite usable
already :)

Regards,

Tony

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-28 22:28       ` Tony Lindgren
@ 2018-12-28 23:25         ` Pavel Machek
  2018-12-28 23:34           ` Tony Lindgren
  2018-12-31 22:20         ` Tony Lindgren
  1 sibling, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2018-12-28 23:25 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 2803 bytes --]

Hi!

> * Pavel Machek <pavel@ucw.cz> [181228 20:46]:
> > I have ofone with direct AT access --
> > https://github.com/pavelmachek/unicsy_demo/blob/master/ofone/at.py .
> 
> OK thanks, that shows some of the commands I was wondering about.

I had some luck just googling AT commands. They are somehow
standartized.

> > Now, ttyUSB4 provides quite a rich interface, and you can actually
> > select what if you want messages in text and PDU format, and if you
> > want modem to auto-acknowledge messages for you.
> 
> So which AT command configures auto-ack of SMS? I don't need it,
> just wondering what all these commands do.

So this would be "text mode": AT+CMGF=1. And I'd actually expect
auto-ack to be the default on ttyUSB4, but in any case this is the
command that controls it is: AT+CNMI=1,2,2,1,0.

> 
> > What kind of battery life do you get with all the optimalizations?
> > IIRC I was getting 7h with ttyUSB4 in use...
> 
> With droid4-pending-mdm-v4.20 branch in the following state:
> 
> - UARTs idled
> - LCD blanked (well no drivers yet droid4-sms-read.rb)
> - MUSB and EHCI USB modules unloaded
> - OHCI loaded with all the children in autosuspend via sysfs
> - WLAN connected
> - busybox acpid stopped (yup, it keeps polling something???)
> - MDM6600 online with AT+CFUN=1 on /dev/motmdm1
> - MDM6600 notifications disabled with AT+SCRN=0 on /motmdm1
> - droid4-sms-read.rb running
> 
> I'm seeing droid 4 idle at 119mW according to my power supply.
> So I guess theoretical battery life would currently be
> (1785mWh * 3.8V) / 119mW = 57h. But in practise things are not
> completely idle and monitoring sysfs POWER_SUPPLY_POWER_AVG
> every 10 seconds I'm seeing something along these 10 samples:
> 
> POWER_SUPPLY_POWER_AVG=138938
> POWER_SUPPLY_POWER_AVG=134571
> POWER_SUPPLY_POWER_AVG=505802
> POWER_SUPPLY_POWER_AVG=240412
> POWER_SUPPLY_POWER_AVG=134252
> POWER_SUPPLY_POWER_AVG=132694
> POWER_SUPPLY_POWER_AVG=571569
> POWER_SUPPLY_POWER_AVG=132694
> POWER_SUPPLY_POWER_AVG=190456
> POWER_SUPPLY_POWER_AVG=518288
> 
> So the average based on that sampling is about 270mW and the idle
> time should be about 1785 * 3.8 / 270 = 25h, which is quite usable
> already :)

So... 57h would be very nice, and even 25h is cool. IIRC original
motorola firmware does something like 100hours, and cyanogenmod is
closer to 24h...

Note that there's something in the sysfs that allows "precise"
measurements. Aha, it is "charge_counter" on droid4.

(I even have some software to do the monitoring and display the
graphs. unicsy_demo/monitor/batmond).

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-28 23:25         ` Pavel Machek
@ 2018-12-28 23:34           ` Tony Lindgren
  0 siblings, 0 replies; 25+ messages in thread
From: Tony Lindgren @ 2018-12-28 23:34 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

* Pavel Machek <pavel@ucw.cz> [181228 23:25]:
> So this would be "text mode": AT+CMGF=1. And I'd actually expect
> auto-ack to be the default on ttyUSB4, but in any case this is the
> command that controls it is: AT+CNMI=1,2,2,1,0.

OK thanks. These are not available for /dev/motmdm* files AFAIK.

> So... 57h would be very nice, and even 25h is cool. IIRC original
> motorola firmware does something like 100hours, and cyanogenmod is
> closer to 24h...

Well I got things down to about 55mW during idle but that still needs
more work. So that would be in theory idle battery life of:

(1735mWh * 3.8V) / 55mW = 119.87h (4.99d)

> Note that there's something in the sysfs that allows "precise"
> measurements. Aha, it is "charge_counter" on droid4.
> 
> (I even have some software to do the monitoring and display the
> graphs. unicsy_demo/monitor/batmond).

Oh nice, I'll give that a try.

Regards,

Tony


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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-28 22:28       ` Tony Lindgren
  2018-12-28 23:25         ` Pavel Machek
@ 2018-12-31 22:20         ` Tony Lindgren
  1 sibling, 0 replies; 25+ messages in thread
From: Tony Lindgren @ 2018-12-31 22:20 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

Hi,

* Tony Lindgren <tony@atomide.com> [181228 22:28]:
> With droid4-pending-mdm-v4.20 branch in the following state:
> 
> - UARTs idled
> - LCD blanked (well no drivers yet droid4-sms-read.rb)
> - MUSB and EHCI USB modules unloaded
> - OHCI loaded with all the children in autosuspend via sysfs
> - WLAN connected
> - busybox acpid stopped (yup, it keeps polling something???)
> - MDM6600 online with AT+CFUN=1 on /dev/motmdm1
> - MDM6600 notifications disabled with AT+SCRN=0 on /motmdm1
> - droid4-sms-read.rb running

So I tracked down what I thought is a busybox acpid issue, I was
wrong. There's nothing wrong with busybox acpid, sorry for
blaming a wrong culprit.

We have acpid keep the device open for
/dev/input/by-path/platform-48072000.i2c-event open, which
seems to keep atmel_mxt_ts and i2c busy.

Things idle fine after I rmmod atmel_mxt_ts after blanking
the screen.

Regards,

Tony


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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-18 21:53       ` Tony Lindgren
@ 2019-01-16 13:48         ` Pavel Machek
  2019-01-17  2:54           ` Tony Lindgren
  0 siblings, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2019-01-16 13:48 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1247 bytes --]

Hi!

> > > > I did a quick test in my config... and it did not break my old setup
> > > > -- voice calls still work when set up over USB and with manual mixer
> > > > setup. That was good surprise.
> > > 
> > > OK good to hear. Using the n_gsm port instead of USB during idle
> > > has a major PM advantage as the SoC can hit retention during idle
> > > while still connected to the modem and getting notifications.
> > > 
> > > So looks like during idle we can keep USB in autosuspend mode with
> > > something like the below shell script function.
> > 
> > Yes, I should really start using serials instead of USB. But... I have
> > working ofono there, and was using that phone and am little short on
> > time at the moment.
> 
> Hopefully adding support to ofono and modemmanager to use use
> /dev/motmdm1 for calls should be quite trivial now.

git@github.com:pavelmachek/ofono.git

"quite trivial" does not mix with ofono. I did parts and it is still
not finished. At the moment, I do not have enough working SIM cards to
test everything. Feel free to help :-).
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2018-12-28 19:31   ` Tony Lindgren
  2018-12-28 20:46     ` Pavel Machek
@ 2019-01-16 13:58     ` Pavel Machek
  2019-01-16 14:59       ` Tony Lindgren
  1 sibling, 1 reply; 25+ messages in thread
From: Pavel Machek @ 2019-01-16 13:58 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 2093 bytes --]

Hi!

> * Pavel Machek <pavel@ucw.cz> [181227 10:17]:
> > Ok, I really need SMS messages, too.
> > 
> > Fortunately, they are on /dev/motmdm9, in PDU format. Quite
> > logical. And you probably need to acknowledge them, using PDU,
> > too... (because otherwise you'll just get the same SMS over and over
> > and over). Which is also logical, but hard to do from shell/python.
> 
> Yeah so I found that Ruby pdu_tools module allows decoding PDUs
> properly while I did not have much luck with other tools.
> 
> So I wrote a hasty script to read SMS, copy it to a Maildir and
> then ack it:
> 
> https://github.com/tmlind/droid4-sms-tools

I could not get that one to work.

/var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47:in
`class_eval': /var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47:
`@@{' is not allowed as a class variable name (SyntaxError)
/var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47: syntax error,
unexpected end-of-input
          unless defined? @@{:default=>true}
	                              ^
from /var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47:in `block in cattr_accessor'
					

And I wanted to ask -- did you figure out how to acknowledge the
SMSs? +CGNNA does not seem to do the job:

07912470338016...
AT+CGNMA=1
+CGNMA:ERROR=9

> > Fortunately ttyUSB4 still works, so I can still use my old code... and
> > I started logging motmdm1 and 9 to a file as a backup... that should
> > be better than my existing solution. (But I don't get power benefits
> > etc.)
> 
> So what are you using to ack the received SMS over ttyUSB4?
> 
> My logs show that Android uses two different commands for ack.
> Either AT+GCNMA=1 or AT+CNMA=0,0 gets used depending on something
> that I have no idea of.. Maybe the network connected?

I believe I tried both... but for some reason I think you need to
paste back "acknowledge PDU"...?


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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2019-01-16 13:58     ` Pavel Machek
@ 2019-01-16 14:59       ` Tony Lindgren
  2019-01-16 15:09         ` Tony Lindgren
  2019-01-16 23:06         ` Pavel Machek
  0 siblings, 2 replies; 25+ messages in thread
From: Tony Lindgren @ 2019-01-16 14:59 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

* Pavel Machek <pavel@ucw.cz> [190116 13:58]:
> Hi!
> 
> > * Pavel Machek <pavel@ucw.cz> [181227 10:17]:
> > > Ok, I really need SMS messages, too.
> > > 
> > > Fortunately, they are on /dev/motmdm9, in PDU format. Quite
> > > logical. And you probably need to acknowledge them, using PDU,
> > > too... (because otherwise you'll just get the same SMS over and over
> > > and over). Which is also logical, but hard to do from shell/python.
> > 
> > Yeah so I found that Ruby pdu_tools module allows decoding PDUs
> > properly while I did not have much luck with other tools.
> > 
> > So I wrote a hasty script to read SMS, copy it to a Maildir and
> > then ack it:
> > 
> > https://github.com/tmlind/droid4-sms-tools
> 
> I could not get that one to work.
> 
> /var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47:in
> `class_eval': /var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47:
> `@@{' is not allowed as a class variable name (SyntaxError)
> /var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47: syntax error,
> unexpected end-of-input
>           unless defined? @@{:default=>true}
> 	                              ^
> from /var/lib/gems/2.3.0/gems/phone-1.2.3/lib/support.rb:47:in `block in cattr_accessor'

Hmm yeah looking at my notes I also had some issues and did something like
this to install git version of phone gem:

$ git clone git://github.com/carr/phone
$ cd phone
$ sed -i 's/beta//' lib/phone/version.rb
$ cd phone
$ sed -i 's/1.3.0.beta1/1.2.9/' lib/phone/version.rb
$ gem build phone.gemspec
$ sudo gem uninstall phone
$ sudo gem uninstall bigdecimal -v 1.4.2        # 1.3.4 works
$ sudo gem install phone-1.2.9.gem

> And I wanted to ask -- did you figure out how to acknowledge the
> SMSs? +CGNNA does not seem to do the job:
> 
> 07912470338016...
> AT+CGNMA=1
> +CGNMA:ERROR=9

Yeah the scripts in droid4-sms-tools git repo work for me for sending
and receiving. They do not work with cdma currently as the format is
different.

Maybe you've managed to change the mode of the modem to queue the
messages with the at commands to the usb port?

You are reading and writing to /dev/motmdm9 for incoming sms right?

> > My logs show that Android uses two different commands for ack.
> > Either AT+GCNMA=1 or AT+CNMA=0,0 gets used depending on something
> > that I have no idea of.. Maybe the network connected?

I think AT+GCNMA=1 works 3g and AT+CNMA=0,0 with cdma. Or it could be
that one of them is just a delayed ack, I don't know.

Regards,

Tony

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2019-01-16 14:59       ` Tony Lindgren
@ 2019-01-16 15:09         ` Tony Lindgren
  2019-01-16 23:06         ` Pavel Machek
  1 sibling, 0 replies; 25+ messages in thread
From: Tony Lindgren @ 2019-01-16 15:09 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

* Tony Lindgren <tony@atomide.com> [190116 14:59]:
> * Pavel Machek <pavel@ucw.cz> [190116 13:58]:
> > And I wanted to ask -- did you figure out how to acknowledge the
> > SMSs? +CGNNA does not seem to do the job:
> > 
> > 07912470338016...
> > AT+CGNMA=1
> > +CGNMA:ERROR=9
> 
> Yeah the scripts in droid4-sms-tools git repo work for me for sending
> and receiving. They do not work with cdma currently as the format is
> different.
> 
> Maybe you've managed to change the mode of the modem to queue the
> messages with the at commands to the usb port?
> 
> You are reading and writing to /dev/motmdm9 for incoming sms right?

To debug, you can modprobe n_gsm debug=0xff and you'll see all the
packet data in dmesg, maybe email me the dmesg output of your ack
command packet data?

Or compare against what Android is doing, you can echo 0x7fffffff to
the ts27010 sysfs debug file somewhere to see similar packet data
with logcat -b radio.

Regards,

Tony

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2019-01-16 14:59       ` Tony Lindgren
  2019-01-16 15:09         ` Tony Lindgren
@ 2019-01-16 23:06         ` Pavel Machek
  1 sibling, 0 replies; 25+ messages in thread
From: Pavel Machek @ 2019-01-16 23:06 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

Hi!

> Yeah the scripts in droid4-sms-tools git repo work for me for sending
> and receiving. They do not work with cdma currently as the format is
> different.
> 
> Maybe you've managed to change the mode of the modem to queue the
> messages with the at commands to the usb port?

I did not have ttyUSB open during that boot. I hope this kind of
settings does not survive across reboots.

> You are reading and writing to /dev/motmdm9 for incoming sms right?

Yes, I think so. Same one where hex-coded PDU comes.

> > > My logs show that Android uses two different commands for ack.
> > > Either AT+GCNMA=1 or AT+CNMA=0,0 gets used depending on something
> > > that I have no idea of.. Maybe the network connected?
> 
> I think AT+GCNMA=1 works 3g and AT+CNMA=0,0 with cdma. Or it could be
> that one of them is just a delayed ack, I don't know.

Strange. It does not seem to be recognized at all.

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2019-01-16 13:48         ` Pavel Machek
@ 2019-01-17  2:54           ` Tony Lindgren
  2019-01-17 12:51             ` Pavel Machek
  0 siblings, 1 reply; 25+ messages in thread
From: Tony Lindgren @ 2019-01-17  2:54 UTC (permalink / raw)
  To: Pavel Machek
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

* Pavel Machek <pavel@ucw.cz> [190116 13:48]:
> "quite trivial" does not mix with ofono. I did parts and it is still
> not finished. At the moment, I do not have enough working SIM cards to
> test everything. Feel free to help :-).

I gave it a try but could only see "ofonod[14012]: motmdm init"
on start up. Running test/list-modems shows only /stktest
and no motmdm..

Do I need to configure something in /etc/ofono?

Regards,

Tony

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

* Re: WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver
  2019-01-17  2:54           ` Tony Lindgren
@ 2019-01-17 12:51             ` Pavel Machek
  0 siblings, 0 replies; 25+ messages in thread
From: Pavel Machek @ 2019-01-17 12:51 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: linux-kernel, linux-arm-kernel, linux-omap, Jarkko Nikula,
	Johan Hovold, Kuninori Morimoto, Marcel Partap, Merlijn Wajer,
	Michael Scott, NeKit, omerlle, Sebastian Reichel, Peter Ujfalusi,
	Rob Herring

[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]

Hi!

> > "quite trivial" does not mix with ofono. I did parts and it is still
> > not finished. At the moment, I do not have enough working SIM cards to
> > test everything. Feel free to help :-).
> 
> I gave it a try but could only see "ofonod[14012]: motmdm init"
> on start up. Running test/list-modems shows only /stktest
> and no motmdm..
> 
> Do I need to configure something in /etc/ofono?

No, that should not be needed. But you need this:

user@devuan:~$ cat /etc/udev/rules.d/55-modem.rules
KERNEL=="ttyUSB4", ENV{OFONO_DRIVER}="g1"

KERNEL=="motmdm1", ENV{OFONO_DRIVER}="motmdm"

(different devices for different branches of ofono), and it is useful
to run ofono like this:

sudo OFONO_AT_DEBUG=1 src/ofonod -d -n -p motmdm,udevng,atmodem,motorolamodem

...to get right kind of debugging.

You then want to run enable-modem . online-modem is NOP, afaict.

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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

end of thread, other threads:[~2019-01-17 12:51 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17  0:44 WIP Droid 4 voice calls, GNSS & PM with a TS 27.010 serdev driver Tony Lindgren
2018-12-18 12:46 ` Pavel Machek
2018-12-18 15:36   ` Tony Lindgren
2018-12-18 20:22     ` Pavel Machek
2018-12-18 21:53       ` Tony Lindgren
2019-01-16 13:48         ` Pavel Machek
2019-01-17  2:54           ` Tony Lindgren
2019-01-17 12:51             ` Pavel Machek
2018-12-22 23:05 ` Pavel Machek
2018-12-23 10:33 ` Pavel Machek
2018-12-23 11:10   ` Pavel Machek
2018-12-23 15:51     ` Tony Lindgren
2018-12-23 19:59       ` Pavel Machek
2018-12-26 21:16       ` Pavel Machek
2018-12-27 10:16 ` Pavel Machek
2018-12-28 19:31   ` Tony Lindgren
2018-12-28 20:46     ` Pavel Machek
2018-12-28 22:28       ` Tony Lindgren
2018-12-28 23:25         ` Pavel Machek
2018-12-28 23:34           ` Tony Lindgren
2018-12-31 22:20         ` Tony Lindgren
2019-01-16 13:58     ` Pavel Machek
2019-01-16 14:59       ` Tony Lindgren
2019-01-16 15:09         ` Tony Lindgren
2019-01-16 23:06         ` Pavel Machek

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