Commit Graph

36 Commits

Author SHA1 Message Date
Bjorn Andersson
81e46878ed cdba-server: Allow external status command
While the CDB Assist and QcomLT Debugboard is measuring voltage and
current on the DC jack directly in the backend, other backends and
further measurements can be performed using custom tooling.

Introduce support for invoking an external "status-cmd" to produce such
status updates.

The status command should on its stdout produce json-formatted status
updates following the same format as the cdba-server:

  {"ts":%d.%03d, "name": {["mv"|"ma"]: %u}(, "name2": {["mv"|"ma"]: %u})*}

with the ts aquired using clock_gettime(CLOCK_MONOTONIC) and provided in
seconds and milliseconds since the first measurement.

Signed-off-by: Bjorn Andersson <quic_bjorande@quicinc.com>
2023-11-27 21:19:57 -06:00
Neil Armstrong
a2ae5974ed ftdi_gpio: accept new yaml config
Now local_gpio has landed, also accept a more verbose
and cleaner yaml config syntax for ftdi_gpio.

For now keep support for the current configuration string.

Closes: #42

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-11-02 18:18:18 +01:00
Dmitry Baryshkov
bb653da577 ppps: add support for separate USB-3 PPPS path
Some devices / hubs require switching both USB-2 and USB-3 ports to
function correctly. Add ppps3_path device option to control USB-3 port
in addition to the USB-2 port.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-10-30 17:21:02 +02:00
Neil Armstrong
87fbc38286 Add local gpio control
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>
2023-10-30 16:16:36 +01:00
Neil Armstrong
55902b7ba9 Export device_parser struct and functions
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>
2023-10-30 16:00:40 +01:00
Dmitry Baryshkov
310004badb external: control the board using external program
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>
2023-10-02 17:33:13 +03:00
Dmitry Baryshkov
3b089f313e device: separate backend operations
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>
2023-10-02 17:33:10 +03:00
Caleb Connolly
91daddcb7c support ppps usb control
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>
2023-09-28 11:09:46 +01:00
Dmitry Baryshkov
3ea8df6c70 device: implement access control to the boards
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>
2023-09-23 16:50:11 +03:00
Dmitry Baryshkov
327da0b5b5 device: support specifying active slot
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>
2023-09-21 13:35:04 +03:00
Krzysztof Kozlowski
c7e7a81a6c device_parser: fix -Wformat=
Fixes:

  device_parser.c: In function ‘nextsym’:
  device_parser.c:53:56: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘unsigned int’ [-Wformat=]
     53 |                 fprintf(stderr, "device parser: error %d\n", dp->parser.error);
        |                                                       ~^     ~~~~~~~~~~~~~~~~
        |                                                        |               |
        |                                                        int             unsigned int
        |                                                       %d
  device_parser.c: In function ‘expect’:
  device_parser.c:80:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘unsigned int’ [-Wformat=]
     80 |         fprintf(stderr, "device parser: expected %d got %d\n", type, dp->event.type);
        |                                                         ~^           ~~~~~~~~~~~~~~
        |                                                          |                    |
        |                                                          int                  unsigned int

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Neil Armstrong
4f4f1704bb Add generic ftdi GPIO backend
This permits driving a board controlled by GPIOs on an FTDI
interface.

Also add a sample 99-libftdi.rules to permit using the FTDI device.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-01-30 16:00:46 -06:00
Bjorn Andersson
c43466a98f device: Invoke device->close on exit
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>
2021-01-25 18:48:04 -06:00
Bjorn Andersson
7b89bf40ec qcomlt_debug: Introduce support for the QcomLT debug board
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-01-22 19:57:37 -06:00
Bjorn Andersson
d947ca9d46 device: Move alpaca power key state machine to device
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>
2021-01-22 19:57:14 -06:00
Bjorn Andersson
1abac8b200 device: Combine power_on/power_off througout
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>
2021-01-22 18:52:03 -06:00
Bjorn Andersson
3921fcb8a3 cdb_assist: Drop all the USB magic
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>
2021-01-22 18:13:38 -06:00
Bjorn Andersson
032a43b7ee conmux: Use "control_dev" instead of "cdb_serial"
It seems more suitable to use the "control_dev" to denote the target
conmux than "cdb_serial". Further more this makes it possible drop the
"cdb_serial" member in an upcoming commit.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-01-22 18:07:26 -06:00
Bjorn Andersson
87ad99ecf2 alpaca: Rename device member holding control device path
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>
2021-01-22 18:06:26 -06:00
Bjorn Andersson
776f8c30fb console: Add send_break support
Add support for send_break to the generic console implementation.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-01-22 18:04:58 -06:00
Bjorn Andersson
e685d367bc alpaca: Add configuration for keeping USB always connected
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>
2021-01-22 17:26:17 -06:00
Dmitry Baryshkov
b626f41185 device: support working in non-automated setup
Make device power controller optional, allowing one to use cdba in
non-automated setup (just simplifying the fastboot + console handling).

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
[bjorn: Rebased the patch onto master, reversed the logic in power_on/off]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-11-16 14:19:07 -06:00
Bjorn Andersson
7dbd49c4d2 device: Add fastboot_key_timeout
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>
2020-10-29 18:18:56 -05:00
Bjorn Andersson
0d7ff9e782 alpaca: Hold volume down during boot
For some devices to reliably boot into fastboot mode volume down needs
to be held, so do this as we power on the device and release it as
fastboot appears.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-10-19 11:59:19 -05:00
Dmitry Baryshkov
793969b11d device: split console_fd handling away
Split console_fd handling to a separate source file to simplify
device.c.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2020-09-28 10:27:18 -05:00