Skip to content

Rework cdba to support controlling device via external program - #9

Merged
konradybcio merged 6 commits into
linux-msm:masterfrom
lumag:external
Oct 23, 2023
Merged

konradybcio merged 6 commits into
linux-msm:masterfrom
lumag:external

Conversation

@lumag

@lumag lumag commented Dec 20, 2021

Copy link
Copy Markdown
Contributor

Here are the changes that I have here to allow controlling devices through the external script.

@lumag

lumag commented Sep 30, 2022

Copy link
Copy Markdown
Contributor Author

@andersson gracious ping

@lumag

lumag commented Mar 2, 2023

Copy link
Copy Markdown
Contributor Author

Rebased on top of current master branch.
@andersson any hope to hear response from you?

@lumag
lumag force-pushed the external branch 2 times, most recently from 3e2b372 to 165adac Compare September 23, 2023 13:56
@lumag
lumag marked this pull request as draft September 23, 2023 14:38
@lumag
lumag force-pushed the external branch 2 times, most recently from 19e598d to 5626b18 Compare September 23, 2023 14:49
@lumag
lumag marked this pull request as ready for review September 23, 2023 14:51

@superna9999 superna9999 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last patch fixes the external support or fixes in all cases ? If it fixes all cases it should got in a separate or right ?

Comment thread external.c Resolved
Comment thread device.h Resolved
@lumag

lumag commented Sep 23, 2023

Copy link
Copy Markdown
Contributor Author

The last patch fixes the external support or fixes in all cases ? If it fixes all cases it should got in a separate or right ?

It is a generic fix, but I stumbled upon it only with the "external" driver, since other drivers do not output a lot.

@kcxt

kcxt commented Sep 24, 2023

Copy link
Copy Markdown
Member

Is it possible to combine this with the qcomlt debug board? For the phones I have a Pi Pico exposing a compatible serial control interface, but for USB VBUS I need to use PPPS control...

@lumag

lumag commented Sep 24, 2023

Copy link
Copy Markdown
Contributor Author

@calebccff here is (an excerpt) of the script that I have here for the relays and PPPS hub:

#!/bin/sh

#set -x
set -e

if [ "$#" != 3 ]
then
	echo "Usage: $0 [board] [command] [on/off]"
	exit 1
fi

echo "Called $1 $2 $3"

case "$1" in 
	"rb5-2" )
		HUBLOC="10-1"
		HUBPORT="1"
		LAURENT="REL,1"
		;;
	"db820c-1" )
		HUBLOC="10-1"
		HUBPORT="2"
		LAURENT="REL,2"
		;;
	"rb1-1" )
		HUBLOC="10-1"
		HUBPORT="3"
		LAURENT="REL,3"
		;;

	* )
		echo "Unknown board $1"
		exit 2
esac

uhubctl() {
	sudo uhubctl -l $HUBLOC -p $HUBPORT -a $1
	if [ "$1" = "off" ] ; then
		sudo udevadm trigger --action=remove /sys/bus/usb/devices/${HUBLOC}.${HUBPORT}/ || true
	fi
}

laurent() {
	curl "http://laurent.lan/cmd.cgi?psw=$LAURENTPW&cmd=$LAURENT,$1"
}

#echo "$2-$3" >> /tmp/cdba-log

case "$2-$3" in
	"power-off" )
		uhubctl off
		#sleep 1
		laurent 0
		#sleep 1
		;;
	"power-on" )
		uhubctl off
		#sleep 1
		laurent 0
		#sleep 1
		laurent 1
		;;
	"usb-on" )
		uhubctl on
		;;
	"usb-off" )
		uhubctl off
		sleep 1
		;;
	"key-power-on" | "key-power-off" )
		# ignore
		;;
	*)
		echo "Unknown command $2-$3"
		exit 2
		;;
esac

@kcxt

kcxt commented Sep 24, 2023 •

Copy link
Copy Markdown
Member

I hooked up my pico to control the enable pin of the buck converter I have as a battery replacement, this makes all the button wrangling unecessary as I can just erase the boot partition and the devices always boot straight to fastboot mode.

There is maybe some value in this PR for someone else, but given the amount of finesse necessary to get this to work reliably, I'm not gonna stick with it... See #33

Edit: oops, I meant to leave this comment on #21

@lumag lumag mentioned this pull request Sep 28, 2023
Comment thread device.c Resolved
Dmitry Baryshkov added 4 commits October 2, 2023 17:32
Allow PPPS function even if there is no device->usb callback. PPPS is
useable even with no control interface.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Separate backend operations into control and console operations. Main
idea is that each device has single set of console ops (conmux or
console) and at most one way to control it. Each backend driver exports
a structure with the set of callbacks.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Remove headers declaring internal backends API.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Now as each backend exports data structure, mark all functions as
static.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Dmitry Baryshkov added 2 commits October 2, 2023 17:33
Control the board using external program. It will be called with 3
arguments: <board> <command> <on/off>, where command is one of "power",
"usb", "key-fastboot", "key-power".

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
If we got to device_close(), the parent SSH might have been exited,
making standard file descriptors unusable. Rebind them to /dev/null, so
that any output during device_close (both from the cdba server and the
helpers) doesn't cause SIGPIPE.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
@lumag lumag mentioned this pull request Oct 23, 2023
@konradybcio konradybcio self-assigned this Oct 23, 2023
@konradybcio
konradybcio merged commit fbdc677 into linux-msm:master Oct 23, 2023
@lumag lumag mentioned this pull request Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants