* [PATCH 0/2] drm/mipi-dbi: Allow using same the D/C GPIO for multiple displays @ 2023-07-19 9:53 Otto Pflüger 2023-07-19 9:53 ` [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO Otto Pflüger 2023-07-19 9:53 ` [PATCH 2/2] drm/tiny: panel-mipi-dbi: Allow sharing the " Otto Pflüger 0 siblings, 2 replies; 5+ messages in thread From: Otto Pflüger @ 2023-07-19 9:53 UTC (permalink / raw) To: dri-devel Cc: Thomas Zimmermann, Maxime Ripard, Noralf Trønnes, Otto Pflüger When multiple displays are connected to the same SPI bus, the data/command switch is sometimes considered part of the bus and is shared among the displays. This series adds the GPIO_FLAGS_BIT_NONEXCLUSIVE flag for this GPIO and SPI bus locking to the panel-mipi-dbi/drm_mipi_dbi drivers to support this hardware setup. Otto Pflüger (2): drm/mipi-dbi: Lock SPI bus before setting D/C GPIO drm/tiny: panel-mipi-dbi: Allow sharing the D/C GPIO drivers/gpu/drm/drm_mipi_dbi.c | 22 +++++++++++++++++----- drivers/gpu/drm/tiny/panel-mipi-dbi.c | 3 ++- include/drm/drm_mipi_dbi.h | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) -- 2.39.1 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO 2023-07-19 9:53 [PATCH 0/2] drm/mipi-dbi: Allow using same the D/C GPIO for multiple displays Otto Pflüger @ 2023-07-19 9:53 ` Otto Pflüger 2023-07-19 14:55 ` kernel test robot 2023-07-19 20:37 ` kernel test robot 2023-07-19 9:53 ` [PATCH 2/2] drm/tiny: panel-mipi-dbi: Allow sharing the " Otto Pflüger 1 sibling, 2 replies; 5+ messages in thread From: Otto Pflüger @ 2023-07-19 9:53 UTC (permalink / raw) To: dri-devel Cc: Thomas Zimmermann, Maxime Ripard, Noralf Trønnes, Otto Pflüger Multiple displays may be connected to the same bus and share a D/C GPIO, so the display driver needs exclusive access to the bus to ensure that it can control the D/C GPIO safely. Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de> --- drivers/gpu/drm/drm_mipi_dbi.c | 22 +++++++++++++++++----- include/drm/drm_mipi_dbi.h | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c index c871d9f096b8..c205b7594571 100644 --- a/drivers/gpu/drm/drm_mipi_dbi.c +++ b/drivers/gpu/drm/drm_mipi_dbi.c @@ -1140,10 +1140,13 @@ static int mipi_dbi_typec3_command_read(struct mipi_dbi *dbi, u8 *cmd, return -ENOMEM; tr[1].rx_buf = buf; + + spi_bus_lock(spi->controller); gpiod_set_value_cansleep(dbi->dc, 0); spi_message_init_with_transfers(&m, tr, ARRAY_SIZE(tr)); - ret = spi_sync(spi, &m); + ret = spi_sync_locked(spi, &m); + spi_bus_unlock(spi->controller); if (ret) goto err_free; @@ -1177,19 +1180,24 @@ static int mipi_dbi_typec3_command(struct mipi_dbi *dbi, u8 *cmd, MIPI_DBI_DEBUG_COMMAND(*cmd, par, num); + spi_bus_lock(spi->controller); gpiod_set_value_cansleep(dbi->dc, 0); speed_hz = mipi_dbi_spi_cmd_max_speed(spi, 1); - ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1); + ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1, true); + spi_bus_unlock(spi->controller); if (ret || !num) return ret; if (*cmd == MIPI_DCS_WRITE_MEMORY_START && !dbi->swap_bytes) bpw = 16; + spi_bus_lock(spi->controller); gpiod_set_value_cansleep(dbi->dc, 1); speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num); - return mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num); + ret = mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num, true); + spi_bus_unlock(spi->controller); + return ret; } /** @@ -1269,6 +1277,7 @@ EXPORT_SYMBOL(mipi_dbi_spi_init); * @bpw: Bits per word * @buf: Buffer to transfer * @len: Buffer length + * @is_locked: Is the SPI bus locked? * * This SPI transfer helper breaks up the transfer of @buf into chunks which * the SPI controller driver can handle. @@ -1277,7 +1286,7 @@ EXPORT_SYMBOL(mipi_dbi_spi_init); * Zero on success, negative error code on failure. */ int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, - u8 bpw, const void *buf, size_t len) + u8 bpw, const void *buf, size_t len, bool is_locked) { size_t max_chunk = spi_max_transfer_size(spi); struct spi_transfer tr = { @@ -1305,7 +1314,10 @@ int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, buf += chunk; len -= chunk; - ret = spi_sync(spi, &m); + if (is_locked) + ret = spi_sync_locked(spi, &m); + else + ret = spi_sync(spi, &m); if (ret) return ret; } diff --git a/include/drm/drm_mipi_dbi.h b/include/drm/drm_mipi_dbi.h index 816f196b3d4c..da632288aff9 100644 --- a/include/drm/drm_mipi_dbi.h +++ b/include/drm/drm_mipi_dbi.h @@ -185,7 +185,7 @@ int mipi_dbi_poweron_conditional_reset(struct mipi_dbi_dev *dbidev); u32 mipi_dbi_spi_cmd_max_speed(struct spi_device *spi, size_t len); int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, - u8 bpw, const void *buf, size_t len); + u8 bpw, const void *buf, size_t len, bool is_locked); int mipi_dbi_command_read(struct mipi_dbi *dbi, u8 cmd, u8 *val); int mipi_dbi_command_buf(struct mipi_dbi *dbi, u8 cmd, u8 *data, size_t len); -- 2.39.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO 2023-07-19 9:53 ` [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO Otto Pflüger @ 2023-07-19 14:55 ` kernel test robot 2023-07-19 20:37 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2023-07-19 14:55 UTC (permalink / raw) To: Otto Pflüger, dri-devel Cc: Otto Pflüger, Noralf Trønnes, Maxime Ripard, Thomas Zimmermann, oe-kbuild-all Hi Otto, kernel test robot noticed the following build errors: [auto build test ERROR on drm-misc/drm-misc-next] [also build test ERROR on drm/drm-next drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.5-rc2 next-20230719] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Otto-Pfl-ger/drm-mipi-dbi-Lock-SPI-bus-before-setting-D-C-GPIO/20230719-180941 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230719095343.88359-2-otto.pflueger%40abscue.de patch subject: [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO config: arc-randconfig-r022-20230718 (https://download.01.org/0day-ci/archive/20230719/202307192201.7i1HPQEe-lkp@intel.com/config) compiler: arceb-elf-gcc (GCC) 12.3.0 reproduce: (https://download.01.org/0day-ci/archive/20230719/202307192201.7i1HPQEe-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307192201.7i1HPQEe-lkp@intel.com/ All errors (new ones prefixed by >>): drivers/gpu/drm/tiny/ili9225.c: In function 'ili9225_dbi_command': >> drivers/gpu/drm/tiny/ili9225.c:321:15: error: too few arguments to function 'mipi_dbi_spi_transfer' 321 | ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1); | ^~~~~~~~~~~~~~~~~~~~~ In file included from drivers/gpu/drm/tiny/ili9225.c:30: include/drm/drm_mipi_dbi.h:187:5: note: declared here 187 | int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, | ^~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/tiny/ili9225.c:331:16: error: too few arguments to function 'mipi_dbi_spi_transfer' 331 | return mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num); | ^~~~~~~~~~~~~~~~~~~~~ include/drm/drm_mipi_dbi.h:187:5: note: declared here 187 | int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, | ^~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/tiny/ili9225.c:332:1: error: control reaches end of non-void function [-Werror=return-type] 332 | } | ^ cc1: some warnings being treated as errors vim +/mipi_dbi_spi_transfer +321 drivers/gpu/drm/tiny/ili9225.c b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 310 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 311 static int ili9225_dbi_command(struct mipi_dbi *dbi, u8 *cmd, u8 *par, b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 312 size_t num) b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 313 { 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 314 struct spi_device *spi = dbi->spi; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 315 unsigned int bpw = 8; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 316 u32 speed_hz; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 317 int ret; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 318 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 319 gpiod_set_value_cansleep(dbi->dc, 0); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 320 speed_hz = mipi_dbi_spi_cmd_max_speed(spi, 1); d23d4d4dac0119 drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-19 @321 ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 322 if (ret || !num) b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 323 return ret; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 324 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 325 if (*cmd == ILI9225_WRITE_DATA_TO_GRAM && !dbi->swap_bytes) b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 326 bpw = 16; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 327 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 328 gpiod_set_value_cansleep(dbi->dc, 1); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 329 speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 330 d23d4d4dac0119 drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-19 331 return mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 332 } b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 333 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO 2023-07-19 9:53 ` [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO Otto Pflüger 2023-07-19 14:55 ` kernel test robot @ 2023-07-19 20:37 ` kernel test robot 1 sibling, 0 replies; 5+ messages in thread From: kernel test robot @ 2023-07-19 20:37 UTC (permalink / raw) To: Otto Pflüger, dri-devel Cc: llvm, Maxime Ripard, Noralf Trønnes, Thomas Zimmermann, oe-kbuild-all, Otto Pflüger Hi Otto, kernel test robot noticed the following build errors: [auto build test ERROR on drm-misc/drm-misc-next] [also build test ERROR on drm/drm-next drm-exynos/exynos-drm-next drm-intel/for-linux-next drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.5-rc2 next-20230719] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Otto-Pfl-ger/drm-mipi-dbi-Lock-SPI-bus-before-setting-D-C-GPIO/20230719-180941 base: git://anongit.freedesktop.org/drm/drm-misc drm-misc-next patch link: https://lore.kernel.org/r/20230719095343.88359-2-otto.pflueger%40abscue.de patch subject: [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO config: riscv-randconfig-r042-20230720 (https://download.01.org/0day-ci/archive/20230720/202307200456.jGqv0OSC-lkp@intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a) reproduce: (https://download.01.org/0day-ci/archive/20230720/202307200456.jGqv0OSC-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202307200456.jGqv0OSC-lkp@intel.com/ All errors (new ones prefixed by >>): >> drivers/gpu/drm/tiny/ili9225.c:321:54: error: too few arguments to function call, expected 6, have 5 321 | ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1); | ~~~~~~~~~~~~~~~~~~~~~ ^ include/drm/drm_mipi_dbi.h:187:5: note: 'mipi_dbi_spi_transfer' declared here 187 | int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, | ^ drivers/gpu/drm/tiny/ili9225.c:331:59: error: too few arguments to function call, expected 6, have 5 331 | return mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num); | ~~~~~~~~~~~~~~~~~~~~~ ^ include/drm/drm_mipi_dbi.h:187:5: note: 'mipi_dbi_spi_transfer' declared here 187 | int mipi_dbi_spi_transfer(struct spi_device *spi, u32 speed_hz, | ^ 2 errors generated. vim +321 drivers/gpu/drm/tiny/ili9225.c b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 310 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 311 static int ili9225_dbi_command(struct mipi_dbi *dbi, u8 *cmd, u8 *par, b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 312 size_t num) b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 313 { 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 314 struct spi_device *spi = dbi->spi; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 315 unsigned int bpw = 8; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 316 u32 speed_hz; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 317 int ret; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 318 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 319 gpiod_set_value_cansleep(dbi->dc, 0); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 320 speed_hz = mipi_dbi_spi_cmd_max_speed(spi, 1); d23d4d4dac0119 drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-19 @321 ret = mipi_dbi_spi_transfer(spi, speed_hz, 8, cmd, 1); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 322 if (ret || !num) b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 323 return ret; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 324 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 325 if (*cmd == ILI9225_WRITE_DATA_TO_GRAM && !dbi->swap_bytes) b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 326 bpw = 16; b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 327 36b5057216236a drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-22 328 gpiod_set_value_cansleep(dbi->dc, 1); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 329 speed_hz = mipi_dbi_spi_cmd_max_speed(spi, num); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 330 d23d4d4dac0119 drivers/gpu/drm/tinydrm/ili9225.c Noralf Trønnes 2019-07-19 331 return mipi_dbi_spi_transfer(spi, speed_hz, bpw, par, num); b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 332 } b57e8b7661e046 drivers/gpu/drm/tinydrm/ili9225.c David Lechner 2017-11-19 333 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] drm/tiny: panel-mipi-dbi: Allow sharing the D/C GPIO 2023-07-19 9:53 [PATCH 0/2] drm/mipi-dbi: Allow using same the D/C GPIO for multiple displays Otto Pflüger 2023-07-19 9:53 ` [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO Otto Pflüger @ 2023-07-19 9:53 ` Otto Pflüger 1 sibling, 0 replies; 5+ messages in thread From: Otto Pflüger @ 2023-07-19 9:53 UTC (permalink / raw) To: dri-devel Cc: Thomas Zimmermann, Maxime Ripard, Noralf Trønnes, Otto Pflüger Displays that are connected to the same SPI bus may share the D/C GPIO. Use GPIOD_FLAGS_BIT_NONEXCLUSIVE to allow access to the same GPIO for multiple panel-mipi-dbi instances. Exclusive access to the GPIO during transfers is ensured by the locking in drm_mipi_dbi.c. Signed-off-by: Otto Pflüger <otto.pflueger@abscue.de> --- drivers/gpu/drm/tiny/panel-mipi-dbi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tiny/panel-mipi-dbi.c b/drivers/gpu/drm/tiny/panel-mipi-dbi.c index eb9f13f18a02..e616e3890043 100644 --- a/drivers/gpu/drm/tiny/panel-mipi-dbi.c +++ b/drivers/gpu/drm/tiny/panel-mipi-dbi.c @@ -307,7 +307,8 @@ static int panel_mipi_dbi_spi_probe(struct spi_device *spi) if (IS_ERR(dbi->reset)) return dev_err_probe(dev, PTR_ERR(dbi->reset), "Failed to get GPIO 'reset'\n"); - dc = devm_gpiod_get_optional(dev, "dc", GPIOD_OUT_LOW); + dc = devm_gpiod_get_optional(dev, "dc", + GPIOD_OUT_LOW | GPIOD_FLAGS_BIT_NONEXCLUSIVE); if (IS_ERR(dc)) return dev_err_probe(dev, PTR_ERR(dc), "Failed to get GPIO 'dc'\n"); -- 2.39.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-07-19 20:38 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-07-19 9:53 [PATCH 0/2] drm/mipi-dbi: Allow using same the D/C GPIO for multiple displays Otto Pflüger 2023-07-19 9:53 ` [PATCH 1/2] drm/mipi-dbi: Lock SPI bus before setting D/C GPIO Otto Pflüger 2023-07-19 14:55 ` kernel test robot 2023-07-19 20:37 ` kernel test robot 2023-07-19 9:53 ` [PATCH 2/2] drm/tiny: panel-mipi-dbi: Allow sharing the " Otto Pflüger
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox