Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and
dev->config instead.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
In order to align with macros used to obtain a device reference (e.g.
DEVICE_DT_GET), align the PM macros to use "GET" instead of "REF". This
change should have low impact since no official release has gone out yet
with the "REF" macros.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Since drivers implement a callback based on action and not the state,
we should be using the API based on the action instead of the one based
on the state.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Port some drivers to the recently introduced macros to showcase its
usage and be able to do some initial testing (nRF52840).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Changed pwm_pin_set_cycles into pwm_pin_set_nsec
to decrease power consumption. Changed default
value for period to 100000. There is no need in having
period for pwm leds equal to 100 cycles as human eye has ~100 fps.
Signed-off-by: Jan Zyczkowski <jan.zyczkowski@nordicsemi.no>
PCA9633 driver does not cunnetly support multiple devices.
Updated the driver to use DT_INST_FOREACH_STATUS_OKAY to
configure all devices defined in the device tree.
Convert driver to use `i2c_dt_spec` helpers.
Fixes#40076
Signed-off-by: Daniel N. Hansten <dnh2000@gmail.com>
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Change format in various shell_error calls from int to long unsigned
int.
Warning:
warning: format '%d' expects argument of type 'int', but argument
6 has type 'long unsigned int'
Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
A single PWM driver can be used for multiple LED numbers. In that
case -EALREADY may be reported. It should be ignored.
Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
drivers, but better take off with consistency in place after current
changes).
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The device PM control function will only be called if the requested
state is different from the current one. A significant amount of drivers
were checking for state changes, now unnecessary. This patch removes all
this redundant logic.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Since the state is no longer modified by the device PM callback, just
use the state value.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The callback is now invoked to set the device PM state in all cases, so
the usage of ctrl_command is redundant.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
The device PM subsystem already holds the device state, so there is no
need to keep duplicates inside the device. The pm_device_state_get has
been refactored to just return the device state. Note that this is still
not safe, but the same applied to the previous implementation. This
problem will be addressed later.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Add support for TI TLC59108 an I2C 8-bit LED driver.
Supported blinkink period: 41ms to 10730ms
Supported brightness value: 0 to 100%
This driver supports the following APIs:
1. led_blink
2. led_set_brightness
3. led_on
4. led_off
This is a modified version of the NXP PCA9633 driver.
Signed-off-by: John Kjellberg <kjellberg.john@gmail.com>
Driver does not correctly take ic out from sleep mode on init.
Added logic to update mode register on init to take the leddriver
out from sleep mode.
See datasheet for register details.
Fixes#37180
Signed-off-by: Daniel N. Hansten <dnh2000@gmail.com>
The callback is not used anymore, so just delete it from the pm_control
callback signature.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
the device PM callback is not used anymore by the device PM subsystem,
so remove it from all drivers/tests using it.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.
All drivers and tests have been adjusted accordingly.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
Reprocess keyscan event processing in case of an I2C bus read
error. Otherwise, the HT16K33 will be stuck (when used in IRQ mode, not
in polling mode) and no new IRQs will be delivered.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
Convert the keyscan portion of the Holtek HT16K33 driver to adhere to
the kscan API instead of the GPIO API.
When this driver was introduced the kscan API was not present. The
keyscan driver was therefore implemented as a GPIO interrupt driver.
Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
If the label property is missing in a "pwm-leds" compatible DT node
(which is almost always the case), then the device name is now set to
DT_NODE_FULL_NAME instead of "LED_PWM_$inst" previously.
This allows applications to use the DEVICE_DT_NAME macro to retrieve
the device name instead of gessing an arbitrary string.
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
Two minor tweaks and a semantics change:
- fix a whitespace nit
- use gpio_pin_configure_dt()
- turn the LED on in case the percentage is nonzero
The last change patterns this driver after behavior in the Android
lights HAL, which recommends analogous behavior when the user requests
a color change in a non-RGB LED:
Do your best here. [...] If you can only do on or off, 0 is off,
anything else is on.
https://source.android.com/reference/hal/structlight__state__t
I think this behavior makes more sense.
Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
Convert LED PWM driver to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Convert led drivers to use new DT variants of the DEVICE APIs.
DEVICE_AND_API_INIT -> DEVICE_DT_DEFINE
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
This driver supports the PWM driven LEDs. The devices are created from
the DT nodes with a compatible property matching "pwm-leds". For each
child node a LED is created and its "pwms" phandle's node is used to
retrieve the PWM configuration: channel, period and flags. If some of
this properties are missing (it is the case for some PWM controllers),
then reasonable default values are used.
This driver implements the following LED API methods:
- led_on
- led_off
- led_blink
- led_set_brightness
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
HAS_DTS_I2C is now selected by I2C and
always used as I2C && HAS_DTS_I2C.
It could then be purely removed.
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.
A coccinelle rule is used for this:
@r_const_dev_1
disable optional_qualifier
@
@@
-struct device *
+const struct device *
@r_const_dev_2
disable optional_qualifier
@
@@
-struct device * const
+const struct device *
Fixes#27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This patch introduces the "led" shell command. This allows to run the
LED API functions (and to test the LED drivers) from the Zephyr shell.
The following subcommands are supported:
- on
- off
- get_info
- set_brightness
- set_color
- set_channel
- write_channels
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>
This patch adds support for the Texas Instruments LP5030 and LP5036
I2C LED controllers. They are respectively providing up to 30 and 36
channels (i.e. 10 or 12 RGB LEDs).
In addition to the channel/color registers this LED controller provides
a per-LED brigthness register. This driver implements both LED-based and
channel-based API methods:
- led_on
- led_off
- led_get_info
- led_set_brightness
- led_set_color
- led_set_channel
- led_write_channels
Signed-off-by: Simon Guinot <simon.guinot@seagate.com>