diff --git a/data/meson.build b/data/meson.build index 56bc6e3..f1fc8f0 100644 --- a/data/meson.build +++ b/data/meson.build @@ -8,6 +8,7 @@ conf_files = [ 'pine64,pinephone-1.0.toml', 'pine64,pinephone-1.1.toml', 'pine64,pinephone-1.2.toml', +'pine64,pinephone-pro.toml', ] install_data(conf_files) diff --git a/data/pine64,pinephone-pro.toml b/data/pine64,pinephone-pro.toml new file mode 100644 index 0000000..492de96 --- /dev/null +++ b/data/pine64,pinephone-pro.toml @@ -0,0 +1,97 @@ +[manager] +# Delay between setting GPIO and PWRKEY sequence, set in microseconds +poweron_delay = 100000 + +# Uncomment the following if you need to change the modem detection timeout on +# resume and/or the time during which suspend is blocked after modem boot +#[suspend] +#boot_timeout = 120 +#recovery_timeout = 9 + +[gpio] +chips = [ "gpio0", "gpio3" ] +dtr = { chip = 0, line = 3 } +pwrkey = { chip = 0, line = 13 } +reset = { chip = 1, line = 8 } +apready = { chip = 0, line = 12 } +disable = { chip = 0, line = 8 } +status = { chip = 1, line = 6 } + +[at] +uart = "/dev/ttyS3" +configure = [ +# Each command has 4 possible elements: +# * `cmd` : the AT command itself, which will be translated to "AT+`cmd`" +# * `subcmd`: the subcommand in case a single AT command can be used +# to change multiple parameters, such as QCFG (optional) +# * `value` : the commands, argument, usually used to set the value of +# a specific parameter (optional) +# * `expect`: the expected return value; the command is first executed +# without any value in order to query the current state. This +# state is then compared to the `expect` string; if they don't +# match, the command is then executed with value `expect` in +# order to set the parameter to the configured value (optional) +# A command can have `expect` OR `value` configured, but it shouldn't have both +# Print software version + { cmd = "QGMR" }, +# Configure audio + { cmd = "QDAI", expect = "3,0,0,4,0,0,1,1" }, +# RI signaling using physical RI pin + { cmd = "QCFG", subcmd = "risignaltype", expect = "\"physical\"" }, +# Enable VoLTE support + { cmd = "QCFG", subcmd = "ims", expect = "1" }, +# Enable APREADY for PP 1.2 + { cmd = "QCFG", subcmd = "apready", expect = "1,0,500" }, +# URC configuration for PP 1.2 (APREADY pin connected): +# * RING URC: normal pulse length +# * Incoming SMS URC: default pulse length +# * Other URC: default length +# * Report URCs on all ports (serial and USB) for FOSS firmware +# * Reporting of URCs without any delay +# * Configure URC pin to UART Ring Indicator + { cmd = "QCFG", subcmd = "urc/ri/ring", expect = "\"pulse\",120,1000,5000,\"off\",1" }, + { cmd = "QCFG", subcmd = "urc/ri/smsincoming", expect = "\"pulse\",120,1" }, + { cmd = "QCFG", subcmd = "urc/ri/other", expect = "\"off\",1,1" }, + { cmd = "QCFG", subcmd = "urc/delay", expect = "0" }, + { cmd = "QCFG", subcmd = "urc/cache", expect = "0" }, + { cmd = "QCFG", subcmd = "urc/ri/pin", expect = "uart_ri" }, + { cmd = "QURCCFG", subcmd = "urcport", expect = "\"all\"" }, +# Allow sleeping for power saving + { cmd = "QSCLK", value = "1" }, +# GNSS configuration: +# * Enable A-GPS data upload support (XTRA) +# * Disable On-Demand-Positioning (ODP) mode +# to avoid running the GNSS system in the background, even when not enabled. +# * Enable Dynamic Power Optimizations (DPO) mode to turn off GNSS RF radios +# when they are not in use. +# * Only enable GPS and GLONASS, disable other GNSS systems. +# A-GPS data upload doesn't work for Galileo anyway. +# * Avoid turning on GNSS support automatically when the modem boots. + { cmd = "QGPSXTRA", expect = "1" }, + { cmd = "QGPSCFG", subcmd = "gnssconfig", expect = "4" }, + { cmd = "QGPSCFG", subcmd = "odpcontrol", expect = "0" }, + { cmd = "QGPSCFG", subcmd = "dpoenable", expect = "1" }, + { cmd = "QGPSCFG", subcmd = "gpsnmeatype", expect = "31" }, + { cmd = "QGPSCFG", subcmd = "glonassnmeatype", expect = "7" }, + { cmd = "QGPSCFG", subcmd = "galileonmeatype", expect = "0" }, + { cmd = "QGPSCFG", subcmd = "beidounmeatype", expect = "0" }, + { cmd = "QGPSCFG", subcmd = "autogps", expect = "0" }, +# Disable fast poweroff for stability + { cmd = "QCFG", subcmd = "fast/poweroff", expect = "0" }, +# Configure sleep and wake up pin levels to active low + { cmd = "QCFG", subcmd = "sleepind/level", expect = "0" }, + { cmd = "QCFG", subcmd = "wakeupin/level", expect = "0,0" }, +# Do not enter RAMDUMP mode, auto-reset instead + { cmd = "QCFG", subcmd = "ApRstLevel", expect = "1" }, + { cmd = "QCFG", subcmd = "ModemRstLevel", expect = "1" }, +] +suspend = [ +] +resume = [ +] +reset = [ { cmd = "CFUN", value = "1,1" } ] + +[gnss] +enabled = true +url = "https://xtrapath4.izatcloud.net" +file = "xtra2.bin" diff --git a/src/gpio.c b/src/gpio.c index f9e707c..49bee0d 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -170,6 +170,8 @@ int gpio_init(struct EG25Manager *manager, toml_table_t *config[]) if (!data.ok) continue; manager->gpiochip[i] = gpiod_chip_open_by_label(data.u.s); + if (!manager->gpiochip[i]) + g_error("Unable to find GPIO chip '%s'", data.u.s); } for (i = 0; i < GPIO_OUT_COUNT; i++) { @@ -184,7 +186,7 @@ int gpio_init(struct EG25Manager *manager, toml_table_t *config[]) line = toml_int_in(table, "line"); if (!line.ok || line.u.i < 0 || line.u.i > gpiod_chip_num_lines(manager->gpiochip[chip.u.i])) - g_error("Wrong chip ID for output GPIO '%s'", gpio_out_names[i]); + g_error("Wrong line ID for output GPIO '%s'", gpio_out_names[i]); manager->gpio_out[i] = gpio_get_output_line(manager, chip.u.i, line.u.i); if (!manager->gpio_out[i]) @@ -203,7 +205,7 @@ int gpio_init(struct EG25Manager *manager, toml_table_t *config[]) line = toml_int_in(table, "line"); if (!line.ok || line.u.i < 0 || line.u.i > gpiod_chip_num_lines(manager->gpiochip[chip.u.i])) - g_error("Wrong chip ID for input GPIO '%s'", gpio_in_names[i]); + g_error("Wrong line ID for input GPIO '%s'", gpio_in_names[i]); manager->gpio_in[i] = gpio_get_input_line(manager, chip.u.i, line.u.i); if (!manager->gpio_in[i]) @@ -214,16 +216,12 @@ int gpio_init(struct EG25Manager *manager, toml_table_t *config[]) /* Legacy config file, only used on the OG PinePhone */ manager->gpiochip[0] = gpiod_chip_open_by_label(GPIO_CHIP1_LABEL); - if (!manager->gpiochip[0]) { - g_critical("Unable to open GPIO chip " GPIO_CHIP1_LABEL); - return 1; - } + if (!manager->gpiochip[0]) + g_error("Unable to open GPIO chip " GPIO_CHIP1_LABEL); manager->gpiochip[1] = gpiod_chip_open_by_label(GPIO_CHIP2_LABEL); - if (!manager->gpiochip[1]) { - g_critical("Unable to open GPIO chip " GPIO_CHIP2_LABEL); - return 1; - } + if (!manager->gpiochip[1]) + g_error("Unable to open GPIO chip " GPIO_CHIP2_LABEL); for (i = 0; i < GPIO_OUT_COUNT; i++) { if (!config_get_uint(gpio_config, gpio_out_names[i], &gpio_idx))