Commit graph

18 commits

Author SHA1 Message Date
Fabio Baltieri
5b1b874206 regulator: shell: add device name completion
Add the code for the shell to complete the device name in the regulator
commands.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-21 10:56:12 +02:00
Fabio Baltieri
d55ea3aa72 drivers: regulator: shell: add a shipmode command
Add a shipmode regulator shell command to test shipmode on regulators.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2023-08-14 18:11:36 +00:00
Martin Kiepfer
4da1518108 regulator: shell: fix unitialized variable warning from SCA
Static code analysis it has highlighted that a variable is beeing
accessed before initializing. This is a very minor fix
to resolve this potential issue.

Signed-off-by: Martin Kiepfer <mrmarteng@teleschirm.org>
2023-07-07 10:51:53 +02:00
Daniel DeGrasse
bd1cf25821 drivers: regulator: regulator_shell: add command to set DVS mode
Add command to set DVS mode, to aid in testing regulators that expose
this functionality. Since DVS modes are device specific, take an integer
as the mode identifier and pass it to the driver directly.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2023-06-17 07:59:26 -04:00
Gerard Marull-Paretas
e59e38532a drivers: regulator: shell: fix fp number parsing
Parser did not handle decimals correctly (multiplier was not decreased).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-01-16 16:52:35 +01:00
Gerard Marull-Paretas
24f2c30678 drivers: regulator: shell: fix isdigit() usage
ISO/IEC 9899:1999 (C Standard), §7.4 Character handling <ctype.h>:

In all cases the argument is an int, the value of which shall be
representable as an unsigned char or shall equal the value of the macro
EOF. If the argument has any other value, the behavior is undefined.

So add a cast to unsigned char to make sure we do not trigger UB.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-01-04 11:19:25 +01:00
Gerard Marull-Paretas
ea7293e464 drivers: regulator: shell: fix printing of first voltage
The first supported voltages was not printed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-27 16:50:36 +00:00
Gerard Marull-Paretas
2c9a9c3671 drivers: regulator: shell: refactor shell
- Refactor the regulator shell so that it exposes all regulator APIs
- vset/iset commands allow to specify a single value (equal min/max) or
  a range
- Voltage/current input is now more user friendly, e.g. user can specify
  units and decimals: 3.3v, 200mv, -4mv, etc.
- Reported values are also printed in a more user friendly way, e.g.
  1800000 uV will be printed as 1.800 V.
- Added new command to list supported voltages

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-27 13:12:55 +01:00
Gerard Marull-Paretas
2bd6d50934 drivers: regulator: improve regulator_get_current_limit
- Function returns now the value by reference, similar to voltage
  counterparts.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-14 17:01:44 +01:00
Gerard Marull-Paretas
3d47b6dfba drivers: regulator: improve regulator_get_voltage
- Function now returns error, value is obtained by reference. This
  allows to propagate potential bus errors.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-14 17:01:44 +01:00
Gerard Marull-Paretas
b909d0e560 drivers: regulator: drop mode specific APIs
- Mode specific APIs repeat the same functionality offered by non-mode
  specific APIs
- The same functionality can be achieved by the non-mode APIs, since
  they apply to the active mode which can be set using
  regulator_set_mode() first.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-12-14 17:01:44 +01:00
Daniel DeGrasse
95d8943c69 drivers: regulator: support for regulator mode APIs in regulator shell
Add support for regulator mode related APIs to regulator shell, so that
the user can select new operation modes for the regulator and configure
target voltages

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-12-04 19:56:34 +01:00
Daniel DeGrasse
9d1bcc6126 drivers: regulator: cleanup device_is_ready and atoi usage
Cleanup regulator shell to use strtol() over atoi(), as strtol features
error detection. Remove device_is_ready() checks, and replace them with
NULL checks as device_get_binding() calls device_is_ready() interally

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-12-04 19:56:34 +01:00
Gerard Marull-Paretas
a29bdc262c drivers: regulator: drop async enable
Drop the async enable function. This feature is rarely/never used,
complicates driver design, and doesn't really follow the sync/async API
design/naming used in other areas. In the future we can introduce
regulator_enable_async if needed, with support from the driver class (no
onoff). Note that drivers like PCA9420 did not implement any
asynchronous behavior. regulator-fixed implemented in the past
asynchronous behavior using work queues, an overkill for most GPIO
driven regulators. Let's keep things simple for now and extend the API
when needed, based on specific usecases.

In the current implementation, reference counting is managed by the
driver class. \isr-ok attribute is dropped, since calls are potentially
blocking. Note that drivers like PCA9420 already violated such rule.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-30 15:49:30 +01:00
Jamie McCrae
2b472e2d20 drivers: regulator: regulator_shell: Fix missing include
Fixes a missing include for the atoi() function.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2022-11-17 00:34:34 +09:00
Gerard Marull-Paretas
6dd395ddeb drivers: regulator: shell: drop PMIC conditional options
The regulator API supports all voltage/current ops, so there's no need
to guard them under "PMIC". If a particular driver doesn't support the
operations it will just return -ENOSYS and the command will fail.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-14 16:59:05 +01:00
Gerard Marull-Paretas
74e40f88ae drivers: regulator: move consumer.h to regulator.h
In Zephyr all regulator APIs are consumer APIs. There's no point in
adding a separate header file. Our current implementation is also
inconsistent with Linux, where enable/disable are also part of the
consumer.h API.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-11-14 16:59:05 +01:00
Daniel DeGrasse
9d7039f9e9 drivers: regulator: add regulator shell
Add shell for interacting with regulator devices, to enable
users to test power management settings quickly and verify that their
regulator is functioning as expected. Also allows users to interact with
regulator PMIC devices

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-10-10 13:13:27 -05:00