drm/panel: Add MIPI DBI compatible SPI driver
Subsystems (5)
cover drm/panel: Add MIPI DBI compatible SPI driver
Hi,
This patchset adds a driver that will work with most MIPI DBI compatible SPI panels out there.
It's a follow up on 'drm/tiny/st7735r: Match up with staging/fbtft driver'[1] which aimed at making the st7735r driver work with all panels adding DT properties.
Maxime gave[2] a good overview of the situation with these displays and proposed to make a driver that works with all MIPI DBI compatible controllers and use a firmware file to provide the controller setup for a particular panel.
Noralf.
[1] https://lore.kernel.org/dri-devel/[email protected]/
[2] https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
Noralf Trønnes (3):
dt-bindings: display: add bindings for MIPI DBI compatible SPI panels drm/mipi-dbi: Add driver_private member to struct mipi_dbi_dev drm/panel: Add MIPI DBI compatible SPI driver
.../display/panel/panel-mipi-dbi-spi.yaml | 69 ++++ MAINTAINERS | 7 + drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-mipi-dbi.c | 385 ++++++++++++++++++ include/drm/drm_mipi_dbi.h | 2 + 6 files changed, 475 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml create mode 100644 drivers/gpu/drm/panel/panel-mipi-dbi.c
Signature · 1 line
2.33.0
PATCH 1/3 dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Add binding for MIPI DBI compatible SPI panels.
--- .../display/panel/panel-mipi-dbi-spi.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/panel-mipi-dbi-spi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MIPI DBI SPI Panels Device Tree Bindings + +maintainers: + - Noralf Trønnes <[email protected]> + +description: + This binding is for display panels using a MIPI DBI controller + in SPI mode. + +allOf: + - $ref: panel/panel-common.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + const: panel-mipi-dbi-spi + + model: + $ref: /schemas/types.yaml#/definitions/string + description: The name of the display panel. + + write-only: + type: boolean + description: + Controller is not readable (ie. MISO is not wired up). + + dc-gpios: + maxItems: 1 + description: | + Controller data/command selection (D/CX) in 4-line SPI mode. + If not set, the controller is in 3-line SPI mode. + + backlight: true + reg: true + reset-gpios: true + +required: + - compatible + - model + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + spi { + #address-cells = <1>; + #size-cells = <0>; + + display@0{ + compatible = "panel-mipi-dbi-spi"; + model = "sainsmart18"; + reg = <0>; + spi-max-frequency = <40000000>; + dc-gpios = <&gpio 24 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>; + write-only; + }; + }; + +...
Signature · 1 line
2.33.0
Rob Herring
maintainerRe: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Quoted 8 lines · Noralf Trønnes
Add binding for MIPI DBI compatible SPI panels.
Signed-off-by Noralf Trønnes <[email protected]>--- .../display/panel/panel-mipi-dbi-spi.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:schemas/display/panel/panel/panel-common.yaml: ignoring, error parsing file
make[1]: *** Deleting file 'Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.example.dt.yaml' schemas/display/panel/panel/panel-common.yaml: ignoring, error parsing file
Traceback (most recent call last):
File "/usr/local/bin/dt-validate", line 170, in <module>
sg.check_trees(filename, testtree)
File "/usr/local/bin/dt-validate", line 119, in check_trees
self.check_subtree(dt, subtree, False, "/", "/", filename)
File "/usr/local/bin/dt-validate", line 110, in check_subtree
self.check_subtree(tree, value, disabled, name, fullname + name, filename)
File "/usr/local/bin/dt-validate", line 110, in check_subtree
self.check_subtree(tree, value, disabled, name, fullname + name, filename)
File "/usr/local/bin/dt-validate", line 110, in check_subtree
self.check_subtree(tree, value, disabled, name, fullname + name, filename)
File "/usr/local/bin/dt-validate", line 105, in check_subtree
self.check_node(tree, subtree, disabled, nodename, fullname, filename)
File "/usr/local/bin/dt-validate", line 49, in check_node
errors = sorted(dtschema.DTValidator(schema).iter_errors(node), key=lambda e: e.linecol)
File "/usr/local/lib/python3.8/dist-packages/dtschema/lib.py", line 771, in iter_errors
for error in super().iter_errors(instance, _schema):
File "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 229, in iter_errors
for error in errors:
File "/usr/local/lib/python3.8/dist-packages/jsonschema/_validators.py", line 362, in allOf
yield from validator.descend(instance, subschema, schema_path=index)
File "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 245, in descend
for error in self.evolve(schema=schema).iter_errors(instance):
File "/usr/local/lib/python3.8/dist-packages/dtschema/lib.py", line 771, in iter_errors
for error in super().iter_errors(instance, _schema):
File "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 229, in iter_errors
for error in errors:
File "/usr/local/lib/python3.8/dist-packages/jsonschema/_validators.py", line 298, in ref
yield from validator.descend(instance, resolved)
File "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 245, in descend
for error in self.evolve(schema=schema).iter_errors(instance):
File "/usr/local/lib/python3.8/dist-packages/dtschema/lib.py", line 771, in iter_errors
for error in super().iter_errors(instance, _schema):
File "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 219, in iter_errors
scope = id_of(_schema)
File "/usr/local/lib/python3.8/dist-packages/jsonschema/validators.py", line 96, in _id_of
return schema.get("$id", "")AttributeError: 'NoneType' object has no attribute 'get'
make[1]: *** [scripts/Makefile.lib:378: Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1398: dt_binding_check] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1583159
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Re: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
In reply to Noralf TrønnesQuoted 2 lines · Noralf Trønnes
Add binding for MIPI DBI compatible SPI panels.
I'm sure we already have MIPI DBI panels. What's this for?
Quoted 25 lines
Signed-off-by Noralf Trønnes <[email protected]>--- .../display/panel/panel-mipi-dbi-spi.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yamlDocumentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +12
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/panel-mipi-dbi-spi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MIPI DBI SPI Panels Device Tree Bindings + +maintainers: + - Noralf Trønnes <[email protected]> + +description:
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml line 22
Quoted 10 lines
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +10
-0+ This binding is for display panels using a MIPI DBI controller + in SPI mode. + +allOf: + - $ref: panel/panel-common.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + const: panel-mipi-dbi-spi
Does the MIPI spec define how to power on a DBI panel with regulators, enable/reset lines, etc. and all the timing constraints between those? If not, then this compatible on its own is useless. It's fine as a fallback if it's presence means the panel uses only standard DBI commands and no vendor specific commands.
Quoted 50 lines
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +47
-1+ + model: + $ref: /schemas/types.yaml#/definitions/string + description: The name of the display panel. + + write-only: + type: boolean + description: + Controller is not readable (ie. MISO is not wired up). + + dc-gpios: + maxItems: 1 + description: | + Controller data/command selection (D/CX) in 4-line SPI mode. + If not set, the controller is in 3-line SPI mode. + + backlight: true + reg: true + reset-gpios: true + +required: + - compatible + - model + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + spi { + #address-cells = <1>; + #size-cells = <0>; + + display@0{ + compatible = "panel-mipi-dbi-spi"; + model = "sainsmart18"; + reg = <0>; + spi-max-frequency = <40000000>; + dc-gpios = <&gpio 24 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>; + write-only; + }; + }; + +... --2.33.0
Re: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Den 24.01.2022 17.08, skrev Rob Herring:
Quoted 6 lines · Noralf Trønnes
Quoted 2 lines
Add binding for MIPI DBI compatible SPI panels.
I'm sure we already have MIPI DBI panels. What's this for?
It aims to use one driver to cover all MIPI DBI panels where the controller setup is loaded from userspace in a firmware file. The cover letter points to the discussion where Maxime proposed this:
https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
Noralf.
Quoted 92 lines
Quoted 25 lines
Signed-off-by Noralf Trønnes <[email protected]>--- .../display/panel/panel-mipi-dbi-spi.yaml | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yamlDocumentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +12
-0@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: GPL-2.0-only +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/display/panel/panel-mipi-dbi-spi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MIPI DBI SPI Panels Device Tree Bindings + +maintainers: + - Noralf Trønnes <[email protected]> + +description:Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml line 22
Quoted 10 lines
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +10
-0+ This binding is for display panels using a MIPI DBI controller + in SPI mode. + +allOf: + - $ref: panel/panel-common.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + const: panel-mipi-dbi-spiDoes the MIPI spec define how to power on a DBI panel with regulators, enable/reset lines, etc. and all the timing constraints between those? If not, then this compatible on its own is useless. It's fine as a fallback if it's presence means the panel uses only standard DBI commands and no vendor specific commands.
Quoted 50 lines
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +47
-1+ + model: + $ref: /schemas/types.yaml#/definitions/string + description: The name of the display panel. + + write-only: + type: boolean + description: + Controller is not readable (ie. MISO is not wired up). + + dc-gpios: + maxItems: 1 + description: | + Controller data/command selection (D/CX) in 4-line SPI mode. + If not set, the controller is in 3-line SPI mode. + + backlight: true + reg: true + reset-gpios: true + +required: + - compatible + - model + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + spi { + #address-cells = <1>; + #size-cells = <0>; + + display@0{ + compatible = "panel-mipi-dbi-spi"; + model = "sainsmart18"; + reg = <0>; + spi-max-frequency = <40000000>; + dc-gpios = <&gpio 24 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>; + write-only; + }; + }; + +... --2.33.0
Re: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Quoted 6 lines · Noralf Trønnes
Den 24.01.2022 17.08, skrev Rob Herring:
Quoted 2 lines · Noralf Trønnes
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Add binding for MIPI DBI compatible SPI panels.
I'm sure we already have MIPI DBI panels. What's this for?
It aims to use one driver to cover all MIPI DBI panels where the controller setup is loaded from userspace in a firmware file.
What's the solution when the user wants a splash screen in the bootloader and also wants multiple panels supported?
Also, 1 driver doesn't dictate 1 compatible. A one to many relationship is fine and makes the decision entirely the OS's.
Quoted 4 lines
The cover
letter points to the discussion where Maxime proposed this:https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
The proposal there is:
Quoted 2 lines
compatible = "panel-spi";
model = "panel-from-random-place-42";
The same thing can be accomplished with this:
compatible = "panel-from-random-place-42", "panel-spi";
What's the advantage of hijacking 'model'?
Rob
Re: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Den 24.01.2022 17.42, skrev Rob Herring:
Quoted 9 lines · Noralf Trønnes
Quoted 8 lines
Den 24.01.2022 17.08, skrev Rob Herring:
Quoted 4 lines · Noralf Trønnes
Quoted 2 lines
Add binding for MIPI DBI compatible SPI panels.
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
I'm sure we already have MIPI DBI panels. What's this for?
It aims to use one driver to cover all MIPI DBI panels where the controller setup is loaded from userspace in a firmware file.
What's the solution when the user wants a splash screen in the bootloader and also wants multiple panels supported?
In that case the bootloader needs builtin support for the screen. The OS driver can then detect that the controller is configured and just skip the configure stage. I have yet to see someone implement suppport for such a SPI panel in a bootloader though.
Quoted 10 lines
Also, 1 driver doesn't dictate 1 compatible. A one to many relationship is fine and makes the decision entirely the OS's.
Quoted 4 lines
The cover
letter points to the discussion where Maxime proposed this:https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
The proposal there is:
Quoted 9 lines
Quoted 2 lines
compatible = "panel-spi";
model = "panel-from-random-place-42";The same thing can be accomplished with this:
compatible = "panel-from-random-place-42", "panel-spi";
What's the advantage of hijacking 'model'?
That's what Maxime proposed, but having it in the compatible like this is even better. I suppose it's ok for the driver to use the compatible to load the firmware file?
Noralf.
Re: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
In reply to Rob HerringHi Rob,
Quoted 28 lines · Rob Herring
Quoted 6 lines · Noralf Trønnes
Den 24.01.2022 17.08, skrev Rob Herring:
Quoted 2 lines · Noralf Trønnes
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Add binding for MIPI DBI compatible SPI panels.
I'm sure we already have MIPI DBI panels. What's this for?
It aims to use one driver to cover all MIPI DBI panels where the controller setup is loaded from userspace in a firmware file.
What's the solution when the user wants a splash screen in the bootloader and also wants multiple panels supported?
Also, 1 driver doesn't dictate 1 compatible. A one to many relationship is fine and makes the decision entirely the OS's.
Quoted 4 lines
The cover
letter points to the discussion where Maxime proposed this:https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
The proposal there is:
Quoted 8 lines
Quoted 2 lines
compatible = "panel-spi";
model = "panel-from-random-place-42";The same thing can be accomplished with this:
compatible = "panel-from-random-place-42", "panel-spi";
What's the advantage of hijacking 'model'?
So, the main issue is that a panel is essentially two things: a controller and the actual panel.
The controller has an initialization sequence of its own, and part of it is parameters to match the panel.
So you can have identical controllers that won't have the same initialization sequence because they don't have the same panel.
I was assuming that a compatible would be more about the controller, so we needed something else, thus "model"
Maxime
Re: [PATCH 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Quoted 44 lines · Maxime Ripard
Hi Rob,
Quoted 28 lines · Rob Herring
Quoted 6 lines · Noralf Trønnes
Den 24.01.2022 17.08, skrev Rob Herring:
Quoted 2 lines · Noralf Trønnes
Quoted 1 line
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Add binding for MIPI DBI compatible SPI panels.
I'm sure we already have MIPI DBI panels. What's this for?
It aims to use one driver to cover all MIPI DBI panels where the controller setup is loaded from userspace in a firmware file.
What's the solution when the user wants a splash screen in the bootloader and also wants multiple panels supported?
Also, 1 driver doesn't dictate 1 compatible. A one to many relationship is fine and makes the decision entirely the OS's.
Quoted 4 lines
The cover
letter points to the discussion where Maxime proposed this:https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
The proposal there is:
Quoted 8 lines
Quoted 2 lines
compatible = "panel-spi";
model = "panel-from-random-place-42";The same thing can be accomplished with this:
compatible = "panel-from-random-place-42", "panel-spi";
What's the advantage of hijacking 'model'?
So, the main issue is that a panel is essentially two things: a controller and the actual panel.
Quoted 8 lines
The controller has an initialization sequence of its own, and part of it is parameters to match the panel.
So you can have identical controllers that won't have the same initialization sequence because they don't have the same panel.
I was assuming that a compatible would be more about the controller, so we needed something else, thus "model"
We already have cases like that which have "foo,some-panel", "bar,a-ctrlr-ic".
Rob
PATCH 2/3 drm/mipi-dbi: Add driver_private member to struct mipi_dbi_dev
In reply to Noralf Trønnesdevm_drm_dev_alloc() can't allocate structures that embed a structure which then again embeds drm_device. Workaround this by adding a driver_private pointer to struct mipi_dbi_dev which the driver can use for its additional state.
--- include/drm/drm_mipi_dbi.h | 2 ++ 1 file changed, 2 insertions(+)
include/drm/drm_mipi_dbi.h +2 -0
@@ -130,6 +130,8 @@ struct mipi_dbi_dev {* @dbi: MIPI DBI interface */ struct mipi_dbi dbi; + +void *driver_private; };static inline struct mipi_dbi_dev *drm_to_mipi_dbi_dev (struct drm_device *drm)
Signature · 1 line
2.33.0
PATCH 3/3 drm/panel: Add MIPI DBI compatible SPI driver
In reply to Noralf TrønnesAdd a driver that will work with most MIPI DBI compatible SPI panels. This avoids adding a driver for every new MIPI DBI compatible controller that is to be used by Linux. The 'model' Device Tree property contains the name of the display and will be used to load a firmware file that contains the controller configuration.
--- MAINTAINERS | 7 + drivers/gpu/drm/panel/Kconfig | 11 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-mipi-dbi.c | 385 +++++++++++++++++++++++++ 4 files changed, 404 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-mipi-dbi.c
MAINTAINERS +7 -0
@@ -6035,6 +6035,13 @@ T: git git://anongit.freedesktop.org/drm/drm-misc F: Documentation/devicetree/bindings/display/multi-inno,mi0283qt.txt F: drivers/gpu/drm/tiny/mi0283qt.c +DRM DRIVER FOR MIPI DBI compatible panels +M: Noralf Trønnes <[email protected]> +S: Maintained +T: git git://anongit.freedesktop.org/drm/drm-misc +F: Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml +F: drivers/gpu/drm/panel/panel-mipi-dbi.c + DRM DRIVER FOR MSM ADRENO GPU M: Rob Clark <[email protected]> M: Sean Paul <[email protected]>
drivers/gpu/drm/panel/Kconfig +11 -0
@@ -274,6 +274,17 @@ config DRM_PANEL_LG_LG4573 Say Y here if you want to enable support for LG4573 RGB panel. To compile this driver as a module, choose M here. +config DRM_PANEL_MIPI_DBI + tristate "MIPI DBI compatible panel" + depends on SPI + depends on BACKLIGHT_CLASS_DEVICE + depends on DRM_KMS_HELPER + select DRM_KMS_CMA_HELPER + select DRM_MIPI_DBI + help + Say Y here if you want to enable support for MIPI DBI compatible panels. + To compile this driver as a module, choose M here. + config DRM_PANEL_NEC_NL8048HL11 tristate "NEC NL8048HL11 RGB panel" depends on GPIOLIB && OF && SPI
drivers/gpu/drm/panel/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK050H3146W) += panel-leadtek-ltk050h3146w.o obj-$(CONFIG_DRM_PANEL_LEADTEK_LTK500HD1829) += panel-leadtek-ltk500hd1829.o obj-$(CONFIG_DRM_PANEL_LG_LB035Q02) += panel-lg-lb035q02.o obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o +obj-$(CONFIG_DRM_PANEL_MIPI_DBI) += panel-mipi-dbi.o obj-$(CONFIG_DRM_PANEL_NEC_NL8048HL11) += panel-nec-nl8048hl11.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35510) += panel-novatek-nt35510.o obj-$(CONFIG_DRM_PANEL_NOVATEK_NT35950) += panel-novatek-nt35950.o
drivers/gpu/drm/panel/panel-mipi-dbi.c new file +385 -0
385 lines not on this page · raw message
Signature · 1 line
2.33.0