Re: [PATCH v3 2/2] gpu/drm/panel: Add Sony TD4353 JDI panel driver

2022-12-09 Thread Marijn Suijten
On 2022-09-30 20:08:11, Konrad Dybcio wrote:
> Add support for the Sony TD4353 JDI 2160x1080 display panel used in

This is a vertical panel of 1080x2160 right?

> some Sony Xperia XZ2 and XZ2 Compact smartphones. Due to the specifics
> of smartphone manufacturing, it is impossible to retrieve a better name
> for this panel.
> 
> This revision adds support for the default 60 Hz configuration, however
> there could possibly be some room for expansion, as the display panels
> used on Sony devices have historically been capable of >2x refresh rate
> overclocking.
> 
> Signed-off-by: Konrad Dybcio 

Reviewed-by: Marijn Suijten 

Apart from some minor nits about how we can change seemingly magical hex
constants to a decimal represntation, which makes it more obvious (to
the reader) that these are just width-1 and height-1.

> ---
> Changes since v2:
> - "GPL v2" -> "GPL"
> - add missing S-o-b (how embarassing)
> - move { after sony_td4353_assert_reset_gpios() to a new line 
> 
>  drivers/gpu/drm/panel/Kconfig |  10 +
>  drivers/gpu/drm/panel/Makefile|   1 +
>  drivers/gpu/drm/panel/panel-sony-td4353-jdi.c | 329 ++
>  3 files changed, 340 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
> 
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index a582ddd583c2..6ef1b48169b5 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -637,6 +637,16 @@ config DRM_PANEL_SONY_ACX565AKM
> Say Y here if you want to enable support for the Sony ACX565AKM
> 800x600 3.5" panel (found on the Nokia N900).
>  
> +config DRM_PANEL_SONY_TD4353_JDI
> + tristate "Sony TD4353 JDI panel"
> + depends on GPIOLIB && OF
> + depends on DRM_MIPI_DSI
> + depends on BACKLIGHT_CLASS_DEVICE
> + help
> +   Say Y here if you want to enable support for the Sony Tama
> +   TD4353 JDI command mode panel as found on some Sony Xperia
> +   XZ2 and XZ2 Compact smartphones.
> +
>  config DRM_PANEL_SONY_TULIP_TRULY_NT35521
>   tristate "Sony Tulip Truly NT35521 panel"
>   depends on GPIOLIB && OF
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 8e71aa7581b8..8ef27bc86f94 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -64,6 +64,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += 
> panel-sitronix-st7701.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
> +obj-$(CONFIG_DRM_PANEL_SONY_TD4353_JDI) += panel-sony-td4353-jdi.o
>  obj-$(CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521) += 
> panel-sony-tulip-truly-nt35521.o
>  obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
> diff --git a/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c 
> b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
> new file mode 100644
> index ..11db62992b8b
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
> @@ -0,0 +1,329 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2022 Konrad Dybcio 
> + *
> + * Generated with linux-mdss-dsi-panel-driver-generator with a
> + * substantial amount of manual adjustments.
> + *
> + * SONY Downstream kernel calls this one:
> + * - "JDI ID3" for Akari  (XZ2)
> + * - "JDI ID4" for Apollo (XZ2 Compact)
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +enum {
> + TYPE_TAMA_60HZ,
> + /*
> +  * Leaving room for expansion - SONY very often uses
> +  * *truly reliably* overclockable panels on their flagships!
> +  */
> +};
> +
> +struct sony_td4353_jdi {
> + struct drm_panel panel;
> + struct mipi_dsi_device *dsi;
> + struct regulator_bulk_data supplies[3];
> + struct gpio_desc *panel_reset_gpio;
> + struct gpio_desc *touch_reset_gpio;
> + bool prepared;
> + int type;
> +};
> +
> +static inline struct sony_td4353_jdi *to_sony_td4353_jdi(struct drm_panel 
> *panel)
> +{
> + return container_of(panel, struct sony_td4353_jdi, panel);
> +}
> +
> +static int sony_td4353_jdi_on(struct sony_td4353_jdi *ctx)
> +{
> + struct mipi_dsi_device *dsi = ctx->dsi;
> + struct device *dev = >dev;
> + int ret;
> +
> + dsi->mode_flags |= MIPI_DSI_MODE_LPM;
> +
> + ret = mipi_dsi_dcs_set_column_address(dsi, 0x, 0x0437);

As discussed offline, can we just use 0, 1079 here?  That way it's a bit
more clear that our column address is just width-1.

> + if (ret < 0) {
> + dev_err(dev, "Failed to set column address: %d\n", ret);
> + return ret;
> + }
> +
> + ret = mipi_dsi_dcs_set_page_address(dsi, 0x, 0x086f);


Re: [PATCH v3 2/2] gpu/drm/panel: Add Sony TD4353 JDI panel driver

2022-12-09 Thread Konrad Dybcio



On 14.11.2022 15:55, Konrad Dybcio wrote:
> 
> 
> On 14/10/2022 18:36, Konrad Dybcio wrote:
>>
>>
>> On 30.09.2022 20:08, Konrad Dybcio wrote:
>>> Add support for the Sony TD4353 JDI 2160x1080 display panel used in
>>> some Sony Xperia XZ2 and XZ2 Compact smartphones. Due to the specifics
>>> of smartphone manufacturing, it is impossible to retrieve a better name
>>> for this panel.
>>>
>>> This revision adds support for the default 60 Hz configuration, however
>>> there could possibly be some room for expansion, as the display panels
>>> used on Sony devices have historically been capable of >2x refresh rate
>>> overclocking.
>>>
>>> Signed-off-by: Konrad Dybcio 
>>> ---
>> Gentle bump
>>
>> Konrad
> Yet another one.
> 
> Konrad
Hello? Anybody there? It's been quite a while..

Konrad
>>> Changes since v2:
>>> - "GPL v2" -> "GPL"
>>> - add missing S-o-b (how embarassing)
>>> - move { after sony_td4353_assert_reset_gpios() to a new line
>>>
>>>   drivers/gpu/drm/panel/Kconfig |  10 +
>>>   drivers/gpu/drm/panel/Makefile    |   1 +
>>>   drivers/gpu/drm/panel/panel-sony-td4353-jdi.c | 329 ++
>>>   3 files changed, 340 insertions(+)
>>>   create mode 100644 drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
>>>
>>> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
>>> index a582ddd583c2..6ef1b48169b5 100644
>>> --- a/drivers/gpu/drm/panel/Kconfig
>>> +++ b/drivers/gpu/drm/panel/Kconfig
>>> @@ -637,6 +637,16 @@ config DRM_PANEL_SONY_ACX565AKM
>>>     Say Y here if you want to enable support for the Sony ACX565AKM
>>>     800x600 3.5" panel (found on the Nokia N900).
>>>   +config DRM_PANEL_SONY_TD4353_JDI
>>> +    tristate "Sony TD4353 JDI panel"
>>> +    depends on GPIOLIB && OF
>>> +    depends on DRM_MIPI_DSI
>>> +    depends on BACKLIGHT_CLASS_DEVICE
>>> +    help
>>> +  Say Y here if you want to enable support for the Sony Tama
>>> +  TD4353 JDI command mode panel as found on some Sony Xperia
>>> +  XZ2 and XZ2 Compact smartphones.
>>> +
>>>   config DRM_PANEL_SONY_TULIP_TRULY_NT35521
>>>   tristate "Sony Tulip Truly NT35521 panel"
>>>   depends on GPIOLIB && OF
>>> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
>>> index 8e71aa7581b8..8ef27bc86f94 100644
>>> --- a/drivers/gpu/drm/panel/Makefile
>>> +++ b/drivers/gpu/drm/panel/Makefile
>>> @@ -64,6 +64,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += 
>>> panel-sitronix-st7701.o
>>>   obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>>>   obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>>>   obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
>>> +obj-$(CONFIG_DRM_PANEL_SONY_TD4353_JDI) += panel-sony-td4353-jdi.o
>>>   obj-$(CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521) += 
>>> panel-sony-tulip-truly-nt35521.o
>>>   obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>>>   obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
>>> diff --git a/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c 
>>> b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
>>> new file mode 100644
>>> index ..11db62992b8b
>>> --- /dev/null
>>> +++ b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
>>> @@ -0,0 +1,329 @@
>>> +// SPDX-License-Identifier: GPL-2.0-only
>>> +/*
>>> + * Copyright (c) 2022 Konrad Dybcio 
>>> + *
>>> + * Generated with linux-mdss-dsi-panel-driver-generator with a
>>> + * substantial amount of manual adjustments.
>>> + *
>>> + * SONY Downstream kernel calls this one:
>>> + * - "JDI ID3" for Akari  (XZ2)
>>> + * - "JDI ID4" for Apollo (XZ2 Compact)
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +enum {
>>> +    TYPE_TAMA_60HZ,
>>> +    /*
>>> + * Leaving room for expansion - SONY very often uses
>>> + * *truly reliably* overclockable panels on their flagships!
>>> + */
>>> +};
>>> +
>>> +struct sony_td4353_jdi {
>>> +    struct drm_panel panel;
>>> +    struct mipi_dsi_device *dsi;
>>> +    struct regulator_bulk_data supplies[3];
>>> +    struct gpio_desc *panel_reset_gpio;
>>> +    struct gpio_desc *touch_reset_gpio;
>>> +    bool prepared;
>>> +    int type;
>>> +};
>>> +
>>> +static inline struct sony_td4353_jdi *to_sony_td4353_jdi(struct drm_panel 
>>> *panel)
>>> +{
>>> +    return container_of(panel, struct sony_td4353_jdi, panel);
>>> +}
>>> +
>>> +static int sony_td4353_jdi_on(struct sony_td4353_jdi *ctx)
>>> +{
>>> +    struct mipi_dsi_device *dsi = ctx->dsi;
>>> +    struct device *dev = >dev;
>>> +    int ret;
>>> +
>>> +    dsi->mode_flags |= MIPI_DSI_MODE_LPM;
>>> +
>>> +    ret = mipi_dsi_dcs_set_column_address(dsi, 0x, 0x0437);
>>> +    if (ret < 0) {
>>> +    dev_err(dev, "Failed to set column address: %d\n", ret);
>>> +    return ret;
>>> +    }
>>> +
>>> +    ret = 

Re: [PATCH v3 2/2] gpu/drm/panel: Add Sony TD4353 JDI panel driver

2022-11-14 Thread Konrad Dybcio




On 14/10/2022 18:36, Konrad Dybcio wrote:



On 30.09.2022 20:08, Konrad Dybcio wrote:

Add support for the Sony TD4353 JDI 2160x1080 display panel used in
some Sony Xperia XZ2 and XZ2 Compact smartphones. Due to the specifics
of smartphone manufacturing, it is impossible to retrieve a better name
for this panel.

This revision adds support for the default 60 Hz configuration, however
there could possibly be some room for expansion, as the display panels
used on Sony devices have historically been capable of >2x refresh rate
overclocking.

Signed-off-by: Konrad Dybcio 
---

Gentle bump

Konrad

Yet another one.

Konrad

Changes since v2:
- "GPL v2" -> "GPL"
- add missing S-o-b (how embarassing)
- move { after sony_td4353_assert_reset_gpios() to a new line

  drivers/gpu/drm/panel/Kconfig |  10 +
  drivers/gpu/drm/panel/Makefile|   1 +
  drivers/gpu/drm/panel/panel-sony-td4353-jdi.c | 329 ++
  3 files changed, 340 insertions(+)
  create mode 100644 drivers/gpu/drm/panel/panel-sony-td4353-jdi.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index a582ddd583c2..6ef1b48169b5 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -637,6 +637,16 @@ config DRM_PANEL_SONY_ACX565AKM
  Say Y here if you want to enable support for the Sony ACX565AKM
  800x600 3.5" panel (found on the Nokia N900).
  
+config DRM_PANEL_SONY_TD4353_JDI

+   tristate "Sony TD4353 JDI panel"
+   depends on GPIOLIB && OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for the Sony Tama
+ TD4353 JDI command mode panel as found on some Sony Xperia
+ XZ2 and XZ2 Compact smartphones.
+
  config DRM_PANEL_SONY_TULIP_TRULY_NT35521
tristate "Sony Tulip Truly NT35521 panel"
depends on GPIOLIB && OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 8e71aa7581b8..8ef27bc86f94 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -64,6 +64,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += 
panel-sitronix-st7701.o
  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_DRM_PANEL_SONY_TD4353_JDI) += panel-sony-td4353-jdi.o
  obj-$(CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521) += 
panel-sony-tulip-truly-nt35521.o
  obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
diff --git a/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c 
b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
new file mode 100644
index ..11db62992b8b
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
@@ -0,0 +1,329 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 Konrad Dybcio 
+ *
+ * Generated with linux-mdss-dsi-panel-driver-generator with a
+ * substantial amount of manual adjustments.
+ *
+ * SONY Downstream kernel calls this one:
+ * - "JDI ID3" for Akari  (XZ2)
+ * - "JDI ID4" for Apollo (XZ2 Compact)
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+enum {
+   TYPE_TAMA_60HZ,
+   /*
+* Leaving room for expansion - SONY very often uses
+* *truly reliably* overclockable panels on their flagships!
+*/
+};
+
+struct sony_td4353_jdi {
+   struct drm_panel panel;
+   struct mipi_dsi_device *dsi;
+   struct regulator_bulk_data supplies[3];
+   struct gpio_desc *panel_reset_gpio;
+   struct gpio_desc *touch_reset_gpio;
+   bool prepared;
+   int type;
+};
+
+static inline struct sony_td4353_jdi *to_sony_td4353_jdi(struct drm_panel 
*panel)
+{
+   return container_of(panel, struct sony_td4353_jdi, panel);
+}
+
+static int sony_td4353_jdi_on(struct sony_td4353_jdi *ctx)
+{
+   struct mipi_dsi_device *dsi = ctx->dsi;
+   struct device *dev = >dev;
+   int ret;
+
+   dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+   ret = mipi_dsi_dcs_set_column_address(dsi, 0x, 0x0437);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set column address: %d\n", ret);
+   return ret;
+   }
+
+   ret = mipi_dsi_dcs_set_page_address(dsi, 0x, 0x086f);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set page address: %d\n", ret);
+   return ret;
+   }
+
+   ret = mipi_dsi_dcs_set_tear_scanline(dsi, 0x);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set tear scanline: %d\n", ret);
+   return ret;
+   }
+
+   ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set tear on: 

Re: [PATCH v3 2/2] gpu/drm/panel: Add Sony TD4353 JDI panel driver

2022-10-14 Thread Konrad Dybcio



On 30.09.2022 20:08, Konrad Dybcio wrote:
> Add support for the Sony TD4353 JDI 2160x1080 display panel used in
> some Sony Xperia XZ2 and XZ2 Compact smartphones. Due to the specifics
> of smartphone manufacturing, it is impossible to retrieve a better name
> for this panel.
> 
> This revision adds support for the default 60 Hz configuration, however
> there could possibly be some room for expansion, as the display panels
> used on Sony devices have historically been capable of >2x refresh rate
> overclocking.
> 
> Signed-off-by: Konrad Dybcio 
> ---
Gentle bump

Konrad
> Changes since v2:
> - "GPL v2" -> "GPL"
> - add missing S-o-b (how embarassing)
> - move { after sony_td4353_assert_reset_gpios() to a new line 
> 
>  drivers/gpu/drm/panel/Kconfig |  10 +
>  drivers/gpu/drm/panel/Makefile|   1 +
>  drivers/gpu/drm/panel/panel-sony-td4353-jdi.c | 329 ++
>  3 files changed, 340 insertions(+)
>  create mode 100644 drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
> 
> diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
> index a582ddd583c2..6ef1b48169b5 100644
> --- a/drivers/gpu/drm/panel/Kconfig
> +++ b/drivers/gpu/drm/panel/Kconfig
> @@ -637,6 +637,16 @@ config DRM_PANEL_SONY_ACX565AKM
> Say Y here if you want to enable support for the Sony ACX565AKM
> 800x600 3.5" panel (found on the Nokia N900).
>  
> +config DRM_PANEL_SONY_TD4353_JDI
> + tristate "Sony TD4353 JDI panel"
> + depends on GPIOLIB && OF
> + depends on DRM_MIPI_DSI
> + depends on BACKLIGHT_CLASS_DEVICE
> + help
> +   Say Y here if you want to enable support for the Sony Tama
> +   TD4353 JDI command mode panel as found on some Sony Xperia
> +   XZ2 and XZ2 Compact smartphones.
> +
>  config DRM_PANEL_SONY_TULIP_TRULY_NT35521
>   tristate "Sony Tulip Truly NT35521 panel"
>   depends on GPIOLIB && OF
> diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
> index 8e71aa7581b8..8ef27bc86f94 100644
> --- a/drivers/gpu/drm/panel/Makefile
> +++ b/drivers/gpu/drm/panel/Makefile
> @@ -64,6 +64,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += 
> panel-sitronix-st7701.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
>  obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
>  obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
> +obj-$(CONFIG_DRM_PANEL_SONY_TD4353_JDI) += panel-sony-td4353-jdi.o
>  obj-$(CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521) += 
> panel-sony-tulip-truly-nt35521.o
>  obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
>  obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
> diff --git a/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c 
> b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
> new file mode 100644
> index ..11db62992b8b
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
> @@ -0,0 +1,329 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2022 Konrad Dybcio 
> + *
> + * Generated with linux-mdss-dsi-panel-driver-generator with a
> + * substantial amount of manual adjustments.
> + *
> + * SONY Downstream kernel calls this one:
> + * - "JDI ID3" for Akari  (XZ2)
> + * - "JDI ID4" for Apollo (XZ2 Compact)
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +enum {
> + TYPE_TAMA_60HZ,
> + /*
> +  * Leaving room for expansion - SONY very often uses
> +  * *truly reliably* overclockable panels on their flagships!
> +  */
> +};
> +
> +struct sony_td4353_jdi {
> + struct drm_panel panel;
> + struct mipi_dsi_device *dsi;
> + struct regulator_bulk_data supplies[3];
> + struct gpio_desc *panel_reset_gpio;
> + struct gpio_desc *touch_reset_gpio;
> + bool prepared;
> + int type;
> +};
> +
> +static inline struct sony_td4353_jdi *to_sony_td4353_jdi(struct drm_panel 
> *panel)
> +{
> + return container_of(panel, struct sony_td4353_jdi, panel);
> +}
> +
> +static int sony_td4353_jdi_on(struct sony_td4353_jdi *ctx)
> +{
> + struct mipi_dsi_device *dsi = ctx->dsi;
> + struct device *dev = >dev;
> + int ret;
> +
> + dsi->mode_flags |= MIPI_DSI_MODE_LPM;
> +
> + ret = mipi_dsi_dcs_set_column_address(dsi, 0x, 0x0437);
> + if (ret < 0) {
> + dev_err(dev, "Failed to set column address: %d\n", ret);
> + return ret;
> + }
> +
> + ret = mipi_dsi_dcs_set_page_address(dsi, 0x, 0x086f);
> + if (ret < 0) {
> + dev_err(dev, "Failed to set page address: %d\n", ret);
> + return ret;
> + }
> +
> + ret = mipi_dsi_dcs_set_tear_scanline(dsi, 0x);
> + if (ret < 0) {
> + dev_err(dev, "Failed to set tear scanline: %d\n", ret);
> + return ret;
> + }
> +
> + ret = mipi_dsi_dcs_set_tear_on(dsi, 

[PATCH v3 2/2] gpu/drm/panel: Add Sony TD4353 JDI panel driver

2022-09-30 Thread Konrad Dybcio
Add support for the Sony TD4353 JDI 2160x1080 display panel used in
some Sony Xperia XZ2 and XZ2 Compact smartphones. Due to the specifics
of smartphone manufacturing, it is impossible to retrieve a better name
for this panel.

This revision adds support for the default 60 Hz configuration, however
there could possibly be some room for expansion, as the display panels
used on Sony devices have historically been capable of >2x refresh rate
overclocking.

Signed-off-by: Konrad Dybcio 
---
Changes since v2:
- "GPL v2" -> "GPL"
- add missing S-o-b (how embarassing)
- move { after sony_td4353_assert_reset_gpios() to a new line 

 drivers/gpu/drm/panel/Kconfig |  10 +
 drivers/gpu/drm/panel/Makefile|   1 +
 drivers/gpu/drm/panel/panel-sony-td4353-jdi.c | 329 ++
 3 files changed, 340 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-sony-td4353-jdi.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index a582ddd583c2..6ef1b48169b5 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -637,6 +637,16 @@ config DRM_PANEL_SONY_ACX565AKM
  Say Y here if you want to enable support for the Sony ACX565AKM
  800x600 3.5" panel (found on the Nokia N900).
 
+config DRM_PANEL_SONY_TD4353_JDI
+   tristate "Sony TD4353 JDI panel"
+   depends on GPIOLIB && OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for the Sony Tama
+ TD4353 JDI command mode panel as found on some Sony Xperia
+ XZ2 and XZ2 Compact smartphones.
+
 config DRM_PANEL_SONY_TULIP_TRULY_NT35521
tristate "Sony Tulip Truly NT35521 panel"
depends on GPIOLIB && OF
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index 8e71aa7581b8..8ef27bc86f94 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -64,6 +64,7 @@ obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7701) += 
panel-sitronix-st7701.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
 obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7789V) += panel-sitronix-st7789v.o
 obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_DRM_PANEL_SONY_TD4353_JDI) += panel-sony-td4353-jdi.o
 obj-$(CONFIG_DRM_PANEL_SONY_TULIP_TRULY_NT35521) += 
panel-sony-tulip-truly-nt35521.o
 obj-$(CONFIG_DRM_PANEL_TDO_TL070WSH30) += panel-tdo-tl070wsh30.o
 obj-$(CONFIG_DRM_PANEL_TPO_TD028TTEC1) += panel-tpo-td028ttec1.o
diff --git a/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c 
b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
new file mode 100644
index ..11db62992b8b
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-sony-td4353-jdi.c
@@ -0,0 +1,329 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 Konrad Dybcio 
+ *
+ * Generated with linux-mdss-dsi-panel-driver-generator with a
+ * substantial amount of manual adjustments.
+ *
+ * SONY Downstream kernel calls this one:
+ * - "JDI ID3" for Akari  (XZ2)
+ * - "JDI ID4" for Apollo (XZ2 Compact)
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+enum {
+   TYPE_TAMA_60HZ,
+   /*
+* Leaving room for expansion - SONY very often uses
+* *truly reliably* overclockable panels on their flagships!
+*/
+};
+
+struct sony_td4353_jdi {
+   struct drm_panel panel;
+   struct mipi_dsi_device *dsi;
+   struct regulator_bulk_data supplies[3];
+   struct gpio_desc *panel_reset_gpio;
+   struct gpio_desc *touch_reset_gpio;
+   bool prepared;
+   int type;
+};
+
+static inline struct sony_td4353_jdi *to_sony_td4353_jdi(struct drm_panel 
*panel)
+{
+   return container_of(panel, struct sony_td4353_jdi, panel);
+}
+
+static int sony_td4353_jdi_on(struct sony_td4353_jdi *ctx)
+{
+   struct mipi_dsi_device *dsi = ctx->dsi;
+   struct device *dev = >dev;
+   int ret;
+
+   dsi->mode_flags |= MIPI_DSI_MODE_LPM;
+
+   ret = mipi_dsi_dcs_set_column_address(dsi, 0x, 0x0437);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set column address: %d\n", ret);
+   return ret;
+   }
+
+   ret = mipi_dsi_dcs_set_page_address(dsi, 0x, 0x086f);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set page address: %d\n", ret);
+   return ret;
+   }
+
+   ret = mipi_dsi_dcs_set_tear_scanline(dsi, 0x);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set tear scanline: %d\n", ret);
+   return ret;
+   }
+
+   ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
+   if (ret < 0) {
+   dev_err(dev, "Failed to set tear on: %d\n", ret);
+   return ret;
+   }
+
+   mipi_dsi_dcs_write_seq(dsi, MIPI_DCS_SET_ADDRESS_MODE, 0x00);
+
+   ret =