xnux.eu - site map - news

Modem on PinePhone

Enabling and disabling power to the modem

My kernel is a bit special, since compared to pine64-org kernel, it doesn't enable modem power automatically and modem power is handled by a special kernel driver.

It can be controlled using this program:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>

#define A711_IOCTL_RESET _IO('A', 0)
#define A711_IOCTL_POWERUP _IO('A', 1)
#define A711_IOCTL_POWERDN _IO('A', 2)
#define A711_IOCTL_STATUS _IOR('A', 3, int)

int main(int ac, char* av[])
{
        int ret;

        if (ac <= 1) {
                printf("Usage: %s [1|0]", av[0]);
                return 1;
        }

        int fd = open("/dev/pwr-modem", O_RDWR);
        if (fd < 0) {
                perror("power control open failed\n");
                exit(1);
        }
        
        ret = ioctl(fd, av[1][0] == '1' ? A711_IOCTL_POWERUP : A711_IOCTL_POWERDN, 0);
        if (ret < 0) {
                perror("power up failed\n");
                exit(1);
        }

        return 0;       
}
        

To enable modem run:

./modem-power 1

To disable modem power:

./modem-power 0

Or via sysfs (since 5.6):

# request powerup
echo 1 > /sys/devices/platform/modem/powered
# request powerdown
echo 0 > /sys/devices/platform/modem/powered
# read power status (changes only after power state transition is complete)
cat /sys/devices/platform/modem/powered
# It's also possible to change the powerdown safety delay (in ms):
cat /sys/devices/platform/modem/powerdown_safety_delay
echo 10000 > /sys/devices/platform/modem/powerdown_safety_delay

Connecting to the modem

You can connect to the modem once it's powered up via:

screen /dev/ttyUSB2 115200

Disconnect by CTRL+a k.

Setting up the modem for voice calling

Once per a lifetime you have to run AT+QDAI=1,0,0,2,0,1,1,1 and reboot the modem. That will configure audio on the modem side correctly and store the configuration persistently inside the modem.

To setup audio for call use my call audio setup program.

You need to run the program after the call starts twice. Once with your desired audio setup without -2 option and once with -2 option.

To answer a call type ATA, to make a call ATDsomenumber;, to hangup ATH.

That's it. ;)