drm/panel: Add MIPI DBI compatible SPI driver
Subsystems (5)
v3 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.
Maxime gave[1] 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.
I have now made a script[2] that can create the firmware file, example in the wiki[3]
Main change since version 2:
- Use Device Tree for all properties (Maxime)
The MIPI DPI specification has optional support for DPI where the controller is configured over DBI. Because of this I put the driver in drm/panel so it could be extended in the future to support panel-mipi-dpi-spi. I have now looked at this more closely and the only thing that can be shared between the two are the firmware command functions. These functions can be moved to the drm_mipi_dbi_helper for sharing. Now that I know that there won't be one driver module that supports both use cases, I'm thinking of moving the driver to drm/tiny where the other drivers of its kind are located. I'll move the driver in the next version of the patchset unless someone have reasons for leaving it in drm/panel.
Noralf.
[1] https://lore.kernel.org/dri-devel/20211129093946.xhp22mvdut3m67sc@houat/
[2] https://github.com/notro/panel-mipi-dbi/blob/main/mipi-dbi-cmd
[3] https://github.com/notro/panel-mipi-dbi/wiki
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 | 124 ++++++ MAINTAINERS | 8 + drivers/gpu/drm/panel/Kconfig | 13 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-mipi-dbi.c | 413 ++++++++++++++++++ include/drm/drm_mipi_dbi.h | 8 + 6 files changed, 567 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 v3 1/3 dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Add binding for MIPI DBI compatible SPI panels.
v3:
- Move properties to Device Tree (Maxime)
- Use contains for compatible (Maxime)
- Add backlight property to example
- Flesh out description
v2:
- Fix path for panel-common.yaml
- Use unevaluatedProperties
- Drop properties which are in the allOf section
- Drop model property (Rob)
--- .../display/panel/panel-mipi-dbi-spi.yaml | 124 ++++++++++++++++++ 1 file changed, 124 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 +124 -0
@@ -0,0 +1,124 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +%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 Panel + +maintainers: + - Noralf Trønnes <[email protected]> + +description: | + This binding is for display panels using a MIPI DBI compatible controller + in SPI mode. + + The MIPI Alliance Standard for Display Bus Interface defines the electrical + and logical interfaces for display controllers historically used in mobile + phones. The standard defines 4 display architecture types and this binding is + for type 1 which has full frame memory. There are 3 interface types in the + standard and type C is the serial interface. + + The standard defines the following interface signals for type C: + - Power: + - Vdd: Power supply for display module + - Vddi: Logic level supply for interface signals + Combined into one in this binding called: power-supply + - Interface: + - CSx: Chip select + - SCL: Serial clock + - Dout: Serial out + - Din: Serial in + - SDA: Bidrectional in/out + - D/CX: Data/command selection, high=data, low=command + Called dc-gpios in this binding. + - RESX: Reset when low + Called reset-gpios in this binding. + + The type C interface has 3 options: + + - Option 1: 9-bit mode and D/CX as the 9th bit + | Command | the next command or following data | + |<0><D7><D6><D5><D4><D3><D2><D1><D0>|<D/CX><D7><D6><D5><D4><D3><D2><D1><D0>| + + - Option 2: 16-bit mode and D/CX as a 9th bit + | Command or data | + |<X><X><X><X><X><X><X><D/CX><D7><D6><D5><D4><D3><D2><D1><D0>| + + - Option 3: 8-bit mode and D/CX as a separate interface line + | Command or data | + |<D7><D6><D5><D4><D3><D2><D1><D0>| + + The panel resolution is specified using the panel-timing node properties + hactive (width) and vactive (height). The other mandatory panel-timing + properties should be set to zero except clock-frequency which can be + optionally set to inform about the actual pixel clock frequency. + + If the panel is wired to the controller at an offset specify this using + hback-porch (x-offset) and vback-porch (y-offset). + +allOf: + - $ref: panel-common.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + contains: + const: panel-dbi-spi + + 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. + +required: + - compatible + - reg + - panel-timing + +unevaluatedProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + + spi { + #address-cells = <1>; + #size-cells = <0>; + + display@0{ + compatible = "sainsmart18", "panel-dbi-spi"; + reg = <0>; + spi-max-frequency = <40000000>; + + dc-gpios = <&gpio 24 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio 25 GPIO_ACTIVE_HIGH>; + write-only; + + backlight = <&backlight>; + + width-mm = <35>; + height-mm = <28>; + + panel-timing { + hactive = <160>; + vactive = <128>; + hback-porch = <0>; + vback-porch = <0>; + + clock-frequency = <0>; + hfront-porch = <0>; + hsync-len = <0>; + vfront-porch = <0>; + vsync-len = <0>; + }; + }; + }; + +...
Signature · 1 line
2.33.0
Re: [PATCH v3 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Quoted 83 lines · Noralf Trønnes
Add binding for MIPI DBI compatible SPI panels.
v3:
- Move properties to Device Tree (Maxime)
- Use contains for compatible (Maxime)
- Add backlight property to example
- Flesh out descriptionv2:
- Fix path forpanel-common.yaml
- Use unevaluatedProperties
- Drop properties which are in the allOf section
- Drop model property (Rob)Signed-off-by Noralf Trønnes <[email protected]>--- .../display/panel/panel-mipi-dbi-spi.yaml | 124 ++++++++++++++++++ 1 file changed, 124 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 +57
-0@@ -0,0 +1,124 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +%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 Panel + +maintainers: + - Noralf Trønnes <[email protected]> + +description: | + This binding is for display panels using a MIPI DBI compatible controller + in SPI mode. + + The MIPI Alliance Standard for Display Bus Interface defines the electrical + and logical interfaces for display controllers historically used in mobile + phones. The standard defines 4 display architecture types and this binding is + for type 1 which has full frame memory. There are 3 interface types in the + standard and type C is the serial interface. + + The standard defines the following interface signals for type C: + - Power: + - Vdd: Power supply for display module + - Vddi: Logic level supply for interface signals + Combined into one in this binding called: power-supply + - Interface: + - CSx: Chip select + - SCL: Serial clock + - Dout: Serial out + - Din: Serial in + - SDA: Bidrectional in/out + - D/CX: Data/command selection, high=data, low=command + Called dc-gpios in this binding. + - RESX: Reset when low + Called reset-gpios in this binding. + + The type C interface has 3 options: + + - Option 1: 9-bit mode and D/CX as the 9th bit + | Command | the next command or following data | + |<0><D7><D6><D5><D4><D3><D2><D1><D0>|<D/CX><D7><D6><D5><D4><D3><D2><D1><D0>| + + - Option 2: 16-bit mode and D/CX as a 9th bit + | Command or data | + |<X><X><X><X><X><X><X><D/CX><D7><D6><D5><D4><D3><D2><D1><D0>| + + - Option 3: 8-bit mode and D/CX as a separate interface line + | Command or data | + |<D7><D6><D5><D4><D3><D2><D1><D0>| + + The panel resolution is specified using the panel-timing node properties + hactive (width) and vactive (height). The other mandatory panel-timing + properties should be set to zero except clock-frequency which can be + optionally set to inform about the actual pixel clock frequency. + + If the panel is wired to the controller at an offset specify this using
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml line 67
Quoted 10 lines
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +10
-0+ hback-porch (x-offset) and vback-porch (y-offset). + +allOf: + - $ref: panel-common.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + contains: + const: panel-dbi-spi
This could be further improved by using
properties:
compatible:
items:
- {} # Panel Specific Compatible
- const: panel-dbi-spi
To make it obvious we expect two compatible, and what the first one should be.
Once fixed,
Maxime
Re: [PATCH v3 1/3] dt-bindings: display: add bindings for MIPI DBI compatible SPI panels
Den 11.02.2022 14.27, skrev Maxime Ripard:
Quoted 97 lines · Noralf Trønnes
Quoted 83 lines
Add binding for MIPI DBI compatible SPI panels.
v3:
- Move properties to Device Tree (Maxime)
- Use contains for compatible (Maxime)
- Add backlight property to example
- Flesh out descriptionv2:
- Fix path forpanel-common.yaml
- Use unevaluatedProperties
- Drop properties which are in the allOf section
- Drop model property (Rob)Signed-off-by Noralf Trønnes <[email protected]>--- .../display/panel/panel-mipi-dbi-spi.yaml | 124 ++++++++++++++++++ 1 file changed, 124 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 +57
-0@@ -0,0 +1,124 @@ +# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause) +%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 Panel + +maintainers: + - Noralf Trønnes <[email protected]> + +description: | + This binding is for display panels using a MIPI DBI compatible controller + in SPI mode. + + The MIPI Alliance Standard for Display Bus Interface defines the electrical + and logical interfaces for display controllers historically used in mobile + phones. The standard defines 4 display architecture types and this binding is + for type 1 which has full frame memory. There are 3 interface types in the + standard and type C is the serial interface. + + The standard defines the following interface signals for type C: + - Power: + - Vdd: Power supply for display module + - Vddi: Logic level supply for interface signals + Combined into one in this binding called: power-supply + - Interface: + - CSx: Chip select + - SCL: Serial clock + - Dout: Serial out + - Din: Serial in + - SDA: Bidrectional in/out + - D/CX: Data/command selection, high=data, low=command + Called dc-gpios in this binding. + - RESX: Reset when low + Called reset-gpios in this binding. + + The type C interface has 3 options: + + - Option 1: 9-bit mode and D/CX as the 9th bit + | Command | the next command or following data | + |<0><D7><D6><D5><D4><D3><D2><D1><D0>|<D/CX><D7><D6><D5><D4><D3><D2><D1><D0>| + + - Option 2: 16-bit mode and D/CX as a 9th bit + | Command or data | + |<X><X><X><X><X><X><X><D/CX><D7><D6><D5><D4><D3><D2><D1><D0>| + + - Option 3: 8-bit mode and D/CX as a separate interface line + | Command or data | + |<D7><D6><D5><D4><D3><D2><D1><D0>| + + The panel resolution is specified using the panel-timing node properties + hactive (width) and vactive (height). The other mandatory panel-timing + properties should be set to zero except clock-frequency which can be + optionally set to inform about the actual pixel clock frequency. + + If the panel is wired to the controller at an offset specify this usingDocumentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml line 67
Quoted 10 lines
Documentation/devicetree/bindings/display/panel/panel-mipi-dbi-spi.yaml new file +10
-0+ hback-porch (x-offset) and vback-porch (y-offset). + +allOf: + - $ref: panel-common.yaml# + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +properties: + compatible: + contains: + const: panel-dbi-spiThis could be further improved by using
Quoted 8 lines
properties:
compatible:
items:
- {} # Panel Specific Compatible
- const: panel-dbi-spiTo make it obvious we expect two compatible, and what the first one should be.
Ok.
I see that for some reason I've dropped the mipi infix here in the compatible and in the example. I'll fix that and make it panel-mipi-dbi-spi in the next version.
Noralf.
Quoted 5 lines
Once fixed,
Acked-by Maxime Ripard <[email protected]>Maxime
PATCH v3 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.
v3:
- Add documentation
--- include/drm/drm_mipi_dbi.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/drm/drm_mipi_dbi.h +8 -0
@@ -130,6 +130,14 @@ struct mipi_dbi_dev {* @dbi: MIPI DBI interface */ struct mipi_dbi dbi; + +/** +* @driver_private: Driver private data. +* Necessary for drivers with private data since devm_drm_dev_alloc() +* can't allocate structures that embed a structure which then again +* embeds drm_device. +*/ +void *driver_private; };static inline struct mipi_dbi_dev *drm_to_mipi_dbi_dev (struct drm_device *drm)
Signature · 1 line
2.33.0
Re: [PATCH v3 2/3] drm/mipi-dbi: Add driver_private member to struct mipi_dbi_dev
Quoted 9 lines · Noralf Trønnes
devm_drm_dev_alloc()can't allocate structures that embed a structure which then again embedsdrm_device. Workaround this by adding adriver_privatepointer to structmipi_dbi_devwhich the driver can use for its additional state.v3:
- Add documentationSigned-off-by Noralf Trønnes <[email protected]>
Maxime
PATCH v3 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 'compatible' Device Tree property with a '.bin' suffix will be used to load a firmware file that contains the controller configuration.
Example (driver will load sainsmart18.bin):
display@0 {
compatible = "sainsmart18", "panel-mipi-dbi-spi";...
};
v3:
- Move properties to DT (Maxime)
- The MIPI DPI spec has optional support for DPI where the controller is configured over DBI. Rework the command functions so they can be moved to drm_mipi_dbi and shared with a future panel-mipi-dpi-spi driver
v2:
- Drop model property and use compatible instead (Rob)
- Add wiki entry in MAINTAINERS
--- MAINTAINERS | 8 + drivers/gpu/drm/panel/Kconfig | 13 + drivers/gpu/drm/panel/Makefile | 1 + drivers/gpu/drm/panel/panel-mipi-dbi.c | 413 +++++++++++++++++++++++++ 4 files changed, 435 insertions(+) create mode 100644 drivers/gpu/drm/panel/panel-mipi-dbi.c
MAINTAINERS +8 -0
@@ -6047,6 +6047,14 @@ 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 +W: https://github.com/notro/panel-mipi-dbi/wiki +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 +13 -0
@@ -274,6 +274,19 @@ 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. The controller command setup can be provided using a + firmware file. + 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 +413 -0
413 lines not on this page · raw message
Signature · 1 line
2.33.0
Quoted 19 lines · Noralf Trønnes
Add 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 'compatible' Device Tree property with a '.bin' suffix will be used to load a firmware file that contains the controller configuration.
Example (driver will load sainsmart18.bin):
display@0 { compatible = "sainsmart18", "panel-mipi-dbi-spi";...
};v3:
- Move properties to DT (Maxime)
- The MIPI DPI spec has optional support for DPI where the controller is configured over DBI. Rework the command functions so they can be moved todrm_mipi_dbiand shared with a future panel-mipi-dpi-spi driver
Quoted 5 lines
v2:
- Drop model property and use compatible instead (Rob)
- Add wiki entry inMAINTAINERSSigned-off-by Noralf Trønnes <[email protected]>
Maxime