diff --git a/kernel/configs/vamos.config b/kernel/configs/vamos.config index eb5c392..f359ba9 100644 --- a/kernel/configs/vamos.config +++ b/kernel/configs/vamos.config @@ -83,12 +83,6 @@ CONFIG_SENSORS_INA2XX=y CONFIG_TOUCHSCREEN_EDT_FT5X06=y CONFIG_TOUCHSCREEN_S6SY761=y -# GPIO -# TODO: migrate gpio.sh, lte.sh, and power_drop_monitor.py to chardev (libgpiod) -# and remove GPIO_SYSFS (deprecated) -CONFIG_EXPERT=y -CONFIG_GPIO_SYSFS=y - # EROFS CONFIG_EROFS_FS=y CONFIG_EROFS_FS_ZIP=y diff --git a/kernel/dts/sdm845-comma-mici.dts b/kernel/dts/sdm845-comma-mici.dts index 6808794..e3f8938 100644 --- a/kernel/dts/sdm845-comma-mici.dts +++ b/kernel/dts/sdm845-comma-mici.dts @@ -54,3 +54,158 @@ remote-endpoint = <&panel_in>; data-lanes = <0>; }; + +&tlmm { + gpio-line-names = "", /* GPIO_0 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_10 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_20 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_30 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_40 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "LTE_RST_N", /* GPIO_50 */ + "", + "LTE_BOOT", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_60 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_70 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_80 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_90 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_100 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_110 */ + "", + "", + "", + "", + "", + "LTE_PWRKEY", + "", + "", + "", + "", /* GPIO_120 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_130 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_140 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + ""; /* GPIO_150 */ +}; + diff --git a/kernel/dts/sdm845-comma-tizi.dts b/kernel/dts/sdm845-comma-tizi.dts index e6aaa00..904c3d1 100644 --- a/kernel/dts/sdm845-comma-tizi.dts +++ b/kernel/dts/sdm845-comma-tizi.dts @@ -66,3 +66,158 @@ remote-endpoint = <&panel_in>; data-lanes = <0 1 2 3>; }; + +&tlmm { + gpio-line-names = "", /* GPIO_0 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_10 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_20 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_30 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_40 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "LTE_RST_N", /* GPIO_50 */ + "", + "LTE_BOOT", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_60 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_70 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_80 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_90 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_100 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_110 */ + "", + "", + "", + "", + "", + "LTE_PWRKEY", + "", + "", + "", + "", /* GPIO_120 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_130 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", /* GPIO_140 */ + "", + "", + "", + "", + "", + "", + "", + "", + "", + ""; /* GPIO_150 */ +}; + diff --git a/tools/build/Dockerfile b/tools/build/Dockerfile index e52e870..bfef113 100644 --- a/tools/build/Dockerfile +++ b/tools/build/Dockerfile @@ -83,7 +83,7 @@ RUN mkdir -p /root/.config # Enable runit services RUN for svc in \ - ipa_fws brightnessd fs_setup gpio init-qcom lte \ + ipa_fws brightnessd fs_setup init-qcom lte \ avahi-ssh-publish power_monitor power_drop_monitor \ screen_calibration serial-hostname \ sound varwatch busybox-ntpd \ diff --git a/userspace/base_setup.sh b/userspace/base_setup.sh index 982688c..1c61b5a 100755 --- a/userspace/base_setup.sh +++ b/userspace/base_setup.sh @@ -62,7 +62,7 @@ xbps-install -y \ libarchive-devel \ libcurl-devel \ libffi-devel \ - libgpiod \ + libgpiod-tools \ liblzma-devel \ libomp-devel \ libtool \ diff --git a/userspace/root/etc/sv/gpio/finish b/userspace/root/etc/sv/gpio/finish deleted file mode 100755 index fbb5e8d..0000000 --- a/userspace/root/etc/sv/gpio/finish +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Delay restart to avoid spamming console on failure -sleep 5 diff --git a/userspace/root/etc/sv/gpio/run b/userspace/root/etc/sv/gpio/run deleted file mode 100755 index 4f293a4..0000000 --- a/userspace/root/etc/sv/gpio/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# One-shot service - run once then sleep forever -/usr/comma/gpio.sh -exec sleep infinity diff --git a/userspace/root/etc/sv/lte/run b/userspace/root/etc/sv/lte/run index 5c777a6..b8bdfb6 100755 --- a/userspace/root/etc/sv/lte/run +++ b/userspace/root/etc/sv/lte/run @@ -2,9 +2,6 @@ # lte - LTE modem management exec 2>&1 -# Wait for gpio setup to finish exporting all pins -while [ ! -f /run/gpio.ready ]; do sleep 0.1; done - # Run the lte script (stays running) /usr/comma/lte/lte.sh start diff --git a/userspace/root/usr/comma/gpio.sh b/userspace/root/usr/comma/gpio.sh deleted file mode 100755 index cb5af8e..0000000 --- a/userspace/root/usr/comma/gpio.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -source /usr/comma/gpio_base.sh - -pins=( -# 27 # SW_3V3_EN -# 25 # SW_5V_EN -30 # HUB_RST_N -49 # SOM_ST_IO -134 # ST_BOOT0 -41 # PANDA_1V8_EN_N -50 # LTE_RST_N -116 # LTE_PWRKEY -124 # ST_RST_N -34 # GPS_PWR_EN -33 # GPS_SAFEBOOT_N -32 # GPS_RST_N -52 # LTE_BOOT -) - -# PM8998 GPIO4 = INA231 POWER ALERT (not a TLMM pin, separate GPIO chip) -if [ "$PM8998_BASE" -gt 0 ]; then - POWER_ALERT_PIN=$((PM8998_BASE + 3)) - echo "POWER_ALERT (gpio$POWER_ALERT_PIN)" - echo $POWER_ALERT_PIN > /sys/class/gpio/export - until [ -d /sys/class/gpio/gpio$POWER_ALERT_PIN ]; do sleep .05; done - chown root:gpio /sys/class/gpio/gpio$POWER_ALERT_PIN/direction /sys/class/gpio/gpio$POWER_ALERT_PIN/value 2>/dev/null - chmod 660 /sys/class/gpio/gpio$POWER_ALERT_PIN/direction /sys/class/gpio/gpio$POWER_ALERT_PIN/value 2>/dev/null -fi - -for p in ${pins[@]}; do - pin=$((TLMM_BASE + p)) - echo "$p (gpio$pin)" - - # this is SSD_3v3 EN on tici - if [ "$p" -eq 41 ] && grep -q "comma tici" /sys/firmware/devicetree/base/model; then - echo "Skipping $p" - continue - fi - - echo $pin > /sys/class/gpio/export - until [ -d /sys/class/gpio/gpio$pin ] - do - sleep .05 - done - # eudev doesn't apply GROUP/MODE from udev rules to sysfs GPIO files - # like systemd-udevd does, so set permissions manually after export - chown root:gpio /sys/class/gpio/gpio$pin/direction /sys/class/gpio/gpio$pin/value 2>/dev/null - chmod 660 /sys/class/gpio/gpio$pin/direction /sys/class/gpio/gpio$pin/value 2>/dev/null -done - - -HUB_RST_N=30 -gpio $HUB_RST_N 1 - -touch /run/gpio.ready diff --git a/userspace/root/usr/comma/gpio_base.sh b/userspace/root/usr/comma/gpio_base.sh deleted file mode 100644 index 50d05a8..0000000 --- a/userspace/root/usr/comma/gpio_base.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# Get TLMM GPIO chip base (dynamic on mainline, was 0 on downstream) -TLMM_BASE=$(cat /sys/bus/platform/devices/3400000.pinctrl/gpio/*/base 2>/dev/null | head -1) -TLMM_BASE=${TLMM_BASE:-0} - -# Get PM8998 GPIO chip base (SPMI USID 0, GPIO @ 0xc000) -for chip in /sys/class/gpio/gpiochip*/; do - label=$(cat "$chip/label" 2>/dev/null) - if [[ "$label" == *"spmi"*"pmic@0"*"gpio"* ]] || [[ "$label" == *"pm8998"*"gpio"* ]]; then - PM8998_BASE=$(cat "$chip/base") - break - fi -done -PM8998_BASE=${PM8998_BASE:-0} - -function gpio { - local pin=$((TLMM_BASE + $1)) - echo "out" > /sys/class/gpio/gpio$pin/direction - echo $2 > /sys/class/gpio/gpio$pin/value -} diff --git a/userspace/root/usr/comma/lte/lte.sh b/userspace/root/usr/comma/lte/lte.sh index 7ad8e51..2a47acb 100755 --- a/userspace/root/usr/comma/lte/lte.sh +++ b/userspace/root/usr/comma/lte/lte.sh @@ -1,10 +1,4 @@ #!/bin/bash -source /usr/comma/gpio_base.sh - -HUB_RST_N=30 -LTE_RST_N=50 -LTE_BOOT=52 -LTE_PWRKEY=116 function is_modem_up { if lsusb -d "0x05c6:" >/dev/null 2>&1 || lsusb -d "0x2c7c:" >/dev/null 2>&1; then @@ -16,16 +10,16 @@ function is_modem_up { function reset { echo " Resetting..." - gpio $LTE_RST_N 1 + gpioset -t0 LTE_RST_N=1 sleep 1 - gpio $LTE_RST_N 0 + gpioset -t0 LTE_RST_N=0 } function power_button { echo " Pulsing power button..." - gpio $LTE_PWRKEY 1 + gpioset -t0 LTE_PWRKEY=1 sleep 1 - gpio $LTE_PWRKEY 0 + gpioset -t0 LTE_PWRKEY=0 } function is_online { @@ -61,7 +55,7 @@ function is_offline { } # Boot into the regular mode -gpio $LTE_BOOT 0 +gpioset -t0 LTE_BOOT=0 case "$1" in start)