[PATCH v1 3/3] drm/stm: Add STM32 DSI host driver
This mipi dsi host driver is based on the Rockchip version of the Synopsys Designware mipi dsi driver (rockchip/dw-mipi-dsi.c) modified for the stm32 family: - replace Rockchip digital & phy specific extensions with stm32's ones. - add a bridge Signed-off-by: Philippe CORNU --- drivers/gpu/drm/stm/Kconfig |7 + drivers/gpu/drm/stm/Makefile |2 + drivers/gpu/drm/stm/dw-mipi-dsi.c | 1197 + 3 files changed, 1206 insertions(+) create mode 100644 drivers/gpu/drm/stm/dw-mipi-dsi.c diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig index 2c4817f..0007789 100644 --- a/drivers/gpu/drm/stm/Kconfig +++ b/drivers/gpu/drm/stm/Kconfig @@ -14,3 +14,10 @@ config DRM_STM STMicroelectronics STM32 MCUs. To compile this driver as a module, choose M here: the module will be called stm-drm. + +config DRM_STM_DSI + tristate "MIPI DSI support for STMicroelectronics SoC" + depends on DRM_STM + select DRM_MIPI_DSI + help + Choose this option for MIPI DSI support on STMicroelectronics SoC. diff --git a/drivers/gpu/drm/stm/Makefile b/drivers/gpu/drm/stm/Makefile index e114d45..e448a93 100644 --- a/drivers/gpu/drm/stm/Makefile +++ b/drivers/gpu/drm/stm/Makefile @@ -4,4 +4,6 @@ stm-drm-y := \ drv.o \ ltdc.o +obj-$(CONFIG_DRM_STM_DSI) += dw-mipi-dsi.o + obj-$(CONFIG_DRM_STM) += stm-drm.o diff --git a/drivers/gpu/drm/stm/dw-mipi-dsi.c b/drivers/gpu/drm/stm/dw-mipi-dsi.c new file mode 100644 index 000..4b7f7b9 --- /dev/null +++ b/drivers/gpu/drm/stm/dw-mipi-dsi.c @@ -0,0 +1,1197 @@ +/* + * Copyright (c) 2016, Fuzhou Rockchip Electronics Co., Ltd + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Modified by Philippe Cornu for the stm32 family. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DRIVER_NAME"dw-mipi-dsi" + +#define DSI_VERSION0x00 +#define DSI_PWR_UP 0x04 +#define RESET 0 +#define POWERUPBIT(0) + +#define DSI_CLKMGR_CFG 0x08 +#define TO_CLK_DIVIDSION(div) (((div) & 0xff) << 8) +#define TX_ESC_CLK_DIVIDSION(div) (((div) & 0xff) << 0) + +#define DSI_DPI_VCID 0x0c +#define DPI_VID(vid) (((vid) & 0x3) << 0) + +#define DSI_DPI_COLOR_CODING 0x10 +#define EN18_LOOSELY BIT(8) +#define DPI_COLOR_CODING_16BIT_1 0x0 +#define DPI_COLOR_CODING_16BIT_2 0x1 +#define DPI_COLOR_CODING_16BIT_3 0x2 +#define DPI_COLOR_CODING_18BIT_1 0x3 +#define DPI_COLOR_CODING_18BIT_2 0x4 +#define DPI_COLOR_CODING_24BIT 0x5 + +#define DSI_DPI_CFG_POL0x14 +#define COLORM_ACTIVE_LOW BIT(4) +#define SHUTD_ACTIVE_LOW BIT(3) +#define HSYNC_ACTIVE_LOW BIT(2) +#define VSYNC_ACTIVE_LOW BIT(1) +#define DATAEN_ACTIVE_LOW BIT(0) + +#define DSI_DPI_LP_CMD_TIM 0x18 +#define OUTVACT_LPCMD_TIME(p) (((p) & 0xff) << 16) +#define INVACT_LPCMD_TIME(p) ((p) & 0xff) + +#define DSI_DBI_CFG0x20 +#define DSI_DBI_CMDSIZE0x28 + +#define DSI_PCKHDL_CFG 0x2c +#define EN_CRC_RX BIT(4) +#define EN_ECC_RX BIT(3) +#define EN_BTA BIT(2) +#define EN_EOTP_RX BIT(1) +#define EN_EOTP_TX BIT(0) + +#define DSI_MODE_CFG 0x34 +#define ENABLE_VIDEO_MODE 0 +#define ENABLE_CMD_MODEBIT(0) + +#define DSI_VID_MODE_CFG 0x38 +#define FRAME_BTA_ACK BIT(14) +#define ENABLE_LOW_POWER (0x3f << 8) +#define ENABLE_LOW_POWER_MASK (0x3f << 8) +#define VID_MODE_TYPE_NON_BURST_SYNC_PULSES0x0 +#define VID_MODE_TYPE_NON_BURST_SYNC_EVENTS0x1 +#define VID_MODE_TYPE_BURST0x2 +#define VID_MODE_TYPE_MASK 0x3 + +#define DSI_VID_PKT_SIZE 0x3c +#define VID_PKT_SIZE(p)(((p) & 0x3fff) << 0) +#define VID_PKT_MAX_SIZE 0x3fff + +#define DSI_VID_HSA_TIME 0x48 +#define DSI_VID_HBP_TIME 0x4c +#define DSI_VID_HLINE_TIME 0x50 +#define DSI_VID_VSA_LINES 0x54 +#define DSI_VID_VBP_LINES 0x58 +#define DSI_VID_VFP_LINES 0x5c +#define DSI_VID_VACTIVE_LINES 0x60 +#define DSI_CMD_MODE_CFG 0
Re: [PATCH v1 3/3] drm/stm: Add STM32 DSI host driver
On 05/12/2017 04:56 PM, Philippe CORNU wrote: > This mipi dsi host driver is based on the Rockchip version of the > Synopsys Designware mipi dsi driver (rockchip/dw-mipi-dsi.c) > modified for the stm32 family: > - replace Rockchip digital & phy specific extensions with stm32's ones. > - add a bridge > > Signed-off-by: Philippe CORNU > --- > drivers/gpu/drm/stm/Kconfig |7 + > drivers/gpu/drm/stm/Makefile |2 + > drivers/gpu/drm/stm/dw-mipi-dsi.c | 1197 > + > 3 files changed, 1206 insertions(+) > create mode 100644 drivers/gpu/drm/stm/dw-mipi-dsi.c > > diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig > index 2c4817f..0007789 100644 > --- a/drivers/gpu/drm/stm/Kconfig > +++ b/drivers/gpu/drm/stm/Kconfig > @@ -14,3 +14,10 @@ config DRM_STM > STMicroelectronics STM32 MCUs. > To compile this driver as a module, choose M here: the module > will be called stm-drm. > + > +config DRM_STM_DSI > + tristate "MIPI DSI support for STMicroelectronics SoC" > + depends on DRM_STM > + select DRM_MIPI_DSI > + help > + Choose this option for MIPI DSI support on STMicroelectronics SoC. > diff --git a/drivers/gpu/drm/stm/Makefile b/drivers/gpu/drm/stm/Makefile > index e114d45..e448a93 100644 > --- a/drivers/gpu/drm/stm/Makefile > +++ b/drivers/gpu/drm/stm/Makefile > @@ -4,4 +4,6 @@ stm-drm-y := \ > drv.o \ > ltdc.o > > +obj-$(CONFIG_DRM_STM_DSI) += dw-mipi-dsi.o > + > obj-$(CONFIG_DRM_STM) += stm-drm.o > diff --git a/drivers/gpu/drm/stm/dw-mipi-dsi.c > b/drivers/gpu/drm/stm/dw-mipi-dsi.c > new file mode 100644 > index 000..4b7f7b9 > --- /dev/null > +++ b/drivers/gpu/drm/stm/dw-mipi-dsi.c Hi Philippe, First question, why couldn't this be transformed as a bridge driver along the Synopsys DW-HDMI driver ? Neil ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v1 3/3] drm/stm: Add STM32 DSI host driver
Hi Philippe, (please avoid top posting) On 05/15/2017 12:33 PM, Philippe CORNU wrote: > Hi Neil, > Many thanks for your comments. > > The PHY part of the MIPI DSI is the main difference between all chipsets > based on the Synopsys DesignWare MIPI DSI. > There is no "generic DSI PHY interface" and that is probably why all soc > vendors have implemented their own drivers (RockChip, NXP/Freescale, > HiSilicon and now STM32). Sure, this is the same with the DW-HDMI, there is a Synopsys PHY, but also vendor PHYs. > > Regarding creating a "generic dw MIPI DSI bridge" as the recent dw hdmi > bridge, several attempts have been done in the past but without success: > * Liu Ying from Freescale in February 2015 > (https://lkml.org/lkml/2015/2/12/38). > * Chris Zhong from Rockchip in November 2015 > (http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1024586.html). "Impossible n'est pas français !" (Georges Courteline, Le 51e Chasseurs, Marpon et Flammario, 1887, p. 23) I think it's worth the try, and will avoid a lot of code duplication among these drivers. And since it's a Synopsys IP, it will continue to appear in current and future SoCs. > > The Rockchip driver looks nice and is updated regularly. > So, instead of creating a new driver for the STM32 family, we decided to > use Rockchip’s in our own drm/stm directory and replace the > Rockchip-specific PHY by the STM32. Sure, it looks OK. Archit, any advices here ? > Comments are welcome :-) > Many thanks, > Philippe Thanks, Neil > > On 05/15/2017 10:22 AM, Neil Armstrong wrote: >> On 05/12/2017 04:56 PM, Philippe CORNU wrote: >>> This mipi dsi host driver is based on the Rockchip version of the >>> Synopsys Designware mipi dsi driver (rockchip/dw-mipi-dsi.c) >>> modified for the stm32 family: >>> - replace Rockchip digital & phy specific extensions with stm32's ones. >>> - add a bridge >>> >>> Signed-off-by: Philippe CORNU >>> --- >>> drivers/gpu/drm/stm/Kconfig |7 + >>> drivers/gpu/drm/stm/Makefile |2 + >>> drivers/gpu/drm/stm/dw-mipi-dsi.c | 1197 >>> + >>> 3 files changed, 1206 insertions(+) >>> create mode 100644 drivers/gpu/drm/stm/dw-mipi-dsi.c >>> >>> diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig >>> index 2c4817f..0007789 100644 >>> --- a/drivers/gpu/drm/stm/Kconfig >>> +++ b/drivers/gpu/drm/stm/Kconfig >>> @@ -14,3 +14,10 @@ config DRM_STM >>> STMicroelectronics STM32 MCUs. >>> To compile this driver as a module, choose M here: the module >>> will be called stm-drm. >>> + >>> +config DRM_STM_DSI >>> + tristate "MIPI DSI support for STMicroelectronics SoC" >>> + depends on DRM_STM >>> + select DRM_MIPI_DSI >>> + help >>> + Choose this option for MIPI DSI support on STMicroelectronics SoC. >>> diff --git a/drivers/gpu/drm/stm/Makefile b/drivers/gpu/drm/stm/Makefile >>> index e114d45..e448a93 100644 >>> --- a/drivers/gpu/drm/stm/Makefile >>> +++ b/drivers/gpu/drm/stm/Makefile >>> @@ -4,4 +4,6 @@ stm-drm-y := \ >>> drv.o \ >>> ltdc.o >>> >>> +obj-$(CONFIG_DRM_STM_DSI) += dw-mipi-dsi.o >>> + >>> obj-$(CONFIG_DRM_STM) += stm-drm.o >>> diff --git a/drivers/gpu/drm/stm/dw-mipi-dsi.c >>> b/drivers/gpu/drm/stm/dw-mipi-dsi.c >>> new file mode 100644 >>> index 000..4b7f7b9 >>> --- /dev/null >>> +++ b/drivers/gpu/drm/stm/dw-mipi-dsi.c >> >> >> Hi Philippe, >> >> First question, why couldn't this be transformed as a bridge driver along >> the Synopsys DW-HDMI driver ? >> >> Neil >> > ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v1 3/3] drm/stm: Add STM32 DSI host driver
Hi Neil, Many thanks for your comments. The PHY part of the MIPI DSI is the main difference between all chipsets based on the Synopsys DesignWare MIPI DSI. There is no "generic DSI PHY interface" and that is probably why all soc vendors have implemented their own drivers (RockChip, NXP/Freescale, HiSilicon and now STM32). Regarding creating a "generic dw MIPI DSI bridge" as the recent dw hdmi bridge, several attempts have been done in the past but without success: * Liu Ying from Freescale in February 2015 (https://lkml.org/lkml/2015/2/12/38). * Chris Zhong from Rockchip in November 2015 (http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1024586.html). The Rockchip driver looks nice and is updated regularly. So, instead of creating a new driver for the STM32 family, we decided to use Rockchip’s in our own drm/stm directory and replace the Rockchip-specific PHY by the STM32. Comments are welcome :-) Many thanks, Philippe On 05/15/2017 10:22 AM, Neil Armstrong wrote: > On 05/12/2017 04:56 PM, Philippe CORNU wrote: >> This mipi dsi host driver is based on the Rockchip version of the >> Synopsys Designware mipi dsi driver (rockchip/dw-mipi-dsi.c) >> modified for the stm32 family: >> - replace Rockchip digital & phy specific extensions with stm32's ones. >> - add a bridge >> >> Signed-off-by: Philippe CORNU >> --- >> drivers/gpu/drm/stm/Kconfig |7 + >> drivers/gpu/drm/stm/Makefile |2 + >> drivers/gpu/drm/stm/dw-mipi-dsi.c | 1197 >> + >> 3 files changed, 1206 insertions(+) >> create mode 100644 drivers/gpu/drm/stm/dw-mipi-dsi.c >> >> diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig >> index 2c4817f..0007789 100644 >> --- a/drivers/gpu/drm/stm/Kconfig >> +++ b/drivers/gpu/drm/stm/Kconfig >> @@ -14,3 +14,10 @@ config DRM_STM >>STMicroelectronics STM32 MCUs. >>To compile this driver as a module, choose M here: the module >>will be called stm-drm. >> + >> +config DRM_STM_DSI >> +tristate "MIPI DSI support for STMicroelectronics SoC" >> +depends on DRM_STM >> +select DRM_MIPI_DSI >> +help >> + Choose this option for MIPI DSI support on STMicroelectronics SoC. >> diff --git a/drivers/gpu/drm/stm/Makefile b/drivers/gpu/drm/stm/Makefile >> index e114d45..e448a93 100644 >> --- a/drivers/gpu/drm/stm/Makefile >> +++ b/drivers/gpu/drm/stm/Makefile >> @@ -4,4 +4,6 @@ stm-drm-y := \ >> drv.o \ >> ltdc.o >> >> +obj-$(CONFIG_DRM_STM_DSI) += dw-mipi-dsi.o >> + >> obj-$(CONFIG_DRM_STM) += stm-drm.o >> diff --git a/drivers/gpu/drm/stm/dw-mipi-dsi.c >> b/drivers/gpu/drm/stm/dw-mipi-dsi.c >> new file mode 100644 >> index 000..4b7f7b9 >> --- /dev/null >> +++ b/drivers/gpu/drm/stm/dw-mipi-dsi.c > > > Hi Philippe, > > First question, why couldn't this be transformed as a bridge driver along the > Synopsys DW-HDMI driver ? > > Neil > ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v1 3/3] drm/stm: Add STM32 DSI host driver
Hi, On 05/15/2017 04:03 PM, Philippe CORNU wrote: Hi Neil, Many thanks for your comments. The PHY part of the MIPI DSI is the main difference between all chipsets based on the Synopsys DesignWare MIPI DSI. There is no "generic DSI PHY interface" and that is probably why all soc vendors have implemented their own drivers (RockChip, NXP/Freescale, HiSilicon and now STM32). We don't really need a generic DSI PHY interface to ensure we use a common bridge driver. We need to do what's been done in the DW HDMI bridge driver. The dw_hdmi_plat_data struct contains phy ops, which can be used to abstract vendor PHYs. Regarding creating a "generic dw MIPI DSI bridge" as the recent dw hdmi bridge, several attempts have been done in the past but without success: * Liu Ying from Freescale in February 2015 (https://lkml.org/lkml/2015/2/12/38). * Chris Zhong from Rockchip in November 2015 (http://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1024586.html). We can't have 3 almost identical DW MIPI DSI implementations in the kernel. You'll need to separate out the vendor specific PHY pieces into ops (like it's done in the DW HDMI) and post a bridge driver for this. You don't need to convert the existing rockhip and hisilicon implementations into bridge drivers. We can CC the authors of the rockchip and hisil so that they can adapt to the bridge driver too. Thanks, Archit The Rockchip driver looks nice and is updated regularly. So, instead of creating a new driver for the STM32 family, we decided to use Rockchip’s in our own drm/stm directory and replace the Rockchip-specific PHY by the STM32. Comments are welcome :-) Many thanks, Philippe On 05/15/2017 10:22 AM, Neil Armstrong wrote: On 05/12/2017 04:56 PM, Philippe CORNU wrote: This mipi dsi host driver is based on the Rockchip version of the Synopsys Designware mipi dsi driver (rockchip/dw-mipi-dsi.c) modified for the stm32 family: - replace Rockchip digital & phy specific extensions with stm32's ones. - add a bridge Signed-off-by: Philippe CORNU --- drivers/gpu/drm/stm/Kconfig |7 + drivers/gpu/drm/stm/Makefile |2 + drivers/gpu/drm/stm/dw-mipi-dsi.c | 1197 + 3 files changed, 1206 insertions(+) create mode 100644 drivers/gpu/drm/stm/dw-mipi-dsi.c diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig index 2c4817f..0007789 100644 --- a/drivers/gpu/drm/stm/Kconfig +++ b/drivers/gpu/drm/stm/Kconfig @@ -14,3 +14,10 @@ config DRM_STM STMicroelectronics STM32 MCUs. To compile this driver as a module, choose M here: the module will be called stm-drm. + +config DRM_STM_DSI + tristate "MIPI DSI support for STMicroelectronics SoC" + depends on DRM_STM + select DRM_MIPI_DSI + help + Choose this option for MIPI DSI support on STMicroelectronics SoC. diff --git a/drivers/gpu/drm/stm/Makefile b/drivers/gpu/drm/stm/Makefile index e114d45..e448a93 100644 --- a/drivers/gpu/drm/stm/Makefile +++ b/drivers/gpu/drm/stm/Makefile @@ -4,4 +4,6 @@ stm-drm-y := \ drv.o \ ltdc.o +obj-$(CONFIG_DRM_STM_DSI) += dw-mipi-dsi.o + obj-$(CONFIG_DRM_STM) += stm-drm.o diff --git a/drivers/gpu/drm/stm/dw-mipi-dsi.c b/drivers/gpu/drm/stm/dw-mipi-dsi.c new file mode 100644 index 000..4b7f7b9 --- /dev/null +++ b/drivers/gpu/drm/stm/dw-mipi-dsi.c Hi Philippe, First question, why couldn't this be transformed as a bridge driver along the Synopsys DW-HDMI driver ? Neil ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel