Skip to main content

Crate ql_lpm

Crate ql_lpm 

Expand description

Library for interacting with Quectel’s LPM kernel module.

The kernel module is ql-ol-kernel/drivers/quectel-drivers/ql_lpm/ql_lpm.c in the Quectel SDK.

Even though the name seems to imply that this module is for low power mode, it is only tangentially related. The module does two things:

  1. It allows userspace to attach an interrupt to an input pin so that this pin can be used to wake up the system from suspend.
  2. It sets an output pin to a level when the system suspends. This can be used to turn off another device during suspend.

For the TCUv4 we’re using the feature so the NXP can wake the AG35 and the AG35 can turn off the NXP when going to sleep.

§Example

let config = ql_lpm::Config {
    input_pin: ql_gpio::TlmmPin::Gpio2,
    input_pull_selection: ql_gpio::PullSelection::PullUp,
    output_pin: ql_gpio::TlmmPin::Gpio5,
    sleep_level: ql_gpio::Level::Low,
};
let mut lpm = ql_lpm::Lpm::new(config).unwrap();
loop {
    let edge = lpm.next().await.unwrap();
    println!("Edge: {:?}", edge);
}

§Technical details

The initial configuration containing the pins is given to the module as parameters. Once the module is loaded, a netlink socket is used to communicate with the module. The kernel module expects a netlink message to find out which netlink port to send events to. Only one process can receive events. The module will then send messages containing the payload “falling” or “rising” to the listening process whenever the input pin changes its state.

Modules§

linux 🔒 Android or Linux

Structs§

Config
Configuration for the LPM kernel module.
Lpm
Connection to the LPM kernel module.

Enums§

Edge
Edge of an input pin signal.