This driver permits controlling local (on the system) gpios
by using the libgpiod library.
Support for gpiod v1 and v2 is added, and parses the options
via the yaml parser.
This can be tested with the gpio-sim module:
https://docs.kernel.org/admin-guide/gpio/gpio-sim.html
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Export the functions and struct to enable devices to parse
yaml aswell via the parse_options op to be stored in the
device control_options device property.
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
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>
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>
Since Linux kernel 6.0, PPPS capable USB hubs expose a simple sysfs
attribute for power control. Allow overwriting the usb control callback
to use PPPS hub control instead.
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Limit access control to the boards according to the passed username. If
the user has no access, the board becoms completely invisible: it is not
listed, it is not possible to fetch board description, etc.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
For different reasons it might be desirable to keep slot 'b' as an
active slot. Add support for specifying the active slot in the config
file. The default is still slot 'a'.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Allow the control device to implement things such as flushing the
command buffer as part of the close operation. This used to be done to
ensure that any lingering power/usb off requests really where sent to
the device as we closed the control tty.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
As cdba-server exits it turns off power, which used to cut VBUS as well,
but since the refactoring only cuts power. Reintroduce the VBUS toggle
to ensure the device doesn't stay powered through USB after use.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
The power key dance is useful outside of alpaca, move it to device and
modify the device interface to better suite this.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Squash the power_on and power_off into a single "power" function, to
harmonize the code wrt the USB handling.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Some ancient device needed us to pull PSHOLD to trigger the shutdown,
but most of the code is lost, so clean out the last pieces until the
need comes up again.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
All modern systems will properly populate /dev/serial/by-id with links
to the CDB Assist control and target tty, that includes the serial
number in the name.
So there's no reason to keep the complex code that scans for the two
devices by serial number around.
Switch the parameter of "cdb_assist" to be the path of the control tty
and rely on "console" for the "terminal" tty.
Naturally this breaks existing config files.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
By renaming the "alpaca_dev" to "control_dev" is can be reused in the
other implementations as well.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
USB on the Primus acts up when we toggle USB in Alpaca, so add a
configuration option to force it on at all times.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Make the fastboot key handling a property of the device configuration
and use the newly introduced timeout mechanism for handling it.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Add a new keyword "description" to the config file, add the necessary
wire protocol to acquire this string for a given device and introduce
the "-i" option to cdba to trigger its retrieval.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Add a new argument '-l' which in combination with '-h' will connect to
said server and list the attached devices, then exit.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
It's possible for devices that are automated using e.g. a CDB Assist to
have console coming over a separate FTDI USB tty. Move the alpaca
specific implementation of the "console" directive to device.c to make
it generic.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
For some devices it's not possible to use fastboot boot and
as such they will not enter fastboot unless the fastboot key
is held. Expose this functionality in the device api.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
In order to support multiple control boards make all operations follow
indirections in the device context.
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>