[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
Dear Archit, Thanks a lot for your reviewing. I have sent a new patchset for those review items. On Fri, 2016-11-11 at 11:32 +0530, Archit Taneja wrote: > Hi Jitao, > > I couldn't locate the original mail, so posting on this thread instead. > Some comments below. > > On 11/10/2016 10:09 PM, Enric Balletbo Serra wrote: > > Hi Jitao, > > > > 2016-08-27 8:44 GMT+02:00 Jitao Shi : > >> This patch adds drm_bridge driver for parade DSI to eDP bridge chip. > >> > >> Signed-off-by: Jitao Shi > >> Reviewed-by: Daniel Kurtz > >> --- > >> Changes since v16: > >> - Disable ps8640 DSI MCS Function. > >> - Rename gpios name more clearly. > >> - Tune the ps8640 power on sequence. > >> > >> Changes since v15: > >> - Drop drm_connector_(un)register calls from parade ps8640. > >>The main DRM driver mtk_drm_drv now calls > >>drm_connector_register_all() after drm_dev_register() in the > >>mtk_drm_bind() function. That function should iterate over all > >>connectors and call drm_connector_register() for each of them. > >>So, remove drm_connector_(un)register calls from parade ps8640. > >> > >> Changes since v14: > >> - update copyright info. > >> - change bridge_to_ps8640 and connector_to_ps8640 to inline function. > >> - fix some coding style. > >> - use sizeof as array counter. > >> - use drm_get_edid when read edid. > >> - add mutex when firmware updating. > >> > >> Changes since v13: > >> - add const on data, ps8640_write_bytes(struct i2c_client *client, const > >> u8 *data, u16 data_len) > >> - fix PAGE2_SW_REST tyro. > >> - move the buf[3] init to entrance of the function. > >> > >> Changes since v12: > >> - fix hw_chip_id build warning > >> > >> Changes since v11: > >> - Remove depends on I2C, add DRM depends > >> - Reuse ps8640_write_bytes() in ps8640_write_byte() > >> - Use timer check for polling like the routines in > >> - Fix no drm_connector_unregister/drm_connector_cleanup when > >> ps8640_bridge_attach fail > >> - Check the ps8640 hardware id in ps8640_validate_firmware > >> - Remove fw_version check > >> - Move ps8640_validate_firmware before ps8640_enter_bl > >> - Add ddc_i2c unregister when probe fail and ps8640_remove > >> --- > >> drivers/gpu/drm/bridge/Kconfig | 12 + > >> drivers/gpu/drm/bridge/Makefile|1 + > >> drivers/gpu/drm/bridge/parade-ps8640.c | 1077 > >> > >> 3 files changed, 1090 insertions(+) > >> create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c > >> > >> diff --git a/drivers/gpu/drm/bridge/Kconfig > >> b/drivers/gpu/drm/bridge/Kconfig > >> index b590e67..c59d043 100644 > >> --- a/drivers/gpu/drm/bridge/Kconfig > >> +++ b/drivers/gpu/drm/bridge/Kconfig > >> @@ -50,6 +50,18 @@ config DRM_PARADE_PS8622 > >> ---help--- > >> Parade eDP-LVDS bridge chip driver. > >> > >> +config DRM_PARADE_PS8640 > >> + tristate "Parade PS8640 MIPI DSI to eDP Converter" > >> + depends on DRM > >> + depends on OF > >> + select DRM_KMS_HELPER > >> + select DRM_MIPI_DSI > >> + select DRM_PANEL > >> + ---help--- > >> + Choose this option if you have PS8640 for display > >> + The PS8640 is a high-performance and low-power > >> + MIPI DSI to eDP converter > >> + > >> config DRM_SII902X > >> tristate "Silicon Image sii902x RGB/HDMI bridge" > >> depends on OF > >> diff --git a/drivers/gpu/drm/bridge/Makefile > >> b/drivers/gpu/drm/bridge/Makefile > >> index efdb07e..3360537 100644 > >> --- a/drivers/gpu/drm/bridge/Makefile > >> +++ b/drivers/gpu/drm/bridge/Makefile > >> @@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o > >> obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o > >> obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o > >> obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o > >> +obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o > >> obj-$(CONFIG_DRM_SII902X) += sii902x.o > >> obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o > >> obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/ > >> diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c > >> b/drivers/gpu/drm/bridge/parade-ps8640.c > >> new file mode 100644 > >> index 000..7d67431 > >> --- /dev/null > >> +++ b/drivers/gpu/drm/bridge/parade-ps8640.c > >> @@ -0,0 +1,1077 @@ > >> +/* > >> + * Copyright (c) 2016 MediaTek Inc. > >> + * > >> + * This program is free software; you can redistribute it and/or modify > >> + * it under the terms of the GNU General Public License version 2 as > >> + * published by the Free Software Foundation. > >> + * > >> + * This program is distributed in the hope that it will be useful, > >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of > >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > >> + * GNU General Public License for more details. > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> +#include > > Not needed. > > >> +#include > >>
[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
Hi Jitao, I couldn't locate the original mail, so posting on this thread instead. Some comments below. On 11/10/2016 10:09 PM, Enric Balletbo Serra wrote: > Hi Jitao, > > 2016-08-27 8:44 GMT+02:00 Jitao Shi : >> This patch adds drm_bridge driver for parade DSI to eDP bridge chip. >> >> Signed-off-by: Jitao Shi >> Reviewed-by: Daniel Kurtz >> --- >> Changes since v16: >> - Disable ps8640 DSI MCS Function. >> - Rename gpios name more clearly. >> - Tune the ps8640 power on sequence. >> >> Changes since v15: >> - Drop drm_connector_(un)register calls from parade ps8640. >>The main DRM driver mtk_drm_drv now calls >>drm_connector_register_all() after drm_dev_register() in the >>mtk_drm_bind() function. That function should iterate over all >>connectors and call drm_connector_register() for each of them. >>So, remove drm_connector_(un)register calls from parade ps8640. >> >> Changes since v14: >> - update copyright info. >> - change bridge_to_ps8640 and connector_to_ps8640 to inline function. >> - fix some coding style. >> - use sizeof as array counter. >> - use drm_get_edid when read edid. >> - add mutex when firmware updating. >> >> Changes since v13: >> - add const on data, ps8640_write_bytes(struct i2c_client *client, const u8 >> *data, u16 data_len) >> - fix PAGE2_SW_REST tyro. >> - move the buf[3] init to entrance of the function. >> >> Changes since v12: >> - fix hw_chip_id build warning >> >> Changes since v11: >> - Remove depends on I2C, add DRM depends >> - Reuse ps8640_write_bytes() in ps8640_write_byte() >> - Use timer check for polling like the routines in >> - Fix no drm_connector_unregister/drm_connector_cleanup when >> ps8640_bridge_attach fail >> - Check the ps8640 hardware id in ps8640_validate_firmware >> - Remove fw_version check >> - Move ps8640_validate_firmware before ps8640_enter_bl >> - Add ddc_i2c unregister when probe fail and ps8640_remove >> --- >> drivers/gpu/drm/bridge/Kconfig | 12 + >> drivers/gpu/drm/bridge/Makefile|1 + >> drivers/gpu/drm/bridge/parade-ps8640.c | 1077 >> >> 3 files changed, 1090 insertions(+) >> create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c >> >> diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig >> index b590e67..c59d043 100644 >> --- a/drivers/gpu/drm/bridge/Kconfig >> +++ b/drivers/gpu/drm/bridge/Kconfig >> @@ -50,6 +50,18 @@ config DRM_PARADE_PS8622 >> ---help--- >> Parade eDP-LVDS bridge chip driver. >> >> +config DRM_PARADE_PS8640 >> + tristate "Parade PS8640 MIPI DSI to eDP Converter" >> + depends on DRM >> + depends on OF >> + select DRM_KMS_HELPER >> + select DRM_MIPI_DSI >> + select DRM_PANEL >> + ---help--- >> + Choose this option if you have PS8640 for display >> + The PS8640 is a high-performance and low-power >> + MIPI DSI to eDP converter >> + >> config DRM_SII902X >> tristate "Silicon Image sii902x RGB/HDMI bridge" >> depends on OF >> diff --git a/drivers/gpu/drm/bridge/Makefile >> b/drivers/gpu/drm/bridge/Makefile >> index efdb07e..3360537 100644 >> --- a/drivers/gpu/drm/bridge/Makefile >> +++ b/drivers/gpu/drm/bridge/Makefile >> @@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o >> obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o >> obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o >> obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o >> +obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o >> obj-$(CONFIG_DRM_SII902X) += sii902x.o >> obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o >> obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/ >> diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c >> b/drivers/gpu/drm/bridge/parade-ps8640.c >> new file mode 100644 >> index 000..7d67431 >> --- /dev/null >> +++ b/drivers/gpu/drm/bridge/parade-ps8640.c >> @@ -0,0 +1,1077 @@ >> +/* >> + * Copyright (c) 2016 MediaTek Inc. >> + * >> + * This program is free software; you can redistribute it and/or modify >> + * it under the terms of the GNU General Public License version 2 as >> + * published by the Free Software Foundation. >> + * >> + * This program is distributed in the hope that it will be useful, >> + * but WITHOUT ANY WARRANTY; without even the implied warranty of >> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >> + * GNU General Public License for more details. >> + */ >> + >> +#include >> +#include >> +#include >> +#include Not needed. >> +#include >> +#include >> +#include >> +#include >> +#include The above 2 aren't needed. >> +#include >> +#include >> +#include >> +#include >> + >> +#include >> +#include >> +#include >> +#include Not needed. >> +#include >> +#include >> + >> +#define PAGE1_VSTART 0x6b >> +#define PAGE2_SPI_CFG3 0x82 >> +#define I2C_TO_SPI_RESET 0x20 >> +#define PAGE2_ROMADD_BYTE1 0x8e >> +#define
[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
Hi Jitao, 2016-08-27 8:44 GMT+02:00 Jitao Shi : > This patch adds drm_bridge driver for parade DSI to eDP bridge chip. > > Signed-off-by: Jitao Shi > Reviewed-by: Daniel Kurtz > --- > Changes since v16: > - Disable ps8640 DSI MCS Function. > - Rename gpios name more clearly. > - Tune the ps8640 power on sequence. > > Changes since v15: > - Drop drm_connector_(un)register calls from parade ps8640. >The main DRM driver mtk_drm_drv now calls >drm_connector_register_all() after drm_dev_register() in the >mtk_drm_bind() function. That function should iterate over all >connectors and call drm_connector_register() for each of them. >So, remove drm_connector_(un)register calls from parade ps8640. > > Changes since v14: > - update copyright info. > - change bridge_to_ps8640 and connector_to_ps8640 to inline function. > - fix some coding style. > - use sizeof as array counter. > - use drm_get_edid when read edid. > - add mutex when firmware updating. > > Changes since v13: > - add const on data, ps8640_write_bytes(struct i2c_client *client, const u8 > *data, u16 data_len) > - fix PAGE2_SW_REST tyro. > - move the buf[3] init to entrance of the function. > > Changes since v12: > - fix hw_chip_id build warning > > Changes since v11: > - Remove depends on I2C, add DRM depends > - Reuse ps8640_write_bytes() in ps8640_write_byte() > - Use timer check for polling like the routines in > - Fix no drm_connector_unregister/drm_connector_cleanup when > ps8640_bridge_attach fail > - Check the ps8640 hardware id in ps8640_validate_firmware > - Remove fw_version check > - Move ps8640_validate_firmware before ps8640_enter_bl > - Add ddc_i2c unregister when probe fail and ps8640_remove > --- > drivers/gpu/drm/bridge/Kconfig | 12 + > drivers/gpu/drm/bridge/Makefile|1 + > drivers/gpu/drm/bridge/parade-ps8640.c | 1077 > > 3 files changed, 1090 insertions(+) > create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c > > diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig > index b590e67..c59d043 100644 > --- a/drivers/gpu/drm/bridge/Kconfig > +++ b/drivers/gpu/drm/bridge/Kconfig > @@ -50,6 +50,18 @@ config DRM_PARADE_PS8622 > ---help--- > Parade eDP-LVDS bridge chip driver. > > +config DRM_PARADE_PS8640 > + tristate "Parade PS8640 MIPI DSI to eDP Converter" > + depends on DRM > + depends on OF > + select DRM_KMS_HELPER > + select DRM_MIPI_DSI > + select DRM_PANEL > + ---help--- > + Choose this option if you have PS8640 for display > + The PS8640 is a high-performance and low-power > + MIPI DSI to eDP converter > + > config DRM_SII902X > tristate "Silicon Image sii902x RGB/HDMI bridge" > depends on OF > diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile > index efdb07e..3360537 100644 > --- a/drivers/gpu/drm/bridge/Makefile > +++ b/drivers/gpu/drm/bridge/Makefile > @@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o > obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o > obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o > obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o > +obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o > obj-$(CONFIG_DRM_SII902X) += sii902x.o > obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o > obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/ > diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c > b/drivers/gpu/drm/bridge/parade-ps8640.c > new file mode 100644 > index 000..7d67431 > --- /dev/null > +++ b/drivers/gpu/drm/bridge/parade-ps8640.c > @@ -0,0 +1,1077 @@ > +/* > + * Copyright (c) 2016 MediaTek Inc. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define PAGE1_VSTART 0x6b > +#define PAGE2_SPI_CFG3 0x82 > +#define I2C_TO_SPI_RESET 0x20 > +#define PAGE2_ROMADD_BYTE1 0x8e > +#define PAGE2_ROMADD_BYTE2 0x8f > +#define PAGE2_SWSPI_WDATA 0x90 > +#define PAGE2_SWSPI_RDATA 0x91 > +#define PAGE2_SWSPI_LEN0x92 > +#define PAGE2_SWSPI_CTL0x93 > +#define TRIGGER_NO_READBACK0x05 > +#define TRIGGER_READBACK 0x01 > +#define PAGE2_SPI_STATUS 0x9e > +#define SPI_READY 0x0c >
[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
On 05/11/16 00:21, Daniel Kurtz wrote: > On Tue, Oct 25, 2016 at 6:23 AM, Matthias Brugger > wrote: >> >> On 10/18/2016 04:37 PM, Enric Balletbo Serra wrote: >> [...] --- /dev/null +++ b/drivers/gpu/drm/bridge/parade-ps8640.c >> [...] + +/* Firmware */ +#define PS_FW_NAME "ps864x_fw.bin" + >>> >>> From where I can download this firmware image? >> >> I suppose this FW bits have to be added to linux-firmware repository first, >> before this patch can be accepted. > > All PS8640 devices should already ship with working firmware. > The firmware update procedure is only used in the unlikely event where > one wants to update the bridge to a different firmware provided by > Parade. > > Why must the lack of firmware really block landing this driver? > > If this is really so, can we just land the functional part of the > driver first, and add the firmware update in a follow-up patch. > After checking other users of request_firmware and check them against linux-firmware I think we don't need the FW in linux-firmware to get the driver merged. Especially as there already is a working FW stored on the device. Regards, Matthias
[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
On Tue, Oct 25, 2016 at 6:23 AM, Matthias Brugger wrote: > > On 10/18/2016 04:37 PM, Enric Balletbo Serra wrote: > [...] >>> --- /dev/null >>> +++ b/drivers/gpu/drm/bridge/parade-ps8640.c > [...] >>> >>> + >>> +/* Firmware */ >>> +#define PS_FW_NAME "ps864x_fw.bin" >>> + >> >> From where I can download this firmware image? > > I suppose this FW bits have to be added to linux-firmware repository first, > before this patch can be accepted. All PS8640 devices should already ship with working firmware. The firmware update procedure is only used in the unlikely event where one wants to update the bridge to a different firmware provided by Parade. Why must the lack of firmware really block landing this driver? If this is really so, can we just land the functional part of the driver first, and add the firmware update in a follow-up patch. > > Regards, > Matthias
[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
On 10/18/2016 04:37 PM, Enric Balletbo Serra wrote: [...] >> --- /dev/null >> +++ b/drivers/gpu/drm/bridge/parade-ps8640.c [...] >> + >> +/* Firmware */ >> +#define PS_FW_NAME "ps864x_fw.bin" >> + > > From where I can download this firmware image? > I suppose this FW bits have to be added to linux-firmware repository first, before this patch can be accepted. Regards, Matthias
[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
Hi Jitao, 2016-08-27 8:44 GMT+02:00 Jitao Shi : > This patch adds drm_bridge driver for parade DSI to eDP bridge chip. > > Signed-off-by: Jitao Shi > Reviewed-by: Daniel Kurtz > --- > Changes since v16: > - Disable ps8640 DSI MCS Function. > - Rename gpios name more clearly. > - Tune the ps8640 power on sequence. > > Changes since v15: > - Drop drm_connector_(un)register calls from parade ps8640. >The main DRM driver mtk_drm_drv now calls >drm_connector_register_all() after drm_dev_register() in the >mtk_drm_bind() function. That function should iterate over all >connectors and call drm_connector_register() for each of them. >So, remove drm_connector_(un)register calls from parade ps8640. > > Changes since v14: > - update copyright info. > - change bridge_to_ps8640 and connector_to_ps8640 to inline function. > - fix some coding style. > - use sizeof as array counter. > - use drm_get_edid when read edid. > - add mutex when firmware updating. > > Changes since v13: > - add const on data, ps8640_write_bytes(struct i2c_client *client, const u8 > *data, u16 data_len) > - fix PAGE2_SW_REST tyro. > - move the buf[3] init to entrance of the function. > > Changes since v12: > - fix hw_chip_id build warning > > Changes since v11: > - Remove depends on I2C, add DRM depends > - Reuse ps8640_write_bytes() in ps8640_write_byte() > - Use timer check for polling like the routines in > - Fix no drm_connector_unregister/drm_connector_cleanup when > ps8640_bridge_attach fail > - Check the ps8640 hardware id in ps8640_validate_firmware > - Remove fw_version check > - Move ps8640_validate_firmware before ps8640_enter_bl > - Add ddc_i2c unregister when probe fail and ps8640_remove > --- > drivers/gpu/drm/bridge/Kconfig | 12 + > drivers/gpu/drm/bridge/Makefile|1 + > drivers/gpu/drm/bridge/parade-ps8640.c | 1077 > > 3 files changed, 1090 insertions(+) > create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c > > diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig > index b590e67..c59d043 100644 > --- a/drivers/gpu/drm/bridge/Kconfig > +++ b/drivers/gpu/drm/bridge/Kconfig > @@ -50,6 +50,18 @@ config DRM_PARADE_PS8622 > ---help--- > Parade eDP-LVDS bridge chip driver. > > +config DRM_PARADE_PS8640 > + tristate "Parade PS8640 MIPI DSI to eDP Converter" > + depends on DRM > + depends on OF > + select DRM_KMS_HELPER > + select DRM_MIPI_DSI > + select DRM_PANEL > + ---help--- > + Choose this option if you have PS8640 for display > + The PS8640 is a high-performance and low-power > + MIPI DSI to eDP converter > + > config DRM_SII902X > tristate "Silicon Image sii902x RGB/HDMI bridge" > depends on OF > diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile > index efdb07e..3360537 100644 > --- a/drivers/gpu/drm/bridge/Makefile > +++ b/drivers/gpu/drm/bridge/Makefile > @@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o > obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o > obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o > obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o > +obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o > obj-$(CONFIG_DRM_SII902X) += sii902x.o > obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o > obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/ > diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c > b/drivers/gpu/drm/bridge/parade-ps8640.c > new file mode 100644 > index 000..7d67431 > --- /dev/null > +++ b/drivers/gpu/drm/bridge/parade-ps8640.c > @@ -0,0 +1,1077 @@ > +/* > + * Copyright (c) 2016 MediaTek Inc. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define PAGE1_VSTART 0x6b > +#define PAGE2_SPI_CFG3 0x82 > +#define I2C_TO_SPI_RESET 0x20 > +#define PAGE2_ROMADD_BYTE1 0x8e > +#define PAGE2_ROMADD_BYTE2 0x8f > +#define PAGE2_SWSPI_WDATA 0x90 > +#define PAGE2_SWSPI_RDATA 0x91 > +#define PAGE2_SWSPI_LEN0x92 > +#define PAGE2_SWSPI_CTL0x93 > +#define TRIGGER_NO_READBACK0x05 > +#define TRIGGER_READBACK 0x01 > +#define PAGE2_SPI_STATUS 0x9e > +#define SPI_READY 0x0c >
[v17 2/2] drm/bridge: Add I2C based driver for ps8640 bridge
This patch adds drm_bridge driver for parade DSI to eDP bridge chip. Signed-off-by: Jitao Shi Reviewed-by: Daniel Kurtz --- Changes since v16: - Disable ps8640 DSI MCS Function. - Rename gpios name more clearly. - Tune the ps8640 power on sequence. Changes since v15: - Drop drm_connector_(un)register calls from parade ps8640. The main DRM driver mtk_drm_drv now calls drm_connector_register_all() after drm_dev_register() in the mtk_drm_bind() function. That function should iterate over all connectors and call drm_connector_register() for each of them. So, remove drm_connector_(un)register calls from parade ps8640. Changes since v14: - update copyright info. - change bridge_to_ps8640 and connector_to_ps8640 to inline function. - fix some coding style. - use sizeof as array counter. - use drm_get_edid when read edid. - add mutex when firmware updating. Changes since v13: - add const on data, ps8640_write_bytes(struct i2c_client *client, const u8 *data, u16 data_len) - fix PAGE2_SW_REST tyro. - move the buf[3] init to entrance of the function. Changes since v12: - fix hw_chip_id build warning Changes since v11: - Remove depends on I2C, add DRM depends - Reuse ps8640_write_bytes() in ps8640_write_byte() - Use timer check for polling like the routines in - Fix no drm_connector_unregister/drm_connector_cleanup when ps8640_bridge_attach fail - Check the ps8640 hardware id in ps8640_validate_firmware - Remove fw_version check - Move ps8640_validate_firmware before ps8640_enter_bl - Add ddc_i2c unregister when probe fail and ps8640_remove --- drivers/gpu/drm/bridge/Kconfig | 12 + drivers/gpu/drm/bridge/Makefile|1 + drivers/gpu/drm/bridge/parade-ps8640.c | 1077 3 files changed, 1090 insertions(+) create mode 100644 drivers/gpu/drm/bridge/parade-ps8640.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index b590e67..c59d043 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -50,6 +50,18 @@ config DRM_PARADE_PS8622 ---help--- Parade eDP-LVDS bridge chip driver. +config DRM_PARADE_PS8640 + tristate "Parade PS8640 MIPI DSI to eDP Converter" + depends on DRM + depends on OF + select DRM_KMS_HELPER + select DRM_MIPI_DSI + select DRM_PANEL + ---help--- + Choose this option if you have PS8640 for display + The PS8640 is a high-performance and low-power + MIPI DSI to eDP converter + config DRM_SII902X tristate "Silicon Image sii902x RGB/HDMI bridge" depends on OF diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index efdb07e..3360537 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_DRM_DW_HDMI) += dw-hdmi.o obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o +obj-$(CONFIG_DRM_PARADE_PS8640) += parade-ps8640.o obj-$(CONFIG_DRM_SII902X) += sii902x.o obj-$(CONFIG_DRM_TOSHIBA_TC358767) += tc358767.o obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/ diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c new file mode 100644 index 000..7d67431 --- /dev/null +++ b/drivers/gpu/drm/bridge/parade-ps8640.c @@ -0,0 +1,1077 @@ +/* + * Copyright (c) 2016 MediaTek Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define PAGE1_VSTART 0x6b +#define PAGE2_SPI_CFG3 0x82 +#define I2C_TO_SPI_RESET 0x20 +#define PAGE2_ROMADD_BYTE1 0x8e +#define PAGE2_ROMADD_BYTE2 0x8f +#define PAGE2_SWSPI_WDATA 0x90 +#define PAGE2_SWSPI_RDATA 0x91 +#define PAGE2_SWSPI_LEN0x92 +#define PAGE2_SWSPI_CTL0x93 +#define TRIGGER_NO_READBACK0x05 +#define TRIGGER_READBACK 0x01 +#define PAGE2_SPI_STATUS 0x9e +#define SPI_READY 0x0c +#define PAGE2_GPIO_L 0xa6 +#define PAGE2_GPIO_H 0xa7 +#define PS_GPIO9 BIT(1) +#define PAGE2_IROM_CTRL0xb0 +#define IROM_ENABLE0xc0 +#define IROM_DISABLE 0x80 +#define PAGE2_SW_RESET 0xbc +#define SPI_SW_RESET BIT(7) +#define MPU_SW_RESET