Commit graph

55 commits

Author SHA1 Message Date
Chen Xingyu 979cd1dfe8 drivers: display: st7789v: Add support to disable inversion mode
For historical reasons, inversion mode is enabled by default in the
current implementation. This commit introduces an `inversion-off`
boolean DTS property, allowing it to be disabled if necessary.

Signed-off-by: Chen Xingyu <hi@xingrz.me>
2024-04-29 11:02:20 +02:00
Marcus Folkesson cbae54c7f7 drivers: display: remove dummy functions for unsupported API
As the display API now check against valid callback functions and
returns -ENOSYS (or equalent), there is no need to provide
such functions in the driver code

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
2023-12-11 09:56:42 +01:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Bartosz Bilas e077fb73ec drivers: tests: replace usage of spi_is_ready with spi_is_ready_dt
`spi_is_ready` function is being deprecated in favor of
`spi_is_ready_dt` so let's replace the old usage in the tree.

Signed-off-by: Bartosz Bilas <bartosz.bilas@hotmail.com>
2022-12-07 09:40:23 -06:00
Pieter De Gendt 8bef504163 drivers: display: st7789v: Support 3-line serial interface
The sitronix ST7789V serial interface can operate with 3- or 4-line
protocol.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2022-07-06 10:42:15 +02:00
Gerard Marull-Paretas fb60aab245 drivers: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Casper Meijn c33d1b55f8 drivers: display: st7789v: Add multi-instance support
Replace the config and data struct with a macro. Execute the macro
for each instance.

Signed-off-by: Casper Meijn <casper@meijn.net>
2022-04-06 10:58:26 +02:00
Casper Meijn ac9cd9e89a drivers: display: st7789v: Remove compile time reset selection
Replace the compiletime `#if` with a runtime decision. This makes
a multi-instance driver possible.

Signed-off-by: Casper Meijn <casper@meijn.net>
2022-04-06 10:58:26 +02:00
Casper Meijn 7f5c5cf317 drivers: display: st7789v: Move params to struct config
Move the const configuration parameters to `struct st7789v_config`.

Signed-off-by: Casper Meijn <casper@meijn.net>
2022-04-06 10:58:26 +02:00
Casper Meijn 2eb1feea91 drivers: display: st7789v: fix gpio_dt_spec initialization
The `gpio_dt_spec` structures where never initialised, therefore the driver
would always fault with "E: Reset GPIO device not ready" printed to the
console.

Fixes: 069bf6be44
("drivers: display: st7789v: use gpio_dt_spec")

Signed-off-by: Casper Meijn <casper@meijn.net>
2022-03-01 14:38:21 -06:00
Gerard Marull-Paretas 069bf6be44 drivers: display: st7789v: use gpio_dt_spec
Simplify driver implementation by using gpio_dt_spec.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-21 22:16:10 -05:00
Gerard Marull-Paretas 065f8645fb drivers: display: st7789v: use spi_dt_spec
Simplify driver implementation by using spi_dt_spec.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-21 22:16:10 -05:00
Gerard Marull-Paretas 83cccdf757 drivers: display: st7789v: fix function argument
The st7789v_transmit function accepts a device, not device data. As a
result, driver could not be compiled when reset GPIOs were not defined
in Devicetree.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-02-08 07:31:07 -05:00
Gerard Marull-Paretas ddc168fa78 pm: s/PM_DEVICE_(DT_(INST))_REF/PM_DEVICE_(DT_(INST))_GET
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>
2022-01-18 12:14:06 -05:00
Casper Meijn 2b618bdb5c drivers: display: st7789v: Use device * for internal functions
The internal functions of this driver needed either `device *`
or `st7789v_data *` as argument. Standardize to
using `device *`.

Signed-off-by: Casper Meijn <casper@meijn.net>
2021-12-07 09:38:43 -06:00
Casper Meijn 7dfdaf4ab7 drivers: display: st7789v: Remove explicit cast
Remove explicit cast of `data`.

Signed-off-by: Casper Meijn <casper@meijn.net>
2021-12-06 08:04:26 -05:00
Casper Meijn 889ab9107e drivers: display: st7789v: Make naming consistent
The names of `struct st7789v_data` varied a bit in the driver code.
Make the name consistently `data`.

Signed-off-by: Casper Meijn <casper@meijn.net>
2021-11-29 16:29:55 +01:00
Gerard Marull-Paretas 89a4f36fc8 device: remove inclusion of pm/device.h
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>
2021-11-29 11:08:38 +01:00
Gerard Marull-Paretas 88a69674c0 drivers: use new PM macros
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>
2021-11-19 10:11:32 +01:00
Gerard Marull-Paretas 4baf1e01ff drivers: use common PM action callback naming
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>
2021-11-03 20:27:18 -04:00
Gerard Marull-Paretas f647a5c8ec drivers: display: st7789v: remove incorrect error check
The st7789v_transmit function does not return any error code (void), so
ret = st7789v_transmit(...) is wrong.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-09-27 08:24:21 -04:00
David Leach 3ea7fbc662 display: st77xx: Move initialization to POST_KERNEL
These are the only two display drivers initializing in APPLICATION.
Dependency exposed with LVGL with initialization at same level and
priority.

Fixes #38690

Signed-off-by: David Leach <david.leach@nxp.com>
2021-09-21 19:42:36 -04:00
Daniel Leung 8b8e8f99ba display: introduce CONFIG_DISPLAY_INIT_PRIORITY
This introduces a new kconfig CONFIG_DISPLAY_INIT_PRIORITY
to specify the initialization priority for display devices.
Most of the display devices are using APPLICATION and
CONFIG_APPLICATION_INIT_PRIORITY which is not entirely
appropriate for devices. Due to linking order, the display
device may be initialized after application code at same
init level and priority. This results in the display device
not ready to be used for application code. So this kconfig
option allows the display devices to be initialized earlier
if needed.

For the drivers using CONFIG_APPLICATION_INIT_PRIORITY,
they have been changed to use CONFIG_DISPLAY_INIT_PRIORITY
instead.

Note that the default value for CONFIG_DISPLAY_INIT_PRIORITY
is the same as CONFIG_APPLICATION_INIT_PRIORITY at 90 to
avoid any functional changes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-12 17:00:39 +02:00
Gerard Marull-Paretas 7ccc1a41bc pm: use actions for device PM control
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>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 495672ab62 pm: cleanup pm control callback implementations
- 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>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 11eef4d8c8 pm: device: remove pointer usage for state
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>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 9e7d545bb4 pm: device: remove ctrl_command callback argument
The ctrl_command is not used anymore, so remove it from the callback
signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas da0ff4ae46 pm: device: remove usage of ctrl_command
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>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas c2cf1ad203 pm: device: remove usage of local states
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>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
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>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas 217e610d8f pm: remove redundant callback usage
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>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas cc2f0e9c08 pm: use enum for device PM states
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>
2021-07-07 14:13:12 -04:00
Flavio Ceolin 0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin 7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Gerard Marull-Paretas 56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas dbf46b3815 pm: rename device_pm_cb to pm_device_cb
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Kumar Gala bdb773c1c4 drivers: display: Convert drivers to new DT device macros
Convert display drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
    DEVICE_DEFINE -> DEVICE_DT_INST_DEFINE
    DEVICE_GET -> DEVICE_DT_INST_GET

etc..

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-16 12:18:02 -05:00
Anas Nashif dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Kumar Gala b4a3880a75 drivers: remove unnecessary use of DEVICE_AND_API_INIT
For drivers that support CONFIG_DEVICE_POWER_MANAGEMENT there are some
cases that look like:

  #ifdef CONFIG_DEVICE_POWER_MANAGEMENT
    DEVICE_DEFINE()
  #else
    DEVICE_AND_API_INIT()
  #endif

There is no need to special case this as the pm_control_fn argument to
DEVICE_DEFINE will just be ignored in the
!CONFIG_DEVICE_POWER_MANAGEMENT case.  So we can cleanup the code a
little and remove the #else cases for the drivers that do this.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-11-06 09:42:47 -06:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
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>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Jordan Yates 26f83a0f1e display: st7789v: Add chip select flags
Adds the chip select devicetree flags to the spi_cs_control instance.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-07-01 16:40:03 -05:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Albin Söderqvist 35c4838425 drivers: display: st7789v: add power management support
This adds sleep mode along with power managament control.

Signed-off-by: Albin Söderqvist <albin.soderqvist@endian.se>
2020-05-09 13:07:17 +02:00
Marc Reilly eeedc828ae drivers: display: st7789v: set x-offset and y-offset properties properly
This sets the x-offset and y-offset info from the dts

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2020-04-15 08:25:19 -05:00
Marc Reilly de2f2cd14f drivers: display: st7789v: move PORCTRL setup to after CMD2EN
The PORCTRL setting command is in 'bank2' and so might not be changed on
the controller unless bank2 is enabled first.

Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
2020-04-15 08:25:19 -05:00
Kumar Gala 09b1cd90d8 drivers: display: st7789v: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 16:55:28 -05:00
Johann Fischer c671b75e13 drivers: st7789v: convert to new GPIO API
Convert ST7789V display driver to new GPIO API.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-02-05 12:00:36 +01:00
Johann Fischer f6807df469 drivers: display_st7789v: obtain panel settings and parameters from DT
Obtain panel settings and parameters from DT.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2020-01-02 17:00:06 -05:00