Commit Graph

27 Commits

Author SHA1 Message Date
Adam Pigg
40136c2a52 Allow to build without mmglib 2021-04-05 17:11:17 +01:00
Arnaud Ferraris
ea19b0271c Merge branch 'master' into 'master'
Add a 100ms delay before PWRKEY sequence

See merge request mobian1/devices/eg25-manager!11
2021-03-17 21:37:53 +00:00
Djhg2000
528fe7e07c Add a 100ms delay before PWRKEY sequence
This brings the power on sequence in line with the EG25-G Hardware Design
datasheet, which states we need to wait at least 30 ms after VBAT becomes stable
before pulling PWRKEY low (first action of the power on sequene).

After this change the sequence becomes as follows:
- Set RESET_N high
- Wait 60 ms (double 30 ms)
- Execute PWRKEY sequence

60 ms was choosen because we don't know when VBAT becomes stable, but it should
be much less than an additional 30 ms. Empirical evidence suggests PinePhone
units with a healthy battery do not see serious side effects from not doing
this, while the modem will fail to boot and/or throw random errors on boot with
a worn out battery.
2021-03-17 19:11:36 +01:00
Oliver Smith
dcb1a9a050 src: add ofono-iface
Start work on new ofono interface. So far, this detects ofono on dbus
and complains if both mm and ofono are running.
2021-03-15 12:29:08 +05:30
Arnaud Ferraris
042de572ea at: parse config file
The AT commands list for each stage is now configured per-device, as 
well as the UART port to be used.

As this list can be changed by the user, there is no more need for a 
special GNSS-related option
2021-02-20 17:10:43 +01:00
Arnaud Ferraris
433982e4f7 manager: parse config file
The need to use libusb to check for the modem state on startup now 
depends on a config option, instead of the device type. The USB PID and 
VID are moved to config as well.
2021-02-20 17:04:49 +01:00
Arnaud Ferraris
d9256251fd src: implement config file lookup and initial parsing
This commit prepares the use of device-specific configuration files. 
These files should be named after the device-tree `compatible` string 
with the `toml` extension.

`eg25-manager` will search for config files in 
`<prefix>/etc/eg25-manager` first (or `/etc/eg25-manager` if prefix is 
`/usr`), then in `<prefix>/share/eg25-manager`.
2021-02-20 17:04:49 +01:00
Arnaud Ferraris
19d00bee3b manager: make sure we don't block suspend when rebooting the modem 2021-02-20 17:04:38 +01:00
Arnaud Ferraris
b929c6a380 src: minor cleanups and cosmetic fixes 2021-02-20 17:01:17 +01:00
Dylan Van Assche
b8d269cf2f suspend: add boot timer
The EG25 modem needs at least 2 minutes after indicating 'RDY'
to be fully operational. If the modem is suspended before that,
calls or texts may not be seen by the userspace.
This mostly occurs when a full reboot or poweroff/poweron
sequence of the phone is performed.

:
2021-02-17 21:05:58 +01:00
Arnaud Ferraris
79974bc9ee manager: don't manage the GNSS by default 2021-01-14 00:06:55 +01:00
Arnaud Ferraris
c2e83f15a6 manager: improve error checking in modem_reset() 2020-12-30 17:31:44 +01:00
Arnaud Ferraris
abc05e86e5 manager: only toggle GPIOs for suspend after executing all AT commands 2020-12-30 16:20:32 +01:00
Arnaud Ferraris
067c01b685 manager: rename suspend_source to suspend_timer
This makes its role more explicit.
2020-12-18 01:38:27 +01:00
Arnaud Ferraris
62a07f9c51 src: add udev watcher to improve modem recovery
Most of the modem issues follow a (incomplete) USB device reset. Instead 
of relying solely on the existing timer, this patch adds a udev monitor 
which resets the modem as soon as its associated USB device is reset, 
which greatly improves recovery time.
2020-12-18 01:37:06 +01:00
Arnaud Ferraris
74b91c7d58 manager: make sure we don't reset the modem twice in a row
This patch adds a 3s delay when resetting the modem during which we 
avoid triggering a new reset. This makes sure we don't trigger a reset 
twice in a row.

It also disables any related running timer to avoid being re-triggered 
unnecessarily.
2020-12-18 00:45:58 +01:00
Arnaud Ferraris
9c9169a972 manager: get rid of compiler warnings 2020-12-13 00:55:22 +01:00
Arnaud Ferraris
b495d6c747 gpio: get rid of compiler warnings 2020-12-13 00:52:38 +01:00
Arnaud Ferraris
fd6a292a8f manager: don't change modem state after reset
This makes sure the resume commands (disable URC cache and enable GPS)
are executed.
2020-12-11 15:09:38 +01:00
Arnaud Ferraris
75b0920e9d Revert "manager: split modem_suspend() into _pre() and _post() functions"
This reverts commit ff9b26b831.
2020-12-11 13:36:28 +01:00
Arnaud Ferraris
ff9b26b831 manager: split modem_suspend() into _pre() and _post() functions
This way we can make sure the AT commands are executed only once 
ModemManager has released the modem, preventing any race condition.
2020-12-11 12:49:31 +01:00
Arnaud Ferraris
8d31e39e89 manager: only start the modem if it isn't already on 2020-12-11 12:49:10 +01:00
Arnaud Ferraris
87c7af7056 manager: actively poll GPIO when quitting
For some reason, during system the main loop exits before we call 
g_main_loop_quit(), so don't rely on it and use a simple polling loop to 
check for modem poweroff.
2020-12-10 21:33:18 +01:00
Arnaud Ferraris
a8a1c8d161 manager: improve BH/CE detection
`Developer edition` phones have a different compatible string but should 
be considered identical to BraveHeart edition here. Therefore BH is the 
default phone, unless the compatible is that of a CE phone.
2020-12-10 17:07:36 +01:00
Arnaud Ferraris
47b2f71b6f improve poweroff sequence
When powering off the modem, we must assert the RESET line only when the 
modem has shut down (otherwise it'll cause a hard reset and won't allow 
the modem to shut down properly).

This commit also polls the STATUS pin during poweroff and quits 
immediately once this pin goes high.
2020-12-10 17:05:44 +01:00
Arnaud Ferraris
e3387e85ca manager: destroy at/gpio modules after the main loop exits 2020-12-10 16:56:18 +01:00
Arnaud Ferraris
87ade8dd27 Initial release 2020-12-10 15:03:29 +01:00