video: support Rocktech RK050HR345-CT106A panel
Subsystems (3)
v3 cover video: support Rocktech RK050HR345-CT106A panel
This series adds support for the Rocktech RK050HR345-CT106A panel. The initialization of this panel requires a 9-bit word length configuration. To support this, I have extended the STM32 SPI driver (including support for the STM32MP25 SoC) to implement the set_wordlen operation.
To properly validate these changes and ensure the SPI uclass correctly handles the word length propagation, I have also implemented the corresponding logic in the sandbox driver and added a dedicated unit test.
I have grouped these patches together to provide a complete overview of the implementation and its verification.
Changes in v3:
- Use struct spi_slave data to access wordlen parameter instead of driver private data.
- Move the stm32_spi_is_enabled() helper to the new patch "spi: stm32: add stm32_spi_is_enabled() helper"
- Insert blank lines to separate code in ilitek-ili9806e.c
Changes in v2:
- Rplace tristate with bool in drivers/video/Kconfig
Dario Binacchi (9):
spi: add support for bits-per-word setting
spi: sandbox_spi: support wordlen setup
test: spi: add sandbox_spi_get_wordlen interface
test: dm: spi: add testcase for spi_set_wordlen()
spi: stm32: clean up buffer length assignment
spi: stm32: add stm32_spi_is_enabled() helper
spi: stm32: add support for bits-per-word setting
spi: stm32: extend support to STM32MP25
video: support Rocktech RK050HR345-CT106A panel
arch/sandbox/include/asm/test.h | 8 + drivers/spi/sandbox_spi.c | 17 ++ drivers/spi/spi-uclass.c | 22 +- drivers/spi/stm32_spi.c | 71 ++++++- drivers/video/Kconfig | 8 + drivers/video/Makefile | 1 + drivers/video/ilitek-ili9806e.c | 356 ++++++++++++++++++++++++++++++++ include/spi.h | 14 ++ test/dm/spi.c | 16 ++ 9 files changed, 502 insertions(+), 11 deletions(-) create mode 100644 drivers/video/ilitek-ili9806e.c
Signature · 3 lines
2.43.0 base-commit: 4f70106beafe30df8b0528a3d8b2543cd48fe241
PATCH v3 1/9 spi: add support for bits-per-word setting
Allow dynamic configuration of the SPI word length. This is required for controllers and slaves that need to operate with non-standard word lengths, such as 9-bit wide transfers.
---
Changes in v3:
- Add Reviewed-by tag of Simon Glass
- Store the default value in struct dm_spi_slave_plat and copy it in struct spi_slave
drivers/spi/spi-uclass.c | 22 +++++++++++++++++++++- include/spi.h | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-)
drivers/spi/spi-uclass.c +21 -1
@@ -91,6 +91,20 @@ void dm_spi_release_bus(struct udevice *dev) ops->release_bus (dev); } +int dm_spi_set_wordlen (struct udevice *dev,unsigned int wordlen) +{ +struct udevice *bus = dev->parent; +struct dm_spi_ops *ops =spi_get_ops (bus); + +if (bus->uclass->uc_drv->id !=UCLASS_SPI ) +return -EOPNOTSUPP ; + +if (!ops->set_wordlen) +return -ENOSYS ; + +return ops->set_wordlen (dev, wordlen); +} +int dm_spi_xfer (struct udevice *dev,unsigned int bitlen,const void *dout,void *din,unsigned long flags) {
@@ -144,6 +158,11 @@ int spi_set_speed(struct spi_slave *slave, uint hz)return ret; } +int spi_set_wordlen (struct spi_slave *slave,unsigned int wordlen) +{ +return dm_spi_set_wordlen (slave->dev, wordlen); +} +int spi_xfer (struct spi_slave *slave,unsigned int bitlen,const void *dout,void *din,unsigned long flags) {
@@ -215,7 +234,7 @@ static int spi_child_pre_probe(struct udevice *dev) slave->max_hz = plat->max_hz; slave->mode = plat->mode; - slave->wordlen =SPI_DEFAULT_WORDLEN ; + slave->wordlen = plat->wordlen;return 0 ; }
@@ -582,6 +601,7 @@ int spi_slave_of_to_plat(struct udevice *dev, struct dm_spi_slave_plat *plat) } plat->mode = mode; + plat->wordlen =SPI_DEFAULT_WORDLEN ;return 0 ; }
include/spi.h +14 -0
@@ -77,11 +77,13 @@ struct dm_spi_bus {* @cs: Chip select number (0..n-1) * @max_hz: Maximum bus speed that this slave can tolerate * @mode: SPI mode to use for this device (see SPI mode flags) +* @wordlen: Word length in bits to use for this device */ struct dm_spi_slave_plat {unsigned int cs[SPI_CS_CNT_MAX ];uint max_hz;uint mode; +unsigned int wordlen; };/**
@@ -729,6 +731,18 @@ int dm_spi_claim_bus(struct udevice *dev);*/ void dm_spi_release_bus (struct udevice *dev); +/** +* Set the word length for SPI transactions +* +* Set the word length (number of bits per word) for SPI transactions. +* +* @slave: The SPI slave +* @wordlen: The number of bits in a word +* +* Returns: 0 on success, -1 on failure. +*/ +int dm_spi_set_wordlen (struct udevice *dev,unsigned int wordlen); +/** * SPI transfer *
Signature · 1 line
2.43.0
PATCH v3 2/9 spi: sandbox_spi: support wordlen setup
In reply to Dario BinacchiThe driver currently ignores the word length configuration. Implement the set_wordlen operation to store and track the current word length.
---
Changes in v3:
- Add Reviewed-by tag of Simon Glass
- Store wordlen in struct spi_slave data instead of driver private data.
drivers/spi/sandbox_spi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/spi/sandbox_spi.c +10 -0
@@ -61,6 +61,15 @@ uint sandbox_spi_get_mode(struct udevice *dev)return priv->mode; } +static int sandbox_spi_set_wordlen (struct udevice *dev,unsigned int wordlen) +{ +struct spi_slave *slave =dev_get_parent_priv (dev); + + slave->wordlen = wordlen; + +return 0 ; +} +static int sandbox_spi_xfer (struct udevice *slave,unsigned int bitlen,const void *dout,void *din,unsigned long flags) {
@@ -158,6 +167,7 @@ static const struct dm_spi_ops sandbox_spi_ops = { .set_mode = sandbox_spi_set_mode, .cs_info = sandbox_cs_info, .get_mmap = sandbox_spi_get_mmap, + .set_wordlen = sandbox_spi_set_wordlen, };static const struct udevice_id sandbox_spi_ids[] = {
Signature · 1 line
2.43.0
PATCH v3 3/9 test: spi: add sandbox_spi_get_wordlen interface
In reply to Dario BinacchiAdd the sandbox_spi_get_wordlen() public interface to retrieve the internal word length state of the sandbox SPI device.
This is intended for use in sandbox SPI test cases to verify that the word length is correctly propagated from the SPI uclass to the driver.
---
Changes in v3:
- Add Reviewed-by tag of Simon Glass
- Get from struct spi_slave data.
arch/sandbox/include/asm/test.h | 8 ++++++++ drivers/spi/sandbox_spi.c | 7 +++++++ 2 files changed, 15 insertions(+)
arch/sandbox/include/asm/test.h +8 -0
@@ -243,6 +243,14 @@ uint sandbox_spi_get_speed(struct udevice *dev);*/ uint sandbox_spi_get_mode (struct udevice *dev); +/** +* sandbox_spi_get_wordlen() - Get current wordlen setting of a sandbox spi slave +* +* @dev: Device to check +* Return: current wordlen +*/ +uint sandbox_spi_get_wordlen (struct udevice *dev); +/** * sandbox_get_pch_spi_protect() - Get the PCI SPI protection status *
drivers/spi/sandbox_spi.c +7 -0
@@ -61,6 +61,13 @@ uint sandbox_spi_get_mode(struct udevice *dev)return priv->mode; } +uint sandbox_spi_get_wordlen (struct udevice *dev) +{ +struct spi_slave *slave =dev_get_parent_priv (dev); + +return slave->wordlen; +} +static int sandbox_spi_set_wordlen (struct udevice *dev,unsigned int wordlen) {struct spi_slave *slave =dev_get_parent_priv (dev);
Signature · 1 line
2.43.0
PATCH v3 4/9 test: dm: spi: add testcase for spi_set_wordlen()
In reply to Dario BinacchiAdd a unit test to verify that the SPI word length configuration is correctly handled by the SPI uclass and successfully passed down to the sandbox driver.
---
Changes in v3:
- Add Reviewed-by tag of Simon Glass
test/dm/spi.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
test/dm/spi.c +16 -0
@@ -170,6 +170,22 @@ static int dm_test_spi_claim_bus(struct unit_test_state *uts) }DM_TEST (dm_test_spi_claim_bus,UTF_SCAN_PDATA |UTF_SCAN_FDT ); +static int dm_test_spi_set_wordlen (struct unit_test_state *uts) +{ +struct spi_slave *slave; +struct udevice *bus; +const int busnum =0 , cs =0 ; + +ut_assertok (spi_get_bus_and_cs (busnum, cs, &bus, &slave)); +ut_assertok (spi_set_wordlen (slave,8 )); +ut_asserteq (8 ,sandbox_spi_get_wordlen (slave->dev)); +ut_assertok (spi_set_wordlen (slave,9 )); +ut_asserteq (9 ,sandbox_spi_get_wordlen (slave->dev)); + +return 0 ; +} +DM_TEST (dm_test_spi_set_wordlen,UTF_SCAN_PDATA |UTF_SCAN_FDT ); +/* Test that sandbox SPI works correctly */ static int dm_test_spi_xfer (struct unit_test_state *uts) {
Signature · 1 line
2.43.0
PATCH v3 5/9 spi: stm32: clean up buffer length assignment
In reply to Dario BinacchiRemove redundant divisions by using the already available xferlen variable for setting the rx/tx buffer lengths.
---
Changes in v3:
- Add Reviewed-by tag of Patrice Chotard
drivers/spi/stm32_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/spi/stm32_spi.c +2 -2
@@ -404,8 +404,8 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen, priv->tx_buf = dout; priv->rx_buf = din; - priv->tx_len = priv->tx_buf ? bitlen /8 :0 ; - priv->rx_len = priv->rx_buf ? bitlen /8 :0 ; + priv->tx_len = priv->tx_buf ? xferlen :0 ; + priv->rx_len = priv->rx_buf ? xferlen :0 ; mode =SPI_FULL_DUPLEX ;if (!priv->tx_buf)
Signature · 1 line
2.43.0
PATCH v3 6/9 spi: stm32: add stm32_spi_is_enabled() helper
In reply to Dario BinacchiAdd a helper to check the SPE (SPI Enable) bit and replace the open-coded bitwise check in stm32_spi_stopxfer() with this helper to improve readability and consistency.
This is also a preparatory step for future driver updates that require checking the SPI enable state across different code paths.
---
(Added in v3)
drivers/spi/stm32_spi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/spi/stm32_spi.c +6 -3
@@ -192,6 +192,11 @@ static void stm32_spi_read_rxfifo(struct udevice *bus)log_debug ("%d bytes left\n" , priv->rx_len); } +static bool stm32_spi_is_enabled (void __iomem *base) +{ +return !!(readl (base +STM32_SPI_CR1 ) &SPI_CR1_SPE ); +} +static int stm32_spi_enable (void __iomem *base) {log_debug ("\n" );
@@ -245,9 +250,7 @@ static void stm32_spi_stopxfer(struct udevice *dev)dev_dbg (dev,"\n" ); - cr1 =readl (base +STM32_SPI_CR1 ); - -if (!(cr1 &SPI_CR1_SPE )) +if (!stm32_spi_is_enabled (base))return ;/* Wait on EOT or suspend the flow */
Signature · 1 line
2.43.0
Re: [PATCH v3 6/9] spi: stm32: add stm32_spi_is_enabled() helper
Quoted 32 lines · Dario Binacchi
Add a helper to check the SPE (SPI Enable) bit and replace the open-coded bitwise check in
stm32_spi_stopxfer()with this helper to improve readability and consistency.This is also a preparatory step for future driver updates that require checking the SPI enable state across different code paths.
Signed-off-by Dario Binacchi <[email protected]>---
(Added in v3)
drivers/spi/stm32_spi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/spi/stm32_spi.c +5
-0@@ -192,6 +192,11 @@ static void stm32_spi_read_rxfifo(struct udevice *bus)log_debug ("%d bytes left\n" , priv->rx_len); } +static bool stm32_spi_is_enabled (void __iomem *base) +{ +return !!(readl (base +STM32_SPI_CR1 ) &SPI_CR1_SPE ); +} +static int stm32_spi_enable (void __iomem *base) {log_debug ("\n" );
drivers/spi/stm32_spi.c static void stm32_spi_stopxfer(struct udevice *dev) · line 256
Quoted 10 lines
drivers/spi/stm32_spi.c +1
-3@@ -245,9 +250,7 @@ static void stm32_spi_stopxfer(struct udevice *dev)dev_dbg (dev,"\n" ); - cr1 =readl (base +STM32_SPI_CR1 ); - -if (!(cr1 &SPI_CR1_SPE )) +if (!stm32_spi_is_enabled (base))return ;/* Wait on EOT or suspend the flow */
Thanks
Patrice
PATCH v3 7/9 spi: stm32: add support for bits-per-word setting
In reply to Dario BinacchiImplement the set_wordlen operation to allow dynamic bus width configuration. This is required for peripherals with non-standard requirements, such as display panels that need 9-bit word transfers during the initialization and setup phase.
---
Changes in v3:
- Move the stm32_spi_is_enabled() implementation in the previous patch
drivers/spi/stm32_spi.c | 57 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)
drivers/spi/stm32_spi.c +52 -5
@@ -384,6 +384,44 @@ static int stm32_spi_set_speed(struct udevice *bus, uint hz)return 0 ; } +static int _stm32_spi_set_wordlen (struct udevice *bus,unsigned int wordlen) +{ +struct stm32_spi_priv *priv =dev_get_priv (bus); +struct stm32_spi_plat *plat =dev_get_plat (bus); +void __iomem *base = plat->base; +bool spi_enabled; + +if ((wordlen -1 ) <SPI_CFG1_DSIZE_MIN || + (wordlen -1 ) >SPI_CFG1_DSIZE ) { +dev_err (bus,"Cannot set wordlen to %u [%d - %d]\n" , + wordlen,SPI_CFG1_DSIZE_MIN +1 , +SPI_CFG1_DSIZE +1 ); +return -EINVAL ; + } + + spi_enabled =stm32_spi_is_enabled (plat->base); +if (spi_enabled) +stm32_spi_disable (plat->base); + +dev_dbg (bus,"bits_per_word=%d\n" , wordlen); + + priv->cur_bpw = wordlen; +clrsetbits_le32 (base +STM32_SPI_CFG1 ,SPI_CFG1_DSIZE , + priv->cur_bpw -1 ); + +if (spi_enabled) +stm32_spi_enable (plat->base); + +return 0 ; +} + +static int stm32_spi_set_wordlen (struct udevice *slave,unsigned int wordlen) +{ +struct udevice *bus =dev_get_parent (slave); + +return _stm32_spi_set_wordlen (bus, wordlen); +} +static int stm32_spi_xfer (struct udevice *slave,unsigned int bitlen,const void *dout,void *din,unsigned long flags) {
@@ -397,11 +435,19 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen,u32 xferlen;u32 mode;int xfer_status =0 ; +int nb_words; xferlen = bitlen /8 ; -if (xferlen <=SPI_CR2_TSIZE ) -writel (xferlen, base +STM32_SPI_CR2 ); +if (priv->cur_bpw <=8 ) + nb_words = xferlen; +else if (priv->cur_bpw <=16 ) + nb_words =DIV_ROUND_UP (xferlen *8 ,16 ); +else + nb_words =DIV_ROUND_UP (xferlen *8 ,32 ); + +if (nb_words <=SPI_CR2_TSIZE ) +writel (nb_words, base +STM32_SPI_CR2 );else return -EMSGSIZE ;
@@ -409,6 +455,8 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen, priv->rx_buf = din; priv->tx_len = priv->tx_buf ? xferlen :0 ; priv->rx_len = priv->rx_buf ? xferlen :0 ; +dev_dbg (bus,"bitlen: %d, xferlen: %d, nb_words: %d\n" , + bitlen, xferlen, nb_words); mode =SPI_FULL_DUPLEX ;if (!priv->tx_buf)
@@ -570,9 +618,7 @@ static int stm32_spi_probe(struct udevice *dev) priv->fifo_size =stm32_spi_get_fifo_size (dev); priv->cur_mode =SPI_FULL_DUPLEX ; priv->cur_xferlen =0 ; - priv->cur_bpw =SPI_DEFAULT_WORDLEN ; -clrsetbits_le32 (base +STM32_SPI_CFG1 ,SPI_CFG1_DSIZE , - priv->cur_bpw -1 ); +_stm32_spi_set_wordlen (dev,SPI_DEFAULT_WORDLEN );for (i =0 ; i <ARRAY_SIZE (plat->cs_gpios); i++) {if (!dm_gpio_is_valid (&plat->cs_gpios[i]))
@@ -633,6 +679,7 @@ static const struct dm_spi_ops stm32_spi_ops = { .release_bus = stm32_spi_release_bus, .set_mode = stm32_spi_set_mode, .set_speed = stm32_spi_set_speed, + .set_wordlen = stm32_spi_set_wordlen, .xfer = stm32_spi_xfer, };
Signature · 1 line
2.43.0
Re: [PATCH v3 7/9] spi: stm32: add support for bits-per-word setting
Quoted 107 lines · Dario Binacchi
Implement the
set_wordlenoperation to allow dynamic bus width configuration. This is required for peripherals with non-standard requirements, such as display panels that need 9-bit word transfers during the initialization and setup phase.Signed-off-by Dario Binacchi <[email protected]>---
Changes in v3:
- Move thestm32_spi_is_enabled()implementation in the previous patchdrivers/spi/stm32_spi.c | 57 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-)drivers/spi/stm32_spi.c +51
-5@@ -384,6 +384,44 @@ static int stm32_spi_set_speed(struct udevice *bus, uint hz)return 0 ; } +static int _stm32_spi_set_wordlen (struct udevice *bus,unsigned int wordlen) +{ +struct stm32_spi_priv *priv =dev_get_priv (bus); +struct stm32_spi_plat *plat =dev_get_plat (bus); +void __iomem *base = plat->base; +bool spi_enabled; + +if ((wordlen -1 ) <SPI_CFG1_DSIZE_MIN || + (wordlen -1 ) >SPI_CFG1_DSIZE ) { +dev_err (bus,"Cannot set wordlen to %u [%d - %d]\n" , + wordlen,SPI_CFG1_DSIZE_MIN +1 , +SPI_CFG1_DSIZE +1 ); +return -EINVAL ; + } + + spi_enabled =stm32_spi_is_enabled (plat->base); +if (spi_enabled) +stm32_spi_disable (plat->base); + +dev_dbg (bus,"bits_per_word=%d\n" , wordlen); + + priv->cur_bpw = wordlen; +clrsetbits_le32 (base +STM32_SPI_CFG1 ,SPI_CFG1_DSIZE , + priv->cur_bpw -1 ); + +if (spi_enabled) +stm32_spi_enable (plat->base); + +return 0 ; +} + +static int stm32_spi_set_wordlen (struct udevice *slave,unsigned int wordlen) +{ +struct udevice *bus =dev_get_parent (slave); + +return _stm32_spi_set_wordlen (bus, wordlen); +} +static int stm32_spi_xfer (struct udevice *slave,unsigned int bitlen,const void *dout,void *din,unsigned long flags) {@@ -397,11 +435,19 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen,u32 xferlen;u32 mode;int xfer_status =0 ; +int nb_words; xferlen = bitlen /8 ; -if (xferlen <=SPI_CR2_TSIZE ) -writel (xferlen, base +STM32_SPI_CR2 ); +if (priv->cur_bpw <=8 ) + nb_words = xferlen; +else if (priv->cur_bpw <=16 ) + nb_words =DIV_ROUND_UP (xferlen *8 ,16 ); +else + nb_words =DIV_ROUND_UP (xferlen *8 ,32 ); + +if (nb_words <=SPI_CR2_TSIZE ) +writel (nb_words, base +STM32_SPI_CR2 );else return -EMSGSIZE ;@@ -409,6 +455,8 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen, priv->rx_buf = din; priv->tx_len = priv->tx_buf ? xferlen :0 ; priv->rx_len = priv->rx_buf ? xferlen :0 ; +dev_dbg (bus,"bitlen: %d, xferlen: %d, nb_words: %d\n" , + bitlen, xferlen, nb_words); mode =SPI_FULL_DUPLEX ;if (!priv->tx_buf)@@ -570,9 +618,7 @@ static int stm32_spi_probe(struct udevice *dev) priv->fifo_size =stm32_spi_get_fifo_size (dev); priv->cur_mode =SPI_FULL_DUPLEX ; priv->cur_xferlen =0 ; - priv->cur_bpw =SPI_DEFAULT_WORDLEN ; -clrsetbits_le32 (base +STM32_SPI_CFG1 ,SPI_CFG1_DSIZE , - priv->cur_bpw -1 ); +_stm32_spi_set_wordlen (dev,SPI_DEFAULT_WORDLEN );for (i =0 ; i <ARRAY_SIZE (plat->cs_gpios); i++) {if (!dm_gpio_is_valid (&plat->cs_gpios[i]))
drivers/spi/stm32_spi.c static const struct dm_spi_ops stm32_spi_ops = { · line 685
Quoted 7 lines
drivers/spi/stm32_spi.c +1
-0@@ -633,6 +679,7 @@ static const struct dm_spi_ops stm32_spi_ops = { .release_bus = stm32_spi_release_bus, .set_mode = stm32_spi_set_mode, .set_speed = stm32_spi_set_speed, + .set_wordlen = stm32_spi_set_wordlen, .xfer = stm32_spi_xfer, };
Thanks
Patrice
PATCH v3 8/9 spi: stm32: extend support to STM32MP25
In reply to Dario BinacchiThe SPI IP in this platform is fully compatible with the current driver implementation, requiring only a new compatible string.
---
Changes in v3:
- Add Reviewed-by tag of Patrice Chotard
drivers/spi/stm32_spi.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/stm32_spi.c +1 -0
@@ -684,6 +684,7 @@ static const struct dm_spi_ops stm32_spi_ops = { };static const struct udevice_id stm32_spi_ids[] = { + { .compatible ="st,stm32mp25-spi" , }, { .compatible ="st,stm32h7-spi" , }, { } };
Signature · 1 line
2.43.0
PATCH v3 9/9 video: support Rocktech RK050HR345-CT106A panel
In reply to Dario BinacchiAdd support for the Rocktech RK050HR345-CT106A RGB panel. This model uses an Ilitek ILI9806E controller over the SPI bus for initialization and register configuration only.
The driver is designed to be easily extensible to support other panels with different sequences and timings by providing a specific descriptor structure for each model.
---
Changes in v3:
- Insert blank lines to separate code in ilitek-ili9806e.c
Changes in v2:
- Rplace tristate with bool in drivers/video/Kconfig
drivers/video/Kconfig | 8 + drivers/video/Makefile | 1 + drivers/video/ilitek-ili9806e.c | 356 ++++++++++++++++++++++++++++++++ 3 files changed, 365 insertions(+) create mode 100644 drivers/video/ilitek-ili9806e.c
drivers/video/Kconfig +8 -0
@@ -552,6 +552,14 @@ config VIDEO_LCD_HIMAX_HX8394 Say Y here if you want to enable support for Himax HX8394 dsi 4dl panel. +config VIDEO_LCD_ILITEK_ILI9806E + bool "Ilitek ILI9806E-based panels" + depends on PANEL && BACKLIGHT + help + Say Y here if you want to enable support for panels base on + the Ilitek ILI9806E controller. Currently only the DBI panel + is implemented. + config VIDEO_LCD_MOT tristate "Atrix 4G and Droid X2 540x960 DSI video mode panel" depends on PANEL && BACKLIGHT
drivers/video/Makefile +1 -0
@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_LCD_ENDEAVORU) += endeavoru-panel.o obj-$(CONFIG_VIDEO_LCD_HIMAX_HX8394) += himax-hx8394.o obj-$(CONFIG_VIDEO_LCD_HITACHI_TX10D07VM0BAA) += hitachi-tx10d07vm0baa.o obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o +obj-$(CONFIG_VIDEO_LCD_ILITEK_ILI9806E) += ilitek-ili9806e.o obj-$(CONFIG_VIDEO_LCD_LG_LD070WX3) += lg-ld070wx3.o obj-$(CONFIG_VIDEO_LCD_LG_LH400WV3) += lg-lh400wv3-sd04.o obj-$(CONFIG_VIDEO_LCD_MOT) += mot-panel.o
drivers/video/ilitek-ili9806e.c new file +356 -0
356 lines not on this page · raw message
Signature · 1 line
2.43.0
Quoted 406 lines · Dario Binacchi
Add support for the Rocktech RK050HR345-CT106A RGB panel. This model uses an Ilitek ILI9806E controller over the SPI bus for initialization and register configuration only.
The driver is designed to be easily extensible to support other panels with different sequences and timings by providing a specific descriptor structure for each model.
Signed-off-by Dario Binacchi <[email protected]>---
Changes in v3:
- Insert blank lines to separate code inilitek-ili9806e.cChanges in v2:
- Rplace tristate with bool indrivers/video/Kconfigdrivers/video/Kconfig | 8 + drivers/video/Makefile | 1 + drivers/video/ilitek-ili9806e.c | 356 ++++++++++++++++++++++++++++++++ 3 files changed, 365 insertions(+) create mode 100644 drivers/video/ilitek-ili9806e.cdrivers/video/Kconfig +8
-0@@ -552,6 +552,14 @@ config VIDEO_LCD_HIMAX_HX8394 Say Y here if you want to enable support for Himax HX8394 dsi 4dl panel. +config VIDEO_LCD_ILITEK_ILI9806E + bool "Ilitek ILI9806E-based panels" + depends on PANEL && BACKLIGHT + help + Say Y here if you want to enable support for panels base on + the Ilitek ILI9806E controller. Currently only the DBI panel + is implemented. + config VIDEO_LCD_MOT tristate "Atrix 4G and Droid X2 540x960 DSI video mode panel" depends on PANEL && BACKLIGHTdrivers/video/Makefile +1
-0@@ -61,6 +61,7 @@ obj-$(CONFIG_VIDEO_LCD_ENDEAVORU) += endeavoru-panel.o obj-$(CONFIG_VIDEO_LCD_HIMAX_HX8394) += himax-hx8394.o obj-$(CONFIG_VIDEO_LCD_HITACHI_TX10D07VM0BAA) += hitachi-tx10d07vm0baa.o obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o +obj-$(CONFIG_VIDEO_LCD_ILITEK_ILI9806E) += ilitek-ili9806e.o obj-$(CONFIG_VIDEO_LCD_LG_LD070WX3) += lg-ld070wx3.o obj-$(CONFIG_VIDEO_LCD_LG_LH400WV3) += lg-lh400wv3-sd04.o obj-$(CONFIG_VIDEO_LCD_MOT) += mot-panel.odrivers/video/ilitek-ili9806e.c new file +346
-0@@ -0,0 +1,356 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2026 Amarula Solutions, Dario Binacchi <[email protected]> +*/ + +#include <backlight.h> +#include <dm.h> +#include <mipi_display.h> +#include <panel.h> +#include <spi.h> +#include <asm/gpio.h> +#include <dm/device_compat.h> +#include <linux/delay.h> +#include <power/regulator.h> + +struct ilitek_ili9806e_priv { +struct udevice *vdd; +struct udevice *backlight; +struct gpio_desc reset_gpio; +const struct ilitek_ili9806e_desc *desc; +}; + +struct ilitek_ili9806e_desc { +const struct display_timing timing; +void (*init_sequence)(struct udevice *dev); +}; + +static int ilitek_ili9806e_dcs_write (struct udevice *dev,u8 cmd,const u8 *seq,int len) +{ +u16 data[16 ]; +int i, ret; + +if ((len +1 ) >ARRAY_SIZE (data)) { +dev_err (dev,"Command length (%d) exceeds buffer size (%lu)\n" , + len +1 ,ARRAY_SIZE (data)); +return -EMSGSIZE ; + } + + data[0 ] = cmd; +if (len) { +for (i =0 ; i < len; i++) + data[i +1 ] = seq[i] |0x0100 ; + } + + ret =dm_spi_xfer (dev, (len +1 ) *8 *sizeof (u16), data,NULL , +SPI_XFER_ONCE ); +return 0 ; +} + +#define ilitek_ili9806e_dcs_write_seq(dev, cmd, seq...) \ +({ \ + static const u8 b[] = { seq }; \ + ilitek_ili9806e_dcs_write(dev, cmd, b, ARRAY_SIZE(b)); \ +}) + +static int ilitek_ili9806e_enable_backlight (struct udevice *dev) +{ +struct ilitek_ili9806e_priv *priv =dev_get_priv (dev); +const struct ilitek_ili9806e_desc *desc = priv->desc; + + desc->init_sequence (dev); + +return panel_set_backlight (dev,BACKLIGHT_DEFAULT ); +} + +static int ilitek_ili9806e_set_backlight (struct udevice *dev,int percent) +{ +struct ilitek_ili9806e_priv *priv =dev_get_priv (dev); +int ret; + + ret =backlight_enable (priv->backlight); +if (ret) { +dev_err (dev,"Cannot enable backlight\n" ); +return ret; + } + + ret =backlight_set_brightness (priv->backlight, percent); +if (ret) +dev_err (dev,"Cannot set backlight brightness\n" ); + +return ret; +} + +static int ilitek_ili9806e_get_display_timing (struct udevice *dev, +struct display_timing *timing) +{ +struct ilitek_ili9806e_priv *priv =dev_get_priv (dev); + +memcpy (timing, &priv->desc->timing,sizeof (*timing)); + +return 0 ; +} + +static int ilitek_ili9806e_of_to_plat (struct udevice *dev) +{ +struct ilitek_ili9806e_priv *priv =dev_get_priv (dev); +int ret; + +if (CONFIG_IS_ENABLED (DM_REGULATOR )) { + ret =device_get_supply_regulator (dev,"vdd-supply" , &priv->vdd); +if (ret) { +dev_err (dev,"Cannot get vdd supply\n" ); +return ret; + } + } + + ret =uclass_get_device_by_phandle (UCLASS_PANEL_BACKLIGHT , dev, +"backlight" , &priv->backlight); +if (ret) { +dev_err (dev,"Cannot get backlight\n" ); +return ret; + } + + ret =gpio_request_by_name (dev,"reset-gpios" ,0 , + &priv->reset_gpio,GPIOD_IS_OUT ); +if (ret) { +dev_err (dev,"Cannot get reset GPIO\n" ); +return ret; + } + +return 0 ; +} + +static int ilitek_ili9806e_hw_init (struct udevice *dev) +{ +struct ilitek_ili9806e_priv *priv =dev_get_priv (dev); +int ret; + + ret =dm_gpio_set_value (&priv->reset_gpio,1 ); +if (ret) { +dev_err (dev,"Cannot enter reset\n" ); +return ret; + } + + ret =regulator_set_enable_if_allowed (priv->vdd,1 ); +if (ret) { +dev_err (dev,"Cannot enable vdd-supply\n" ); +return ret; + } + +mdelay (20 ); + + ret =dm_gpio_set_value (&priv->reset_gpio,0 ); +if (ret) { +dev_err (dev,"Cannot exit reset\n" ); +return ret; + } + +mdelay (20 ); + +return 0 ; +} + +static int ilitek_ili9806e_probe (struct udevice *dev) +{ +struct ilitek_ili9806e_priv *priv =dev_get_priv (dev); +struct spi_slave *slave =dev_get_parent_priv (dev); +int ret; + + ret =spi_set_wordlen (slave,9 ); +if (ret) { +dev_err (dev,"Cannot set SPI.bits_per_word\n" ); +return ret; + } + + ret =spi_claim_bus (slave); +if (ret) { +dev_err (dev,"Cannot get SPI bus\n" ); +return ret; + } + + priv->desc = (struct ilitek_ili9806e_desc *)dev_get_driver_data (dev); + +return ilitek_ili9806e_hw_init (dev); +} + +static const struct panel_ops ilitek_ili9806e_ops = { + .enable_backlight = ilitek_ili9806e_enable_backlight, + .set_backlight = ilitek_ili9806e_set_backlight, + .get_display_timing = ilitek_ili9806e_get_display_timing, +}; + +static void rk050hr345_ct106a_init (struct udevice *dev) +{ +/* Switch to page 1 */ +ilitek_ili9806e_dcs_write_seq (dev,0xff ,0xff ,0x98 ,0x06 ,0x04 ,0x01 ); +/* Interface Settings */ +ilitek_ili9806e_dcs_write_seq (dev,0x08 ,0x10 ); +ilitek_ili9806e_dcs_write_seq (dev,0x21 ,0x01 ); +/* Panel Settings */ +ilitek_ili9806e_dcs_write_seq (dev,0x30 ,0x01 ); +ilitek_ili9806e_dcs_write_seq (dev,0x31 ,0x00 ); +/* Power Control */ +ilitek_ili9806e_dcs_write_seq (dev,0x40 ,0x15 ); +ilitek_ili9806e_dcs_write_seq (dev,0x41 ,0x44 ); +ilitek_ili9806e_dcs_write_seq (dev,0x42 ,0x03 ); +ilitek_ili9806e_dcs_write_seq (dev,0x43 ,0x09 ); +ilitek_ili9806e_dcs_write_seq (dev,0x44 ,0x09 ); +ilitek_ili9806e_dcs_write_seq (dev,0x50 ,0x78 ); +ilitek_ili9806e_dcs_write_seq (dev,0x51 ,0x78 ); +ilitek_ili9806e_dcs_write_seq (dev,0x52 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x53 ,0x3a ); +ilitek_ili9806e_dcs_write_seq (dev,0x57 ,0x50 ); +/* Timing Control */ +ilitek_ili9806e_dcs_write_seq (dev,0x60 ,0x07 ); +ilitek_ili9806e_dcs_write_seq (dev,0x61 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x62 ,0x08 ); +ilitek_ili9806e_dcs_write_seq (dev,0x63 ,0x00 ); +/* Gamma Settings */ +ilitek_ili9806e_dcs_write_seq (dev,0xa0 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0xa1 ,0x03 ); +ilitek_ili9806e_dcs_write_seq (dev,0xa2 ,0x0b ); +ilitek_ili9806e_dcs_write_seq (dev,0xa3 ,0x0f ); +ilitek_ili9806e_dcs_write_seq (dev,0xa4 ,0x0b ); +ilitek_ili9806e_dcs_write_seq (dev,0xa5 ,0x1b ); +ilitek_ili9806e_dcs_write_seq (dev,0xa6 ,0x0a ); +ilitek_ili9806e_dcs_write_seq (dev,0xa7 ,0x0a ); +ilitek_ili9806e_dcs_write_seq (dev,0xa8 ,0x02 ); +ilitek_ili9806e_dcs_write_seq (dev,0xa9 ,0x07 ); +ilitek_ili9806e_dcs_write_seq (dev,0xaa ,0x05 ); +ilitek_ili9806e_dcs_write_seq (dev,0xab ,0x03 ); +ilitek_ili9806e_dcs_write_seq (dev,0xac ,0x0e ); +ilitek_ili9806e_dcs_write_seq (dev,0xad ,0x32 ); +ilitek_ili9806e_dcs_write_seq (dev,0xae ,0x2d ); +ilitek_ili9806e_dcs_write_seq (dev,0xaf ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc0 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc1 ,0x03 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc2 ,0x0e ); +ilitek_ili9806e_dcs_write_seq (dev,0xc3 ,0x10 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc4 ,0x09 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc5 ,0x17 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc6 ,0x09 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc7 ,0x07 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc8 ,0x04 ); +ilitek_ili9806e_dcs_write_seq (dev,0xc9 ,0x09 ); +ilitek_ili9806e_dcs_write_seq (dev,0xca ,0x06 ); +ilitek_ili9806e_dcs_write_seq (dev,0xcb ,0x06 ); +ilitek_ili9806e_dcs_write_seq (dev,0xcc ,0x0c ); +ilitek_ili9806e_dcs_write_seq (dev,0xcd ,0x25 ); +ilitek_ili9806e_dcs_write_seq (dev,0xce ,0x20 ); +ilitek_ili9806e_dcs_write_seq (dev,0xcf ,0x00 ); + +/* Switch to page 6 */ +ilitek_ili9806e_dcs_write_seq (dev,0xff ,0xff ,0x98 ,0x06 ,0x04 ,0x06 ); +/* GIP settings */ +ilitek_ili9806e_dcs_write_seq (dev,0x00 ,0x21 ); +ilitek_ili9806e_dcs_write_seq (dev,0x01 ,0x09 ); +ilitek_ili9806e_dcs_write_seq (dev,0x02 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x03 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x04 ,0x01 ); +ilitek_ili9806e_dcs_write_seq (dev,0x05 ,0x01 ); +ilitek_ili9806e_dcs_write_seq (dev,0x06 ,0x80 ); +ilitek_ili9806e_dcs_write_seq (dev,0x07 ,0x05 ); +ilitek_ili9806e_dcs_write_seq (dev,0x08 ,0x02 ); +ilitek_ili9806e_dcs_write_seq (dev,0x09 ,0x80 ); +ilitek_ili9806e_dcs_write_seq (dev,0x0a ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x0b ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x0c ,0x0a ); +ilitek_ili9806e_dcs_write_seq (dev,0x0d ,0x0a ); +ilitek_ili9806e_dcs_write_seq (dev,0x0e ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x0f ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x10 ,0xe0 ); +ilitek_ili9806e_dcs_write_seq (dev,0x11 ,0xe4 ); +ilitek_ili9806e_dcs_write_seq (dev,0x12 ,0x04 ); +ilitek_ili9806e_dcs_write_seq (dev,0x13 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x14 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x15 ,0xc0 ); +ilitek_ili9806e_dcs_write_seq (dev,0x16 ,0x08 ); +ilitek_ili9806e_dcs_write_seq (dev,0x17 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x18 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x19 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x1a ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x1b ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x1c ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x1d ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x20 ,0x01 ); +ilitek_ili9806e_dcs_write_seq (dev,0x21 ,0x23 ); +ilitek_ili9806e_dcs_write_seq (dev,0x22 ,0x45 ); +ilitek_ili9806e_dcs_write_seq (dev,0x23 ,0x67 ); +ilitek_ili9806e_dcs_write_seq (dev,0x24 ,0x01 ); +ilitek_ili9806e_dcs_write_seq (dev,0x25 ,0x23 ); +ilitek_ili9806e_dcs_write_seq (dev,0x26 ,0x45 ); +ilitek_ili9806e_dcs_write_seq (dev,0x27 ,0x67 ); +ilitek_ili9806e_dcs_write_seq (dev,0x30 ,0x01 ); +ilitek_ili9806e_dcs_write_seq (dev,0x31 ,0x11 ); +ilitek_ili9806e_dcs_write_seq (dev,0x32 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,0x33 ,0xee ); +ilitek_ili9806e_dcs_write_seq (dev,0x34 ,0xff ); +ilitek_ili9806e_dcs_write_seq (dev,0x35 ,0xbb ); +ilitek_ili9806e_dcs_write_seq (dev,0x36 ,0xca ); +ilitek_ili9806e_dcs_write_seq (dev,0x37 ,0xdd ); +ilitek_ili9806e_dcs_write_seq (dev,0x38 ,0xac ); +ilitek_ili9806e_dcs_write_seq (dev,0x39 ,0x76 ); +ilitek_ili9806e_dcs_write_seq (dev,0x3a ,0x67 ); +ilitek_ili9806e_dcs_write_seq (dev,0x3b ,0x22 ); +ilitek_ili9806e_dcs_write_seq (dev,0x3c ,0x22 ); +ilitek_ili9806e_dcs_write_seq (dev,0x3d ,0x22 ); +ilitek_ili9806e_dcs_write_seq (dev,0x3e ,0x22 ); +ilitek_ili9806e_dcs_write_seq (dev,0x3f ,0x22 ); +ilitek_ili9806e_dcs_write_seq (dev,0x40 ,0x22 ); +ilitek_ili9806e_dcs_write_seq (dev,0x52 ,0x10 ); +ilitek_ili9806e_dcs_write_seq (dev,0x53 ,0x10 ); + +/* Switch to page 7 */ +ilitek_ili9806e_dcs_write_seq (dev,0xff ,0xff ,0x98 ,0x06 ,0x04 ,0x07 ); +ilitek_ili9806e_dcs_write_seq (dev,0x17 ,0x22 ); +ilitek_ili9806e_dcs_write_seq (dev,0x02 ,0x77 ); +ilitek_ili9806e_dcs_write_seq (dev,0xe1 ,0x79 ); +ilitek_ili9806e_dcs_write_seq (dev,0xb3 ,0x10 ); + +/* Switch to page 0 */ +ilitek_ili9806e_dcs_write_seq (dev,0xff ,0xff ,0x98 ,0x06 ,0x04 ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,MIPI_DCS_SET_ADDRESS_MODE ,0x00 ); +ilitek_ili9806e_dcs_write_seq (dev,MIPI_DCS_EXIT_SLEEP_MODE ); + +mdelay (120 ); + +ilitek_ili9806e_dcs_write_seq (dev,MIPI_DCS_SET_DISPLAY_ON ); + +mdelay (120 ); +} + +static const struct ilitek_ili9806e_desc rk050hr345_ct106a_desc = { + .timing = { + .pixelclock.typ =27000000 , + .hactive.typ =480 , + .hfront_porch.typ =10 , + .hback_porch.typ =10 , + .hsync_len.typ =10 , + .vactive.typ =854 , + .vfront_porch.typ =10 , + .vback_porch.typ =10 , + .vsync_len.typ =10 , + .flags =DISPLAY_FLAGS_HSYNC_LOW |DISPLAY_FLAGS_VSYNC_LOW , + }, + .init_sequence = rk050hr345_ct106a_init, +}; + +static const struct udevice_id ilitek_ili9806e_ids[] = { + { + .compatible ="rocktech,rk050hr345-ct106a" , + .data = (ulong)&rk050hr345_ct106a_desc, + }, + { } +}; +
drivers/video/ilitek-ili9806e.c line 356
Quoted 10 lines
drivers/video/ilitek-ili9806e.c new file +10
-0+U_BOOT_DRIVER (ilitek_ili9806e) = { + .name ="ilitek_ili9806e" , + .id =UCLASS_PANEL , + .of_match = ilitek_ili9806e_ids, + .ops = &ilitek_ili9806e_ops, + .of_to_plat = ilitek_ili9806e_of_to_plat, + .probe = ilitek_ili9806e_probe, + .priv_auto =sizeof (struct ilitek_ili9806e_priv ), + .flags =DM_FLAG_PRE_RELOC , +};
Thanks
Patrice
Quoted 35 lines · Dario Binacchi
This series adds support for the Rocktech RK050HR345-CT106A panel. The initialization of this panel requires a 9-bit word length configuration. To support this, I have extended the STM32 SPI driver (including support for the STM32MP25 SoC) to implement the
set_wordlenoperation.To properly validate these changes and ensure the SPI uclass correctly handles the word length propagation, I have also implemented the corresponding logic in the sandbox driver and added a dedicated unit test.
I have grouped these patches together to provide a complete overview of the implementation and its verification.
Changes in v3:
- Use structspi_slavedata to access wordlen parameter instead of driver private data.
- Move thestm32_spi_is_enabled()helper to the new patch "spi: stm32: addstm32_spi_is_enabled()helper"
- Insert blank lines to separate code inilitek-ili9806e.cChanges in v2:
- Rplace tristate with bool indrivers/video/KconfigDario Binacchi (9):
spi: add support for bits-per-word setting
spi:sandbox_spi: support wordlen setup
test: spi: addsandbox_spi_get_wordleninterface
test: dm: spi: add testcase forspi_set_wordlen()
spi: stm32: clean up buffer length assignment
spi: stm32: addstm32_spi_is_enabled()helper
spi: stm32: add support for bits-per-word setting
spi: stm32: extend support to STM32MP25
video: support Rocktech RK050HR345-CT106A panel
Quoted 12 lines
arch/sandbox/include/asm/test.h | 8 + drivers/spi/sandbox_spi.c | 17 ++ drivers/spi/spi-uclass.c | 22 +- drivers/spi/stm32_spi.c | 71 ++++++- drivers/video/Kconfig | 8 + drivers/video/Makefile | 1 + drivers/video/ilitek-ili9806e.c | 356 ++++++++++++++++++++++++++++++++ include/spi.h | 14 ++ test/dm/spi.c | 16 ++ 9 files changed, 502 insertions(+), 11 deletions(-) create mode 100644 drivers/video/ilitek-ili9806e.c
For the whole series
Applied to u-boot-stm32/master
Thanks
Patrice