[PATCH v4 0/5] Add support for PinePhone LCD panel

70 views
Skip to first unread message

Ondrej Jirman

unread,
Jun 16, 2020, 8:32:16 PM6/16/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This patchset adds support for the LCD panel of PinePhone.

The first 3 patches are for the panel itself, and the last 2 patches are
for enabling it on PinePhone.

I've tested this on PinePhone 1.0 and 1.2.

Please take a look.

thank you and regards,
Ondrej Jirman

Changes in v4:
- use ->type from the mode instead of hardcoding (Samuel)
- move init_sequence to ->prepare (Samuel)
- move anti-flicker delay to ->enable, explain it (Samuel)
- add enter_sleep after display_off (Samuel)
- drop ->disable (move code to ->unprepare)
- add ID bytes dumping (Linus)
(I can't test it since allwinner DSI driver has a broken
dcs_read function, and I didn't manage to fix it.)
- document magic bytes (Linus)
- assert reset during powerup
- cleanup powerup timings according to the datasheet

Changes in v3:
- Panel driver renamed to the name of the LCD controller
- Re-organize the driver slightly to more easily support more panels
based on the same controller.
- Add patch to enable the touchscreen to complete the LCD support
on PinePhone.
- Dropped the "DSI fix" patch (the driver seems to work for me without it)
- Improved brightness levels handling:
- PinePhone 1.0 uses default levels generated by the driver
- On PinePhone 1.1 duty cycles < 20% lead to black screen, so
default levels can't be used. Martijn Braam came up with a
list of duty cycle values that lead to perception of linear
brigtness level <-> light intensity on PinePhone 1.1
- There was some feedback on v2 about this being similar to st7701.
It's only similar in name. Most of the "user commands" are different,
so I opted to keep this in a new driver instead of creating st770x.

Anyone who likes to check the differences, here are datasheets:

- https://megous.com/dl/tmp/ST7703_DS_v01_20160128.pdf
- https://megous.com/dl/tmp/ST7701.pdf

Changes in v2:
- DT Example fix.
- DT Format fix.
- Raised copyright info to 2020.
- Sort panel operation functions.
- Sort inclusion.


-- For phone owners: --

There's an open question on how to set the backlight brightness values
on post 1.0 revision phone, since lower duty cycles (< 10-20%) lead
to backlight being black. It would be nice if more people can test
the various backlight levels on 1.1 and 1.2 revision with this change
in dts:

brightness-levels = <0 1000>;
num-interpolated-steps = <1000>;

and report at what brightness level the backlight turns on. So far it
seems this has a wide range. Lowest useable duty cycle for me is ~7%
on 1.2 and for Martijn ~20% on 1.1.

Icenowy Zheng (4):
dt-bindings: vendor-prefixes: Add Xingbangda
dt-bindings: panel: Add binding for Xingbangda XBD599 panel
drm: panel: Add Xingbangda XBD599 panel (ST7703 controller)
arm64: dts: sun50i-a64-pinephone: Enable LCD support on PinePhone

Ondrej Jirman (1):
arm64: dts: sun50i-a64-pinephone: Add touchscreen support

.../display/panel/sitronix,st7703.yaml | 63 +++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
.../allwinner/sun50i-a64-pinephone-1.1.dts | 19 +
.../dts/allwinner/sun50i-a64-pinephone.dtsi | 54 ++
drivers/gpu/drm/panel/Kconfig | 10 +
drivers/gpu/drm/panel/Makefile | 1 +
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 535 ++++++++++++++++++
7 files changed, 684 insertions(+)
create mode 100644 Documentation/devicetree/bindings/display/panel/sitronix,st7703.yaml
create mode 100644 drivers/gpu/drm/panel/panel-sitronix-st7703.c

--
2.27.0

Ondrej Jirman

unread,
Jun 16, 2020, 8:32:17 PM6/16/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah, Ondrej Jirman
From: Icenowy Zheng <ice...@aosc.io>

Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI IPS LCD panel made by
Xingbangda, which is used on PinePhone final assembled phones.

It is based on Sitronix ST7703 LCD controller.

Add support for it.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/Kconfig | 10 +
drivers/gpu/drm/panel/Makefile | 1 +
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 535 ++++++++++++++++++
3 files changed, 546 insertions(+)
create mode 100644 drivers/gpu/drm/panel/panel-sitronix-st7703.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 39055c1f0e2f..b7bc157b0612 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -395,6 +395,16 @@ config DRM_PANEL_SITRONIX_ST7701
ST7701 controller for 480X864 LCD panels with MIPI/RGB/SPI
system interfaces.

+config DRM_PANEL_SITRONIX_ST7703
+ tristate "Sitronix ST7703 panel driver"
+ depends on OF
+ depends on DRM_MIPI_DSI
+ depends on BACKLIGHT_CLASS_DEVICE
+ help
+ Say Y here if you want to enable support for the Sitronix
+ ST7703 controller for 720X1440 LCD panels with MIPI/RGB/SPI
+ system interfaces.
+
config DRM_PANEL_SITRONIX_ST7789V
tristate "Sitronix ST7789V panel"
depends on OF && SPI
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index de74f282c433..47f4789a8685 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o
obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
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_ACX424AKP) += panel-sony-acx424akp.o
obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
new file mode 100644
index 000000000000..dbd46b6c0b46
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -0,0 +1,535 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * DRM driver for Sitronix ST7703 MIPI DSI panel
+ *
+ * Copyright (C) 2020 Ondrej Jirman <meg...@megous.com>
+ * Copyright (C) 2019-2020 Icenowy Zheng <ice...@aosc.io>
+ *
+ * Based on panel-rocktech-jh057n00900.c, which is:
+ * Copyright (C) Purism SPC 2019
+ */
+
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/regulator/consumer.h>
+
+#include <drm/drm_mipi_dsi.h>
+#include <drm/drm_modes.h>
+#include <drm/drm_panel.h>
+#include <drm/drm_print.h>
+
+/* Manufacturer specific DCS commands */
+#define ST7703_CMD_SETDISP 0xB2
+#define ST7703_CMD_SETRGBIF 0xB3
+#define ST7703_CMD_SETCYC 0xB4
+#define ST7703_CMD_SETBGP 0xB5
+#define ST7703_CMD_SETVCOM 0xB6
+#define ST7703_CMD_SETOTP 0xB7
+#define ST7703_CMD_SETPOWER_EXT 0xB8
+#define ST7703_CMD_SETEXTC 0xB9
+#define ST7703_CMD_SETMIPI 0xBA
+#define ST7703_CMD_SETVDC 0xBC
+#define ST7703_CMD_UNK_BF 0xBF
+#define ST7703_CMD_SETSCR 0xC0
+#define ST7703_CMD_SETPOWER 0xC1
+#define ST7703_CMD_UNK_C6 0xC6
+#define ST7703_CMD_SETPANEL 0xCC
+#define ST7703_CMD_RDID1 0xDA
+#define ST7703_CMD_RDID2 0xDB
+#define ST7703_CMD_RDID3 0xDC
+#define ST7703_CMD_SETGAMMA 0xE0
+#define ST7703_CMD_SETEQ 0xE3
+#define ST7703_CMD_SETGIP1 0xE9
+#define ST7703_CMD_SETGIP2 0xEA
+
+struct st7703_panel_desc {
+ const struct drm_display_mode *mode;
+ unsigned int lanes;
+ unsigned long flags;
+ enum mipi_dsi_pixel_format format;
+ const char *const *supply_names;
+ unsigned int num_supplies;
+};
+
+struct st7703 {
+ struct device *dev;
+ struct drm_panel panel;
+ struct gpio_desc *reset_gpio;
+ struct regulator_bulk_data *supplies;
+ const struct st7703_panel_desc *desc;
+ bool prepared;
+};
+
+static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
+{
+ return container_of(panel, struct st7703, panel);
+}
+
+#define dsi_dcs_write_seq(dsi, cmd, seq...) do { \
+ static const u8 d[] = { seq }; \
+ int ret; \
+ ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d)); \
+ if (ret < 0) \
+ return ret; \
+ } while (0)
+
+
+static int st7703_init_sequence(struct st7703 *ctx)
+{
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ struct device *dev = ctx->dev;
+
+ /*
+ * Init sequence was supplied by the panel vendor.
+ */
+
+ /* Magic sequence to unlock user commands below. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETEXTC, 0xF1, 0x12, 0x83);
+
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETMIPI,
+ 0x33, /* VC_main = 0, Lane_Number = 3 (4 lanes) */
+ 0x81, /* DSI_LDO_SEL = 1.7V, RTERM = 90 Ohm */
+ 0x05, /* IHSRX = x6 (Low High Speed driving ability) */
+ 0xF9, /* TX_CLK_SEL = fDSICLK/16 */
+ 0x0E, /* HFP_OSC (min. HFP number in DSI mode) */
+ 0x0E, /* HBP_OSC (min. HBP number in DSI mode) */
+ /* The rest is undocumented in ST7703 datasheet */
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x44, 0x25, 0x00, 0x91, 0x0a, 0x00, 0x00, 0x02,
+ 0x4F, 0x11, 0x00, 0x00, 0x37);
+
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER_EXT,
+ 0x25, /* PCCS = 2, ECP_DC_DIV = 1/4 HSYNC */
+ 0x22, /* DT = 15ms XDK_ECP = x2 */
+ 0x20, /* PFM_DC_DIV = /1 */
+ 0x03 /* ECP_SYNC_EN = 1, VGX_SYNC_EN = 1 */);
+
+ /* RGB I/F porch timing */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETRGBIF,
+ 0x10, /* VBP_RGB_GEN */
+ 0x10, /* VFP_RGB_GEN */
+ 0x05, /* DE_BP_RGB_GEN */
+ 0x05, /* DE_FP_RGB_GEN */
+ /* The rest is undocumented in ST7703 datasheet */
+ 0x03, 0xFF,
+ 0x00, 0x00,
+ 0x00, 0x00);
+
+ /* Source driving settings. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETSCR,
+ 0x73, /* N_POPON */
+ 0x73, /* N_NOPON */
+ 0x50, /* I_POPON */
+ 0x50, /* I_NOPON */
+ 0x00, /* SCR[31,24] */
+ 0xC0, /* SCR[23,16] */
+ 0x08, /* SCR[15,8] */
+ 0x70, /* SCR[7,0] */
+ 0x00 /* Undocumented */);
+
+ /* NVDDD_SEL = -1.8V, VDDD_SEL = out of range (possibly 1.9V?) */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETVDC, 0x4E);
+
+ /*
+ * SS_PANEL = 1 (reverse scan), GS_PANEL = 0 (normal scan)
+ * REV_PANEL = 1 (normally black panel), BGR_PANEL = 1 (BGR)
+ */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETPANEL, 0x0B);
+
+ /* Zig-Zag Type C column inversion. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETCYC, 0x80);
+
+ /* Set display resolution. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETDISP,
+ 0xF0, /* NL = 240 */
+ 0x12, /* RES_V_LSB = 0, BLK_CON = VSSD,
+ * RESO_SEL = 720RGB
+ */
+ 0xF0 /* WHITE_GND_EN = 1 (GND),
+ * WHITE_FRAME_SEL = 7 frames,
+ * ISC = 0 frames
+ */);
+
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETEQ,
+ 0x00, /* PNOEQ */
+ 0x00, /* NNOEQ */
+ 0x0B, /* PEQGND */
+ 0x0B, /* NEQGND */
+ 0x10, /* PEQVCI */
+ 0x10, /* NEQVCI */
+ 0x00, /* PEQVCI1 */
+ 0x00, /* NEQVCI1 */
+ 0x00, /* reserved */
+ 0x00, /* reserved */
+ 0xFF, /* reserved */
+ 0x00, /* reserved */
+ 0xC0, /* ESD_DET_DATA_WHITE = 1, ESD_WHITE_EN = 1 */
+ 0x10 /* SLPIN_OPTION = 1 (no need vsync after sleep-in)
+ * VEDIO_NO_CHECK_EN = 0
+ * ESD_WHITE_GND_EN = 0
+ * ESD_DET_TIME_SEL = 0 frames
+ */);
+
+ /* Undocumented command. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_UNK_C6, 0x01, 0x00, 0xFF, 0xFF, 0x00);
+
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETPOWER,
+ 0x74, /* VBTHS, VBTLS: VGH = 17V, VBL = -11V */
+ 0x00, /* FBOFF_VGH = 0, FBOFF_VGL = 0 */
+ 0x32, /* VRP */
+ 0x32, /* VRN */
+ 0x77, /* reserved */
+ 0xF1, /* APS = 1 (small),
+ * VGL_DET_EN = 1, VGH_DET_EN = 1,
+ * VGL_TURBO = 1, VGH_TURBO = 1
+ */
+ 0xFF, /* VGH1_L_DIV, VGL1_L_DIV (1.5MHz) */
+ 0xFF, /* VGH1_R_DIV, VGL1_R_DIV (1.5MHz) */
+ 0xCC, /* VGH2_L_DIV, VGL2_L_DIV (2.6MHz) */
+ 0xCC, /* VGH2_R_DIV, VGL2_R_DIV (2.6MHz) */
+ 0x77, /* VGH3_L_DIV, VGL3_L_DIV (4.5MHz) */
+ 0x77 /* VGH3_R_DIV, VGL3_R_DIV (4.5MHz) */);
+
+ /* Reference voltage. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETBGP,
+ 0x07, /* VREF_SEL = 4.2V */
+ 0x07 /* NVREF_SEL = 4.2V */);
+
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETVCOM,
+ 0x2C, /* VCOMDC_F = -0.67V */
+ 0x2C /* VCOMDC_B = -0.67V */);
+
+ /* Undocumented command. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_UNK_BF, 0x02, 0x11, 0x00);
+
+ /* This command is to set forward GIP timing. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETGIP1,
+ 0x82, 0x10, 0x06, 0x05, 0xA2, 0x0A, 0xA5, 0x12,
+ 0x31, 0x23, 0x37, 0x83, 0x04, 0xBC, 0x27, 0x38,
+ 0x0C, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0C, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x75, 0x75, 0x31, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x13, 0x88, 0x64,
+ 0x64, 0x20, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x02, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
+
+ /* This command is to set backward GIP timing. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETGIP2,
+ 0x02, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x46, 0x02, 0x88,
+ 0x88, 0x88, 0x88, 0x88, 0x88, 0x64, 0x88, 0x13,
+ 0x57, 0x13, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88,
+ 0x75, 0x88, 0x23, 0x14, 0x00, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0A,
+ 0xA5, 0x00, 0x00, 0x00, 0x00);
+
+ /* Adjust the gamma characteristics of the panel. */
+ dsi_dcs_write_seq(dsi, ST7703_CMD_SETGAMMA,
+ 0x00, 0x09, 0x0D, 0x23, 0x27, 0x3C, 0x41, 0x35,
+ 0x07, 0x0D, 0x0E, 0x12, 0x13, 0x10, 0x12, 0x12,
+ 0x18, 0x00, 0x09, 0x0D, 0x23, 0x27, 0x3C, 0x41,
+ 0x35, 0x07, 0x0D, 0x0E, 0x12, 0x13, 0x10, 0x12,
+ 0x12, 0x18);
+
+ DRM_DEV_DEBUG_DRIVER(dev, "Panel init sequence done\n");
+ return 0;
+}
+
+static int st7703_read_id(struct st7703 *ctx)
+{
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ u8 id1, id2, id3;
+ int ret;
+
+ ret = mipi_dsi_dcs_read(dsi, ST7703_CMD_RDID1, &id1, 1);
+ if (ret < 0) {
+ DRM_DEV_ERROR(ctx->dev, "could not read ID1\n");
+ return ret;
+ }
+
+ ret = mipi_dsi_dcs_read(dsi, ST7703_CMD_RDID2, &id2, 1);
+ if (ret < 0) {
+ DRM_DEV_ERROR(ctx->dev, "could not read ID2\n");
+ return ret;
+ }
+
+ ret = mipi_dsi_dcs_read(dsi, ST7703_CMD_RDID3, &id3, 1);
+ if (ret < 0) {
+ DRM_DEV_ERROR(ctx->dev, "could not read ID3\n");
+ return ret;
+ }
+
+ DRM_DEV_INFO(ctx->dev,
+ "manufacturer: %02x version: %02x driver: %02x\n",
+ id1, id2, id3);
+
+ return 0;
+}
+
+static int st7703_prepare(struct drm_panel *panel)
+{
+ struct st7703 *ctx = panel_to_st7703(panel);
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int ret;
+
+ if (ctx->prepared)
+ return 0;
+
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+
+ ret = regulator_bulk_enable(ctx->desc->num_supplies, ctx->supplies);
+ if (ret)
+ return ret;
+
+ /* Wait for regulators to stabilize. */
+ usleep_range(10000, 20000);
+
+ gpiod_set_value_cansleep(ctx->reset_gpio, 0);
+
+ /* There needs to be at least 15ms post-reset delay. */
+ usleep_range(15000, 20000);
+
+ ret = st7703_read_id(ctx);
+ if (ret < 0)
+ goto err_poweroff;
+
+ ret = st7703_init_sequence(ctx);
+ if (ret < 0) {
+ DRM_DEV_ERROR(ctx->dev,
+ "Panel init sequence failed (%d)\n", ret);
+ goto err_poweroff;
+ }
+
+ ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+ if (ret < 0) {
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to exit sleep mode (%d)\n", ret);
+ goto err_poweroff;
+ }
+
+ msleep(120);
+
+ ret = mipi_dsi_dcs_set_display_on(dsi);
+ if (ret) {
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to turn on the display (%d)\n", ret);
+ goto err_poweroff;
+ }
+
+ ctx->prepared = true;
+
+ return 0;
+
+err_poweroff:
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+ regulator_bulk_disable(ctx->desc->num_supplies, ctx->supplies);
+ return ret;
+}
+
+static int st7703_enable(struct drm_panel *panel)
+{
+ /*
+ * Avoid flicker by waiting for slightly more than 1
+ * frame's interval.
+ */
+ msleep(50);
+
+ return 0;
+}
+
+static int st7703_unprepare(struct drm_panel *panel)
+{
+ struct st7703 *ctx = panel_to_st7703(panel);
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int ret;
+
+ if (!ctx->prepared)
+ return 0;
+
+ ret = mipi_dsi_dcs_set_display_off(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to turn off the display (%d)\n", ret);
+
+ ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to enter sleep mode (%d)\n", ret);
+
+ gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+ regulator_bulk_disable(ctx->desc->num_supplies, ctx->supplies);
+ ctx->prepared = false;
+
+ return 0;
+}
+
+static int st7703_get_modes(struct drm_panel *panel,
+ struct drm_connector *connector)
+{
+ struct st7703 *ctx = panel_to_st7703(panel);
+ struct drm_display_mode *mode;
+
+ mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
+ if (!mode) {
+ DRM_DEV_ERROR(ctx->dev, "Failed to add mode\n");
+ return -ENOMEM;
+ }
+
+ drm_mode_set_name(mode);
+
+ connector->display_info.width_mm = mode->width_mm;
+ connector->display_info.height_mm = mode->height_mm;
+ drm_mode_probed_add(connector, mode);
+
+ return 1;
+}
+
+static const struct drm_panel_funcs st7703_drm_funcs = {
+ .prepare = st7703_prepare,
+ .enable = st7703_enable,
+ .unprepare = st7703_unprepare,
+ .get_modes = st7703_get_modes,
+};
+
+static const struct drm_display_mode xbd599_mode = {
+ .hdisplay = 720,
+ .hsync_start = 720 + 40,
+ .hsync_end = 720 + 40 + 40,
+ .htotal = 720 + 40 + 40 + 40,
+ .vdisplay = 1440,
+ .vsync_start = 1440 + 18,
+ .vsync_end = 1440 + 18 + 10,
+ .vtotal = 1440 + 18 + 10 + 17,
+ .vrefresh = 60,
+ .clock = 69000,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+
+ .width_mm = 68,
+ .height_mm = 136,
+ .type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+};
+
+static const char * const xbd599_supply_names[] = {
+ "iovcc",
+ "vcc",
+};
+
+static const struct st7703_panel_desc xbd599_desc = {
+ .mode = &xbd599_mode,
+ .lanes = 4,
+ .flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .supply_names = xbd599_supply_names,
+ .num_supplies = ARRAY_SIZE(xbd599_supply_names),
+};
+
+static int st7703_probe(struct mipi_dsi_device *dsi)
+{
+ const struct st7703_panel_desc *desc;
+ struct device *dev = &dsi->dev;
+ struct st7703 *ctx;
+ int i, ret;
+
+ ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
+ if (!ctx)
+ return -ENOMEM;
+
+ ctx->dev = dev;
+ ctx->desc = desc = of_device_get_match_data(dev);
+
+ dsi->mode_flags = desc->flags;
+ dsi->format = desc->format;
+ dsi->lanes = desc->lanes;
+
+ ctx->supplies = devm_kcalloc(&dsi->dev, desc->num_supplies,
+ sizeof(*ctx->supplies),
+ GFP_KERNEL);
+ if (!ctx->supplies)
+ return -ENOMEM;
+
+ for (i = 0; i < desc->num_supplies; i++)
+ ctx->supplies[i].supply = desc->supply_names[i];
+
+ ret = devm_regulator_bulk_get(&dsi->dev, desc->num_supplies,
+ ctx->supplies);
+ if (ret < 0)
+ return ret;
+
+ ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR(ctx->reset_gpio)) {
+ DRM_DEV_ERROR(dev, "Can't get reset gpio\n");
+ return PTR_ERR(ctx->reset_gpio);
+ }
+
+ mipi_dsi_set_drvdata(dsi, ctx);
+
+ drm_panel_init(&ctx->panel, &dsi->dev, &st7703_drm_funcs,
+ DRM_MODE_CONNECTOR_DSI);
+
+ ret = drm_panel_of_backlight(&ctx->panel);
+ if (ret)
+ return ret;
+
+ drm_panel_add(&ctx->panel);
+
+ ret = mipi_dsi_attach(dsi);
+ if (ret < 0) {
+ drm_panel_remove(&ctx->panel);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void st7703_shutdown(struct mipi_dsi_device *dsi)
+{
+ struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
+ int ret;
+
+ ret = drm_panel_unprepare(&ctx->panel);
+ if (ret < 0)
+ DRM_DEV_ERROR(&dsi->dev,
+ "Failed to unprepare panel (%d)\n", ret);
+}
+
+static int st7703_remove(struct mipi_dsi_device *dsi)
+{
+ struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
+ int ret;
+
+ st7703_shutdown(dsi);
+
+ ret = mipi_dsi_detach(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(&dsi->dev,
+ "Failed to detach from DSI host (%d)\n", ret);
+
+ drm_panel_remove(&ctx->panel);
+
+ return 0;
+}
+
+static const struct of_device_id st7703_of_match[] = {
+ { .compatible = "xingbangda,xbd599", .data = &xbd599_desc },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, st7703_of_match);
+
+static struct mipi_dsi_driver st7703_driver = {
+ .probe = st7703_probe,
+ .remove = st7703_remove,
+ .shutdown = st7703_shutdown,
+ .driver = {
+ .name = "st7703",
+ .of_match_table = st7703_of_match,
+ },
+};
+module_mipi_dsi_driver(st7703_driver);
+
+MODULE_AUTHOR("Icenowy Zheng <ice...@aosc.io>");
+MODULE_DESCRIPTION("DRM driver for Sitronix ST7703 MIPI DSI panel");
+MODULE_LICENSE("GPL v2");
--
2.27.0

Ondrej Jirman

unread,
Jun 16, 2020, 8:32:18 PM6/16/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Pinephone has a Goodix GT917S capacitive touchscreen controller on
I2C0 bus. Add support for it.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../dts/allwinner/sun50i-a64-pinephone.dtsi | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index e60b57f8ac14..6b2ff431cddb 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -123,6 +123,25 @@ &ehci1 {
status = "okay";
};

+&i2c0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c0_pins>;
+ status = "okay";
+
+ touchscreen@5d {
+ compatible = "goodix,gt917s", "goodix,gt911";
+ reg = <0x5d>;
+ interrupt-parent = <&pio>;
+ interrupts = <7 4 IRQ_TYPE_LEVEL_HIGH>; /* PH4 */
+ irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
+ reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
+ AVDD28-supply = <&reg_ldo_io0>;
+ VDDIO-supply = <&reg_ldo_io0>;
+ touchscreen-size-x = <720>;
+ touchscreen-size-y = <1440>;
+ };
+};
+
&i2c1 {
status = "okay";

--
2.27.0

Ondřej Jirman

unread,
Jun 20, 2020, 6:30:14 PM6/20/20
to Sam Ravnborg, linux...@googlegroups.com, Thierry Reding, David Airlie, Daniel Vetter, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, devic...@vger.kernel.org, Samuel Holland, Bhushan Shah, linux-...@vger.kernel.org, dri-...@lists.freedesktop.org, Luca Weiss, Martijn Braam, linux-ar...@lists.infradead.org
On Sat, Jun 20, 2020 at 11:25:29PM +0200, Sam Ravnborg wrote:
> Hi Ondrej et al.
>
> On Wed, Jun 17, 2020 at 02:32:07AM +0200, Ondrej Jirman wrote:
> > From: Icenowy Zheng <ice...@aosc.io>
> >
> > Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI IPS LCD panel made by
> > Xingbangda, which is used on PinePhone final assembled phones.
> >
> > It is based on Sitronix ST7703 LCD controller.
>
> I am a little late to the game here - so sorry if this has been
> discussed before.
> We already have panel-rocktech-jh057n00900.c which is a panle driver
> based on st7703.
> Why is it we need a new driver?

No reason other than the driver not being named after the controller,
so I didn't notice.

> Would it not be better to have one st7703 driver that suipports both
> panels?
>
> The driver would need dedicated init functions depending on the panel.
> But a lot could also be shared.

I guess I can move the code there.

regards,
o.

> Sam
> > _______________________________________________
> > dri-devel mailing list
> > dri-...@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

Ondřej Jirman

unread,
Jun 22, 2020, 7:17:56 AM6/22/20
to Sam Ravnborg, linux...@googlegroups.com, Thierry Reding, David Airlie, Daniel Vetter, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, devic...@vger.kernel.org, Samuel Holland, Bhushan Shah, linux-...@vger.kernel.org, dri-...@lists.freedesktop.org, Luca Weiss, Martijn Braam, linux-ar...@lists.infradead.org
Hello Sam,

On Mon, Jun 22, 2020 at 10:08:02AM +0200, Sam Ravnborg wrote:
> On Sun, Jun 21, 2020 at 12:30:10AM +0200, Ondřej Jirman wrote:
> > On Sat, Jun 20, 2020 at 11:25:29PM +0200, Sam Ravnborg wrote:
> > > Hi Ondrej et al.

...

> > > Would it not be better to have one st7703 driver that suipports both
> > > panels?
> > >
> > > The driver would need dedicated init functions depending on the panel.
> > > But a lot could also be shared.
> >
> > I guess I can move the code there.
> In the same process the river should then be renamed to follow other
> sitronix based drivers.
> So the next developer will recognize this and use the correct driver.

Are driver/module names considered kernel ABI? Or is it possible to
change them?

regards,
o.

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:07 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This patchset adds support for the LCD panel of PinePhone.

I've tested this on PinePhone 1.0 and 1.2.

Please take a look.

thank you and regards,
Ondrej Jirman

Changes in v5:
- rewritten on top of rocktech-jh057n00900 driver
- rocktech-jh057n00900 renamed to st7703 (controller name)
- converted rocktech-jh057n00900 bindings to yaml and extended for xbd599
Icenowy Zheng (2):
dt-bindings: vendor-prefixes: Add Xingbangda
arm64: dts: sun50i-a64-pinephone: Enable LCD support on PinePhone

Ondrej Jirman (11):
dt-bindings: panel: Convert rocktech,jh057n00900 to yaml
dt-bindings: panel: Add compatible for Xingbangda XBD599 panel
drm/panel: rocktech-jh057n00900: Rename the driver to st7703
drm/panel: st7703: Rename functions from jh057n prefix to st7703
drm/panel: st7703: Prepare for supporting multiple panels
drm/panel: st7703: Move code specific to jh057n closer together
drm/panel: st7703: Move generic part of init sequence to enable
callback
drm/panel: st7703: Add support for Xingbangda XBD599
drm/panel: st7703: Enter sleep after display off
drm/panel: st7703: Assert reset prior to powering down the regulators
arm64: dts: sun50i-a64-pinephone: Add touchscreen support

.../display/panel/rocktech,jh057n00900.txt | 23 -
.../display/panel/rocktech,jh057n00900.yaml | 70 ++
.../devicetree/bindings/vendor-prefixes.yaml | 2 +
.../allwinner/sun50i-a64-pinephone-1.1.dts | 19 +
.../dts/allwinner/sun50i-a64-pinephone.dtsi | 54 ++
drivers/gpu/drm/panel/Kconfig | 26 +-
drivers/gpu/drm/panel/Makefile | 2 +-
.../drm/panel/panel-rocktech-jh057n00900.c | 424 ------------
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 655 ++++++++++++++++++
9 files changed, 814 insertions(+), 461 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt
create mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
delete mode 100644 drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:09 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This is done so that code that's not specific to a particular
jh057n panel is named after the controller. Functions specific
to the panel are kept named after the panel.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 90 ++++++++++---------
1 file changed, 46 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 38ff742bc120..511af659f273 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
/*
- * Rockteck jh057n00900 5.5" MIPI-DSI panel driver
+ * Driver for panels based on Sitronix ST7703 controller, souch as:
+ *
+ * - Rocktech jh057n00900 5.5" MIPI-DSI panel
*
* Copyright (C) Purism SPC 2019
*/
@@ -21,7 +23,7 @@
#include <drm/drm_panel.h>
#include <drm/drm_print.h>

-#define DRV_NAME "panel-rocktech-jh057n00900"
+#define DRV_NAME "panel-sitronix-st7703"

/* Manufacturer specific Commands send via DSI */
#define ST7703_CMD_ALL_PIXEL_OFF 0x22
@@ -45,7 +47,7 @@
#define ST7703_CMD_SETGIP1 0xE9
#define ST7703_CMD_SETGIP2 0xEA

-struct jh057n {
+struct st7703 {
struct device *dev;
struct drm_panel panel;
struct gpio_desc *reset_gpio;
@@ -56,9 +58,9 @@ struct jh057n {
struct dentry *debugfs;
};

-static inline struct jh057n *panel_to_jh057n(struct drm_panel *panel)
+static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
{
- return container_of(panel, struct jh057n, panel);
+ return container_of(panel, struct st7703, panel);
}

#define dsi_generic_write_seq(dsi, seq...) do { \
@@ -69,7 +71,7 @@ static inline struct jh057n *panel_to_jh057n(struct drm_panel *panel)
return ret; \
} while (0)

-static int jh057n_init_sequence(struct jh057n *ctx)
+static int jh057n_init_sequence(struct st7703 *ctx)
{
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct device *dev = ctx->dev;
@@ -141,9 +143,9 @@ static int jh057n_init_sequence(struct jh057n *ctx)
return 0;
}

-static int jh057n_enable(struct drm_panel *panel)
+static int st7703_enable(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
int ret;

ret = jh057n_init_sequence(ctx);
@@ -156,17 +158,17 @@ static int jh057n_enable(struct drm_panel *panel)
return 0;
}

-static int jh057n_disable(struct drm_panel *panel)
+static int st7703_disable(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);

return mipi_dsi_dcs_set_display_off(dsi);
}

-static int jh057n_unprepare(struct drm_panel *panel)
+static int st7703_unprepare(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);

if (!ctx->prepared)
return 0;
@@ -178,9 +180,9 @@ static int jh057n_unprepare(struct drm_panel *panel)
return 0;
}

-static int jh057n_prepare(struct drm_panel *panel)
+static int st7703_prepare(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
int ret;

if (ctx->prepared)
@@ -230,10 +232,10 @@ static const struct drm_display_mode default_mode = {
.height_mm = 130,
};

-static int jh057n_get_modes(struct drm_panel *panel,
+static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
struct drm_display_mode *mode;

mode = drm_mode_duplicate(connector->dev, &default_mode);
@@ -254,17 +256,17 @@ static int jh057n_get_modes(struct drm_panel *panel,
return 1;
}

-static const struct drm_panel_funcs jh057n_drm_funcs = {
- .disable = jh057n_disable,
- .unprepare = jh057n_unprepare,
- .prepare = jh057n_prepare,
- .enable = jh057n_enable,
- .get_modes = jh057n_get_modes,
+static const struct drm_panel_funcs st7703_drm_funcs = {
+ .disable = st7703_disable,
+ .unprepare = st7703_unprepare,
+ .prepare = st7703_prepare,
+ .enable = st7703_enable,
+ .get_modes = st7703_get_modes,
};

static int allpixelson_set(void *data, u64 val)
{
- struct jh057n *ctx = data;
+ struct st7703 *ctx = data;
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);

DRM_DEV_DEBUG_DRIVER(ctx->dev, "Setting all pixels on\n");
@@ -282,7 +284,7 @@ static int allpixelson_set(void *data, u64 val)
DEFINE_SIMPLE_ATTRIBUTE(allpixelson_fops, NULL,
allpixelson_set, "%llu\n");

-static void jh057n_debugfs_init(struct jh057n *ctx)
+static void st7703_debugfs_init(struct st7703 *ctx)
{
ctx->debugfs = debugfs_create_dir(DRV_NAME, NULL);

@@ -290,16 +292,16 @@ static void jh057n_debugfs_init(struct jh057n *ctx)
&allpixelson_fops);
}

-static void jh057n_debugfs_remove(struct jh057n *ctx)
+static void st7703_debugfs_remove(struct st7703 *ctx)
{
debugfs_remove_recursive(ctx->debugfs);
ctx->debugfs = NULL;
}

-static int jh057n_probe(struct mipi_dsi_device *dsi)
+static int st7703_probe(struct mipi_dsi_device *dsi)
{
struct device *dev = &dsi->dev;
- struct jh057n *ctx;
+ struct st7703 *ctx;
int ret;

ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
@@ -340,7 +342,7 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
return ret;
}

- drm_panel_init(&ctx->panel, dev, &jh057n_drm_funcs,
+ drm_panel_init(&ctx->panel, dev, &st7703_drm_funcs,
DRM_MODE_CONNECTOR_DSI);

ret = drm_panel_of_backlight(&ctx->panel);
@@ -363,13 +365,13 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
default_mode.vrefresh,
mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);

- jh057n_debugfs_init(ctx);
+ st7703_debugfs_init(ctx);
return 0;
}

-static void jh057n_shutdown(struct mipi_dsi_device *dsi)
+static void st7703_shutdown(struct mipi_dsi_device *dsi)
{
- struct jh057n *ctx = mipi_dsi_get_drvdata(dsi);
+ struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
int ret;

ret = drm_panel_unprepare(&ctx->panel);
@@ -383,12 +385,12 @@ static void jh057n_shutdown(struct mipi_dsi_device *dsi)
ret);
}

-static int jh057n_remove(struct mipi_dsi_device *dsi)
+static int st7703_remove(struct mipi_dsi_device *dsi)
{
- struct jh057n *ctx = mipi_dsi_get_drvdata(dsi);
+ struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
int ret;

- jh057n_shutdown(dsi);
+ st7703_shutdown(dsi);

ret = mipi_dsi_detach(dsi);
if (ret < 0)
@@ -397,28 +399,28 @@ static int jh057n_remove(struct mipi_dsi_device *dsi)

drm_panel_remove(&ctx->panel);

- jh057n_debugfs_remove(ctx);
+ st7703_debugfs_remove(ctx);

return 0;
}

-static const struct of_device_id jh057n_of_match[] = {
+static const struct of_device_id st7703_of_match[] = {
{ .compatible = "rocktech,jh057n00900" },
{ /* sentinel */ }
};
-MODULE_DEVICE_TABLE(of, jh057n_of_match);
+MODULE_DEVICE_TABLE(of, st7703_of_match);

-static struct mipi_dsi_driver jh057n_driver = {
- .probe = jh057n_probe,
- .remove = jh057n_remove,
- .shutdown = jh057n_shutdown,
+static struct mipi_dsi_driver st7703_driver = {
+ .probe = st7703_probe,
+ .remove = st7703_remove,
+ .shutdown = st7703_shutdown,
.driver = {
.name = DRV_NAME,
- .of_match_table = jh057n_of_match,
+ .of_match_table = st7703_of_match,
},
};
-module_mipi_dsi_driver(jh057n_driver);
+module_mipi_dsi_driver(st7703_driver);

MODULE_AUTHOR("Guido Günther <a...@sigxcpu.org>");
-MODULE_DESCRIPTION("DRM driver for Rocktech JH057N00900 MIPI DSI panel");
+MODULE_DESCRIPTION("DRM driver for Sitronix ST7703 based MIPI DSI panels");

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:09 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
It's better than having it spread around the driver.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 50 +++++++++----------
1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 08cbc316266c..d03aab10cfef 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -153,6 +153,31 @@ static int jh057n_init_sequence(struct st7703 *ctx)
return 0;
}

+static const struct drm_display_mode jh057n00900_mode = {
+ .hdisplay = 720,
+ .hsync_start = 720 + 90,
+ .hsync_end = 720 + 90 + 20,
+ .htotal = 720 + 90 + 20 + 20,
+ .vdisplay = 1440,
+ .vsync_start = 1440 + 20,
+ .vsync_end = 1440 + 20 + 4,
+ .vtotal = 1440 + 20 + 4 + 12,
+ .vrefresh = 60,
+ .clock = 75276,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .width_mm = 65,
+ .height_mm = 130,
+};
+
+struct st7703_panel_desc jh057n00900_panel_desc = {
+ .mode = &jh057n00900_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO |
+ MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = jh057n_init_sequence,
+};
+
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
@@ -226,31 +251,6 @@ static int st7703_prepare(struct drm_panel *panel)
return ret;
}

-static const struct drm_display_mode jh057n00900_mode = {
- .hdisplay = 720,
- .hsync_start = 720 + 90,
- .hsync_end = 720 + 90 + 20,
- .htotal = 720 + 90 + 20 + 20,
- .vdisplay = 1440,
- .vsync_start = 1440 + 20,
- .vsync_end = 1440 + 20 + 4,
- .vtotal = 1440 + 20 + 4 + 12,
- .vrefresh = 60,
- .clock = 75276,
- .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
- .width_mm = 65,
- .height_mm = 130,
-};
-
-struct st7703_panel_desc jh057n00900_panel_desc = {
- .mode = &jh057n00900_mode,
- .lanes = 4,
- .mode_flags = MIPI_DSI_MODE_VIDEO |
- MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
- .format = MIPI_DSI_FMT_RGB888,
- .init_sequence = jh057n_init_sequence,
-};
-
static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
--
2.27.0

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:09 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Parametrize the driver so that it can support more panels based
on st7703 controller.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 43 +++++++++++++------
1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 511af659f273..08cbc316266c 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -13,6 +13,7 @@
#include <linux/media-bus-format.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/regulator/consumer.h>

#include <video/display_timing.h>
@@ -56,6 +57,15 @@ struct st7703 {
bool prepared;

struct dentry *debugfs;
+ const struct st7703_panel_desc *desc;
+};
+
+struct st7703_panel_desc {
+ const struct drm_display_mode *mode;
+ unsigned int lanes;
+ unsigned long mode_flags;
+ enum mipi_dsi_pixel_format format;
+ int (*init_sequence)(struct st7703 *ctx);
};

static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
@@ -148,7 +158,7 @@ static int st7703_enable(struct drm_panel *panel)
struct st7703 *ctx = panel_to_st7703(panel);
int ret;

- ret = jh057n_init_sequence(ctx);
+ ret = ctx->desc->init_sequence(ctx);
if (ret < 0) {
DRM_DEV_ERROR(ctx->dev, "Panel init sequence failed: %d\n",
ret);
@@ -216,7 +226,7 @@ static int st7703_prepare(struct drm_panel *panel)
return ret;
}

-static const struct drm_display_mode default_mode = {
+static const struct drm_display_mode jh057n00900_mode = {
.hdisplay = 720,
.hsync_start = 720 + 90,
.hsync_end = 720 + 90 + 20,
@@ -232,17 +242,26 @@ static const struct drm_display_mode default_mode = {
.height_mm = 130,
};

+struct st7703_panel_desc jh057n00900_panel_desc = {
+ .mode = &jh057n00900_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO |
+ MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = jh057n_init_sequence,
+};
+
static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct st7703 *ctx = panel_to_st7703(panel);
struct drm_display_mode *mode;

- mode = drm_mode_duplicate(connector->dev, &default_mode);
+ mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
if (!mode) {
DRM_DEV_ERROR(ctx->dev, "Failed to add mode %ux%u@%u\n",
- default_mode.hdisplay, default_mode.vdisplay,
- default_mode.vrefresh);
+ ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
+ ctx->desc->mode->vrefresh);
return -ENOMEM;
}

@@ -317,11 +336,11 @@ static int st7703_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, ctx);

ctx->dev = dev;
+ ctx->desc = of_device_get_match_data(dev);

- dsi->lanes = 4;
- dsi->format = MIPI_DSI_FMT_RGB888;
- dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
- MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
+ dsi->mode_flags = ctx->desc->mode_flags;
+ dsi->format = ctx->desc->format;
+ dsi->lanes = ctx->desc->lanes;

ctx->vcc = devm_regulator_get(dev, "vcc");
if (IS_ERR(ctx->vcc)) {
@@ -361,8 +380,8 @@ static int st7703_probe(struct mipi_dsi_device *dsi)
}

DRM_DEV_INFO(dev, "%ux%u@%u %ubpp dsi %udl - ready\n",
- default_mode.hdisplay, default_mode.vdisplay,
- default_mode.vrefresh,
+ ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
+ ctx->desc->mode->vrefresh,
mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);

st7703_debugfs_init(ctx);
@@ -405,7 +424,7 @@ static int st7703_remove(struct mipi_dsi_device *dsi)
}

static const struct of_device_id st7703_of_match[] = {
- { .compatible = "rocktech,jh057n00900" },
+ { .compatible = "rocktech,jh057n00900", .data = &jh057n00900_panel_desc },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, st7703_of_match);
--
2.27.0

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:10 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Calling sleep out and display on is a controller specific part
of the initialization process. Move it out of the panel specific
initialization function to the enable callback.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 33 ++++++++++---------
1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index d03aab10cfef..cdbf7dfb4dd4 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -84,8 +84,6 @@ static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
static int jh057n_init_sequence(struct st7703 *ctx)
{
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
- struct device *dev = ctx->dev;
- int ret;

/*
* Init sequence was supplied by the panel vendor. Most of the commands
@@ -136,20 +134,7 @@ static int jh057n_init_sequence(struct st7703 *ctx)
0x18, 0x00, 0x09, 0x0E, 0x29, 0x2D, 0x3C, 0x41,
0x37, 0x07, 0x0B, 0x0D, 0x10, 0x11, 0x0F, 0x10,
0x11, 0x18);
- msleep(20);
-
- ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
- if (ret < 0) {
- DRM_DEV_ERROR(dev, "Failed to exit sleep mode: %d\n", ret);
- return ret;
- }
- /* Panel is operational 120 msec after reset */
- msleep(60);
- ret = mipi_dsi_dcs_set_display_on(dsi);
- if (ret)
- return ret;

- DRM_DEV_DEBUG_DRIVER(dev, "Panel init sequence done\n");
return 0;
}

@@ -181,6 +166,7 @@ struct st7703_panel_desc jh057n00900_panel_desc = {
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
int ret;

ret = ctx->desc->init_sequence(ctx);
@@ -190,6 +176,23 @@ static int st7703_enable(struct drm_panel *panel)
return ret;
}

+ msleep(20);
+
+ ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+ if (ret < 0) {
+ DRM_DEV_ERROR(ctx->dev, "Failed to exit sleep mode: %d\n", ret);
+ return ret;
+ }
+
+ /* Panel is operational 120 msec after reset */
+ msleep(60);
+
+ ret = mipi_dsi_dcs_set_display_on(dsi);
+ if (ret)
+ return ret;
+
+ DRM_DEV_DEBUG_DRIVER(ctx->dev, "Panel init sequence done\n");
+
return 0;
}

--
2.27.0

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:11 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI LCD panel used in
PinePhone. Add support for it.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 199 +++++++++++++++++-
1 file changed, 197 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index cdbf7dfb4dd4..33611419059a 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -39,10 +39,11 @@
#define ST7703_CMD_SETEXTC 0xB9
#define ST7703_CMD_SETMIPI 0xBA
#define ST7703_CMD_SETVDC 0xBC
-#define ST7703_CMD_UNKNOWN0 0xBF
+#define ST7703_CMD_UNKNOWN_BF 0xBF
#define ST7703_CMD_SETSCR 0xC0
#define ST7703_CMD_SETPOWER 0xC1
#define ST7703_CMD_SETPANEL 0xCC
+#define ST7703_CMD_UNKNOWN_C6 0xC6
#define ST7703_CMD_SETGAMMA 0xE0
#define ST7703_CMD_SETEQ 0xE3
#define ST7703_CMD_SETGIP1 0xE9
@@ -109,7 +110,7 @@ static int jh057n_init_sequence(struct st7703 *ctx)
msleep(20);

dsi_generic_write_seq(dsi, ST7703_CMD_SETVCOM, 0x3F, 0x3F);
- dsi_generic_write_seq(dsi, ST7703_CMD_UNKNOWN0, 0x02, 0x11, 0x00);
+ dsi_generic_write_seq(dsi, ST7703_CMD_UNKNOWN_BF, 0x02, 0x11, 0x00);
dsi_generic_write_seq(dsi, ST7703_CMD_SETGIP1,
0x82, 0x10, 0x06, 0x05, 0x9E, 0x0A, 0xA5, 0x12,
0x31, 0x23, 0x37, 0x83, 0x04, 0xBC, 0x27, 0x38,
@@ -163,6 +164,199 @@ struct st7703_panel_desc jh057n00900_panel_desc = {
.init_sequence = jh057n_init_sequence,
};

+#define dsi_dcs_write_seq(dsi, cmd, seq...) do { \
+ static const u8 d[] = { seq }; \
+ int ret; \
+ ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d)); \
+ if (ret < 0) \
+ return ret; \
+ } while (0)
+
+
+static int xbd599_init_sequence(struct st7703 *ctx)
+{
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ dsi_dcs_write_seq(dsi, ST7703_CMD_UNKNOWN_C6, 0x01, 0x00, 0xFF, 0xFF, 0x00);
+ dsi_dcs_write_seq(dsi, ST7703_CMD_UNKNOWN_BF, 0x02, 0x11, 0x00);
+ return 0;
+}
+
+static const struct drm_display_mode xbd599_mode = {
+ .hdisplay = 720,
+ .hsync_start = 720 + 40,
+ .hsync_end = 720 + 40 + 40,
+ .htotal = 720 + 40 + 40 + 40,
+ .vdisplay = 1440,
+ .vsync_start = 1440 + 18,
+ .vsync_end = 1440 + 18 + 10,
+ .vtotal = 1440 + 18 + 10 + 17,
+ .vrefresh = 60,
+ .clock = 69000,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .width_mm = 68,
+ .height_mm = 136,
+};
+
+static const struct st7703_panel_desc xbd599_desc = {
+ .mode = &xbd599_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = xbd599_init_sequence,
+};
+
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
@@ -428,6 +622,7 @@ static int st7703_remove(struct mipi_dsi_device *dsi)

static const struct of_device_id st7703_of_match[] = {
{ .compatible = "rocktech,jh057n00900", .data = &jh057n00900_panel_desc },
+ { .compatible = "xingbangda,xbd599", .data = &xbd599_desc },

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:11 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah, Ondrej Jirman
From: Icenowy Zheng <ice...@aosc.io>

PinePhone uses PWM backlight and a XBD599 LCD panel over DSI for
display.

Backlight levels curve was optimized by Martijn Braam using a
lux meter.

Add its device nodes.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Martijn Braam <mar...@brixit.nl>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../allwinner/sun50i-a64-pinephone-1.1.dts | 19 ++++++++++
.../dts/allwinner/sun50i-a64-pinephone.dtsi | 35 +++++++++++++++++++
2 files changed, 54 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts
index 06a775c41664..3e99a87e9ce5 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone-1.1.dts
@@ -9,3 +9,22 @@ / {
model = "Pine64 PinePhone Braveheart (1.1)";
compatible = "pine64,pinephone-1.1", "allwinner,sun50i-a64";
};
+
+&backlight {
+ power-supply = <&reg_ldo_io0>;
+ /*
+ * PWM backlight circuit on this PinePhone revision was changed since
+ * 1.0, and the lowest PWM duty cycle that doesn't lead to backlight
+ * being off is around 20%. Duty cycle for the lowest brightness level
+ * also varries quite a bit between individual boards, so the lowest
+ * value here was chosen as a safe default.
+ */
+ brightness-levels = <
+ 774 793 814 842
+ 882 935 1003 1088
+ 1192 1316 1462 1633
+ 1830 2054 2309 2596
+ 2916 3271 3664 4096>;
+ num-interpolated-steps = <50>;
+ default-brightness-level = <400>;
+};
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index cefda145c3c9..85a7aa5efd32 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -16,6 +16,13 @@ aliases {
serial0 = &uart0;
};

+ backlight: backlight {
+ compatible = "pwm-backlight";
+ pwms = <&r_pwm 0 50000 PWM_POLARITY_INVERTED>;
+ enable-gpios = <&pio 7 10 GPIO_ACTIVE_HIGH>; /* PH10 */
+ /* Backlight configuration differs per PinePhone revision. */
+ };
+
chosen {
stdout-path = "serial0:115200n8";
};
@@ -84,6 +91,30 @@ &dai {
status = "okay";
};

+&de {
+ status = "okay";
+};
+
+&dphy {
+ status = "okay";
+};
+
+&dsi {
+ vcc-dsi-supply = <&reg_dldo1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ panel@0 {
+ compatible = "xingbangda,xbd599";
+ reg = <0>;
+ reset-gpios = <&pio 3 23 GPIO_ACTIVE_LOW>; /* PD23 */
+ iovcc-supply = <&reg_dldo2>;
+ vcc-supply = <&reg_ldo_io0>;
+ backlight = <&backlight>;
+ };
+};
+
&ehci0 {
status = "okay";
};
@@ -188,6 +219,10 @@ &r_pio {
*/
};

+&r_pwm {
+ status = "okay";
+};
+
&r_rsb {

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:11 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
The datasheet suggests to issue sleep in after display off
as a part of the panel's shutdown sequence.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 33611419059a..e771281eb547 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -394,8 +394,19 @@ static int st7703_disable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int ret;
+
+ ret = mipi_dsi_dcs_set_display_off(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to turn off the display: %d\n", ret);

- return mipi_dsi_dcs_set_display_off(dsi);
+ ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to enter sleep mode: %d\n", ret);
+
+ return 0;
}

static int st7703_unprepare(struct drm_panel *panel)
--
2.27.0

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:11 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
The reset pin is inverted, so if we don't assert reset, the actual gpio
will be high and may keep driving the IO port of the panel.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index e771281eb547..92930e127559 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -416,6 +416,7 @@ static int st7703_unprepare(struct drm_panel *panel)
if (!ctx->prepared)
return 0;

+ gpiod_set_value_cansleep(ctx->reset_gpio, 1);
regulator_disable(ctx->iovcc);
regulator_disable(ctx->vcc);
ctx->prepared = false;
--
2.27.0

Ondrej Jirman

unread,
Jun 25, 2020, 8:56:13 PM6/25/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Pinephone has a Goodix GT917S capacitive touchscreen controller on
I2C0 bus. Add support for it.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../dts/allwinner/sun50i-a64-pinephone.dtsi | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index 85a7aa5efd32..2d5694446d17 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -123,6 +123,25 @@ &ehci1 {
status = "okay";
};

+&i2c0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c0_pins>;
+ status = "okay";
+
+ touchscreen@5d {
+ compatible = "goodix,gt917s", "goodix,gt911";
+ reg = <0x5d>;
+ interrupt-parent = <&pio>;
+ interrupts = <7 4 IRQ_TYPE_LEVEL_HIGH>; /* PH4 */
+ irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
+ reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
+ AVDD28-supply = <&reg_ldo_io0>;
+ VDDIO-supply = <&reg_ldo_io0>;
+ touchscreen-size-x = <720>;
+ touchscreen-size-y = <1440>;
+ };
+};
+
&i2c1 {

Linus Walleij

unread,
Jul 1, 2020, 3:48:15 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> This is done so that code that's not specific to a particular
> jh057n panel is named after the controller. Functions specific
> to the panel are kept named after the panel.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Reviewed-by: Linus Walleij <linus....@linaro.org>

Yours,
Linus Walleij

Linus Walleij

unread,
Jul 1, 2020, 3:48:51 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> Parametrize the driver so that it can support more panels based
> on st7703 controller.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Linus Walleij

unread,
Jul 1, 2020, 3:49:25 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> It's better than having it spread around the driver.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Linus Walleij

unread,
Jul 1, 2020, 3:50:15 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> Calling sleep out and display on is a controller specific part
> of the initialization process. Move it out of the panel specific
> initialization function to the enable callback.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Linus Walleij

unread,
Jul 1, 2020, 3:50:53 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI LCD panel used in
> PinePhone. Add support for it.
>
> Signed-off-by: Icenowy Zheng <ice...@aosc.io>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Linus Walleij

unread,
Jul 1, 2020, 3:51:24 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> The datasheet suggests to issue sleep in after display off
> as a part of the panel's shutdown sequence.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Linus Walleij

unread,
Jul 1, 2020, 3:51:54 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> The reset pin is inverted, so if we don't assert reset, the actual gpio
> will be high and may keep driving the IO port of the panel.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Linus Walleij

unread,
Jul 1, 2020, 3:52:35 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> From: Icenowy Zheng <ice...@aosc.io>
>
> PinePhone uses PWM backlight and a XBD599 LCD panel over DSI for
> display.
>
> Backlight levels curve was optimized by Martijn Braam using a
> lux meter.
>
> Add its device nodes.
>
> Signed-off-by: Icenowy Zheng <ice...@aosc.io>
> Signed-off-by: Martijn Braam <mar...@brixit.nl>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Acked-by: Linus Walleij <linus....@linaro.org>

Yours,
Linus Walleij

Linus Walleij

unread,
Jul 1, 2020, 3:53:07 AM7/1/20
to Ondrej Jirman, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
On Fri, Jun 26, 2020 at 2:56 AM Ondrej Jirman <meg...@megous.com> wrote:

> Pinephone has a Goodix GT917S capacitive touchscreen controller on
> I2C0 bus. Add support for it.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:33 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This patchset adds support for the LCD panel of PinePhone.

I've tested this on PinePhone 1.0 and 1.2.

Please take a look.

thank you and regards,
Ondrej Jirman

Changes in v6:
- Fixed spacing in yaml
- Fixed wrong vccio->iovcc supply name in the bindings doc
- I noticed that the original driver uses a delay of 20ms in the init
function to achieve a combined total of 120ms required from post-reset
to display_on. I've added a similar delay to xbd599_init, so that
xbd599 panel also has the right timing. (patch 9)
- v5->v6 diff: https://megous.com/dl/tmp/v5-v6.patch
- Added review/ack tags
- Learned to run dt_binding_check by myself ;)
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 656 ++++++++++++++++++
9 files changed, 815 insertions(+), 461 deletions(-)

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:34 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Parametrize the driver so that it can support more panels based
on st7703 controller.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 43 +++++++++++++------
1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 511af659f273..08cbc316266c 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -13,6 +13,7 @@
#include <linux/media-bus-format.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/regulator/consumer.h>

#include <video/display_timing.h>
@@ -56,6 +57,15 @@ struct st7703 {
bool prepared;

struct dentry *debugfs;
+ const struct st7703_panel_desc *desc;
+};
+
+struct st7703_panel_desc {
+ const struct drm_display_mode *mode;
+ unsigned int lanes;
+ unsigned long mode_flags;
+ enum mipi_dsi_pixel_format format;
+ int (*init_sequence)(struct st7703 *ctx);
};

static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
@@ -148,7 +158,7 @@ static int st7703_enable(struct drm_panel *panel)
struct st7703 *ctx = panel_to_st7703(panel);
int ret;

- ret = jh057n_init_sequence(ctx);
+ ret = ctx->desc->init_sequence(ctx);
if (ret < 0) {
DRM_DEV_ERROR(ctx->dev, "Panel init sequence failed: %d\n",
ret);
@@ -216,7 +226,7 @@ static int st7703_prepare(struct drm_panel *panel)
return ret;
}

-static const struct drm_display_mode default_mode = {
+static const struct drm_display_mode jh057n00900_mode = {
.hdisplay = 720,
.hsync_start = 720 + 90,
.hsync_end = 720 + 90 + 20,
@@ -232,17 +242,26 @@ static const struct drm_display_mode default_mode = {
.height_mm = 130,
};

+struct st7703_panel_desc jh057n00900_panel_desc = {
+ .mode = &jh057n00900_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO |
+ MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = jh057n_init_sequence,
+};
+
static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct st7703 *ctx = panel_to_st7703(panel);
@@ -405,7 +424,7 @@ static int st7703_remove(struct mipi_dsi_device *dsi)
}

static const struct of_device_id st7703_of_match[] = {
- { .compatible = "rocktech,jh057n00900" },
+ { .compatible = "rocktech,jh057n00900", .data = &jh057n00900_panel_desc },

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:34 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
It's better than having it spread around the driver.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 50 +++++++++----------
1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 08cbc316266c..d03aab10cfef 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -153,6 +153,31 @@ static int jh057n_init_sequence(struct st7703 *ctx)
return 0;
}

+static const struct drm_display_mode jh057n00900_mode = {
+ .hdisplay = 720,
+ .hsync_start = 720 + 90,
+ .hsync_end = 720 + 90 + 20,
+ .htotal = 720 + 90 + 20 + 20,
+ .vdisplay = 1440,
+ .vsync_start = 1440 + 20,
+ .vsync_end = 1440 + 20 + 4,
+ .vtotal = 1440 + 20 + 4 + 12,
+ .vrefresh = 60,
+ .clock = 75276,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .width_mm = 65,
+ .height_mm = 130,
+};
+
+struct st7703_panel_desc jh057n00900_panel_desc = {
+ .mode = &jh057n00900_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO |
+ MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = jh057n_init_sequence,
+};
+
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
@@ -226,31 +251,6 @@ static int st7703_prepare(struct drm_panel *panel)
return ret;
}
static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
--
2.27.0

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:35 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This is done so that code that's not specific to a particular
jh057n panel is named after the controller. Functions specific
to the panel are kept named after the panel.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 90 ++++++++++---------
1 file changed, 46 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 38ff742bc120..511af659f273 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct device *dev = ctx->dev;
@@ -141,9 +143,9 @@ static int jh057n_init_sequence(struct jh057n *ctx)
return 0;
}

-static int jh057n_enable(struct drm_panel *panel)
+static int st7703_enable(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
int ret;

ret = jh057n_init_sequence(ctx);
@@ -156,17 +158,17 @@ static int jh057n_enable(struct drm_panel *panel)
return 0;
}

-static int jh057n_disable(struct drm_panel *panel)
+static int st7703_disable(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);

return mipi_dsi_dcs_set_display_off(dsi);
}

-static int jh057n_unprepare(struct drm_panel *panel)
+static int st7703_unprepare(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);

if (!ctx->prepared)
return 0;
@@ -178,9 +180,9 @@ static int jh057n_unprepare(struct drm_panel *panel)
return 0;
}

-static int jh057n_prepare(struct drm_panel *panel)
+static int st7703_prepare(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
int ret;

if (ctx->prepared)
@@ -230,10 +232,10 @@ static const struct drm_display_mode default_mode = {
.height_mm = 130,
};

-static int jh057n_get_modes(struct drm_panel *panel,
+static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
struct drm_display_mode *mode;

mode = drm_mode_duplicate(connector->dev, &default_mode);
@@ -254,17 +256,17 @@ static int jh057n_get_modes(struct drm_panel *panel,
return 1;
}

-static const struct drm_panel_funcs jh057n_drm_funcs = {
- .disable = jh057n_disable,
- .unprepare = jh057n_unprepare,
- .prepare = jh057n_prepare,
- .enable = jh057n_enable,
- .get_modes = jh057n_get_modes,
+static const struct drm_panel_funcs st7703_drm_funcs = {
+ .disable = st7703_disable,
+ .unprepare = st7703_unprepare,
+ .prepare = st7703_prepare,
+ .enable = st7703_enable,
+ .get_modes = st7703_get_modes,
};

static int allpixelson_set(void *data, u64 val)
{
- struct jh057n *ctx = data;
+ struct st7703 *ctx = data;
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:36 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Calling sleep out and display on is a controller specific part
of the initialization process. Move it out of the panel specific
initialization function to the enable callback.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 33 ++++++++++---------
1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index d03aab10cfef..cdbf7dfb4dd4 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -84,8 +84,6 @@ static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
static int jh057n_init_sequence(struct st7703 *ctx)
{
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
- struct device *dev = ctx->dev;
- int ret;

/*
* Init sequence was supplied by the panel vendor. Most of the commands
@@ -136,20 +134,7 @@ static int jh057n_init_sequence(struct st7703 *ctx)
0x18, 0x00, 0x09, 0x0E, 0x29, 0x2D, 0x3C, 0x41,
0x37, 0x07, 0x0B, 0x0D, 0x10, 0x11, 0x0F, 0x10,
0x11, 0x18);
- msleep(20);
-
- ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
- if (ret < 0) {
- DRM_DEV_ERROR(dev, "Failed to exit sleep mode: %d\n", ret);
- return ret;
- }
- /* Panel is operational 120 msec after reset */
- msleep(60);
- ret = mipi_dsi_dcs_set_display_on(dsi);
- if (ret)
- return ret;

- DRM_DEV_DEBUG_DRIVER(dev, "Panel init sequence done\n");
return 0;
}

@@ -181,6 +166,7 @@ struct st7703_panel_desc jh057n00900_panel_desc = {
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
int ret;

ret = ctx->desc->init_sequence(ctx);
@@ -190,6 +176,23 @@ static int st7703_enable(struct drm_panel *panel)
return ret;
}

+ msleep(20);
+
+ ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+ if (ret < 0) {

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:36 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
The datasheet suggests to issue sleep in after display off
as a part of the panel's shutdown sequence.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 5cd5503f894f..0c4167994d01 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -395,8 +395,19 @@ static int st7703_disable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int ret;
+
+ ret = mipi_dsi_dcs_set_display_off(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to turn off the display: %d\n", ret);

- return mipi_dsi_dcs_set_display_off(dsi);
+ ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to enter sleep mode: %d\n", ret);
+
+ return 0;
}

static int st7703_unprepare(struct drm_panel *panel)
--
2.27.0

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:36 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI LCD panel used in
PinePhone. Add support for it.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 200 +++++++++++++++++-
1 file changed, 198 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index cdbf7dfb4dd4..5cd5503f894f 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -39,10 +39,11 @@
#define ST7703_CMD_SETEXTC 0xB9
#define ST7703_CMD_SETMIPI 0xBA
#define ST7703_CMD_SETVDC 0xBC
-#define ST7703_CMD_UNKNOWN0 0xBF
+#define ST7703_CMD_UNKNOWN_BF 0xBF
#define ST7703_CMD_SETSCR 0xC0
#define ST7703_CMD_SETPOWER 0xC1
#define ST7703_CMD_SETPANEL 0xCC
+#define ST7703_CMD_UNKNOWN_C6 0xC6
#define ST7703_CMD_SETGAMMA 0xE0
#define ST7703_CMD_SETEQ 0xE3
#define ST7703_CMD_SETGIP1 0xE9
@@ -109,7 +110,7 @@ static int jh057n_init_sequence(struct st7703 *ctx)
msleep(20);

dsi_generic_write_seq(dsi, ST7703_CMD_SETVCOM, 0x3F, 0x3F);
- dsi_generic_write_seq(dsi, ST7703_CMD_UNKNOWN0, 0x02, 0x11, 0x00);
+ dsi_generic_write_seq(dsi, ST7703_CMD_UNKNOWN_BF, 0x02, 0x11, 0x00);
dsi_generic_write_seq(dsi, ST7703_CMD_SETGIP1,
0x82, 0x10, 0x06, 0x05, 0x9E, 0x0A, 0xA5, 0x12,
0x31, 0x23, 0x37, 0x83, 0x04, 0xBC, 0x27, 0x38,
@@ -163,6 +164,200 @@ struct st7703_panel_desc jh057n00900_panel_desc = {
.init_sequence = jh057n_init_sequence,
};

+#define dsi_dcs_write_seq(dsi, cmd, seq...) do { \
+ static const u8 d[] = { seq }; \
+ int ret; \
+ ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d)); \
+ if (ret < 0) \
+ return ret; \
+ } while (0)
+
+
+static int xbd599_init_sequence(struct st7703 *ctx)
+{
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+
+ msleep(20);
+static const struct drm_display_mode xbd599_mode = {
+ .hdisplay = 720,
+ .hsync_start = 720 + 40,
+ .hsync_end = 720 + 40 + 40,
+ .htotal = 720 + 40 + 40 + 40,
+ .vdisplay = 1440,
+ .vsync_start = 1440 + 18,
+ .vsync_end = 1440 + 18 + 10,
+ .vtotal = 1440 + 18 + 10 + 17,
+ .vrefresh = 60,
+ .clock = 69000,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .width_mm = 68,
+ .height_mm = 136,
+};
+
+static const struct st7703_panel_desc xbd599_desc = {
+ .mode = &xbd599_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = xbd599_init_sequence,
+};
+
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
@@ -428,6 +623,7 @@ static int st7703_remove(struct mipi_dsi_device *dsi)

static const struct of_device_id st7703_of_match[] = {
{ .compatible = "rocktech,jh057n00900", .data = &jh057n00900_panel_desc },
+ { .compatible = "xingbangda,xbd599", .data = &xbd599_desc },

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:37 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah, Ondrej Jirman
From: Icenowy Zheng <ice...@aosc.io>

PinePhone uses PWM backlight and a XBD599 LCD panel over DSI for
display.

Backlight levels curve was optimized by Martijn Braam using a
lux meter.

Add its device nodes.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Martijn Braam <mar...@brixit.nl>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
Acked-by: Linus Walleij <linus....@linaro.org>
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index cefda145c3c9..85a7aa5efd32 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -16,6 +16,13 @@ aliases {
serial0 = &uart0;
};

+ backlight: backlight {
+ compatible = "pwm-backlight";
+ pwms = <&r_pwm 0 50000 PWM_POLARITY_INVERTED>;
+ enable-gpios = <&pio 7 10 GPIO_ACTIVE_HIGH>; /* PH10 */
+ /* Backlight configuration differs per PinePhone revision. */
+ };
+
chosen {
stdout-path = "serial0:115200n8";
};
@@ -84,6 +91,30 @@ &dai {
status = "okay";
};

+&de {
+ status = "okay";
+};
+
+&dphy {
+ status = "okay";
+};
+
+&dsi {
+ vcc-dsi-supply = <&reg_dldo1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ panel@0 {
+ compatible = "xingbangda,xbd599";
+ reg = <0>;
+ reset-gpios = <&pio 3 23 GPIO_ACTIVE_LOW>; /* PD23 */
+ iovcc-supply = <&reg_dldo2>;
+ vcc-supply = <&reg_ldo_io0>;
+ backlight = <&backlight>;
+ };
+};
+
&ehci0 {
status = "okay";
};
@@ -188,6 +219,10 @@ &r_pio {
*/
};

+&r_pwm {
+ status = "okay";
+};
+
&r_rsb {

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:37 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
The reset pin is inverted, so if we don't assert reset, the actual gpio
will be high and may keep driving the IO port of the panel.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 0c4167994d01..e303b7b1a215 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -417,6 +417,7 @@ static int st7703_unprepare(struct drm_panel *panel)
if (!ctx->prepared)
return 0;

Ondrej Jirman

unread,
Jul 1, 2020, 6:31:38 AM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Pinephone has a Goodix GT917S capacitive touchscreen controller on
I2C0 bus. Add support for it.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Acked-by: Linus Walleij <linus....@linaro.org>
---
.../dts/allwinner/sun50i-a64-pinephone.dtsi | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index 85a7aa5efd32..2d5694446d17 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -123,6 +123,25 @@ &ehci1 {
status = "okay";
};

+&i2c0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c0_pins>;
+ status = "okay";
+
+ touchscreen@5d {
+ compatible = "goodix,gt917s", "goodix,gt911";
+ reg = <0x5d>;
+ interrupt-parent = <&pio>;
+ interrupts = <7 4 IRQ_TYPE_LEVEL_HIGH>; /* PH4 */
+ irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
+ reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
+ AVDD28-supply = <&reg_ldo_io0>;
+ VDDIO-supply = <&reg_ldo_io0>;
+ touchscreen-size-x = <720>;
+ touchscreen-size-y = <1440>;
+ };
+};
+
&i2c1 {

Ondřej Jirman

unread,
Jul 1, 2020, 6:34:55 AM7/1/20
to Linus Walleij, linux-sunxi, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Hello Linus,
Thank you very much for the review. :)

I've sent v6 which should fix the currently remaining issues with dt bindings
+ one timing issue I've found in this patch. I've kept your reviewed-by tag,
because it's a fairly trivial issue. But feel free to complain.

thank you again and regards,
o.

> Yours,
> Linus Walleij

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:34 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This patchset adds support for the LCD panel of PinePhone.

I've tested this on PinePhone 1.0 and 1.2.

Please take a look.

thank you and regards,
Ondrej Jirman

Changes in v7:
- Removed mode.vrefresh, rebased onto next-20200701
- v6->v7 diff: https://megous.com/dl/tmp/v6-v7.patch
.../drm/panel/panel-rocktech-jh057n00900.c | 423 -----------
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 654 ++++++++++++++++++
9 files changed, 813 insertions(+), 460 deletions(-)

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:35 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This is done so that code that's not specific to a particular
jh057n panel is named after the controller. Functions specific
to the panel are kept named after the panel.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 90 ++++++++++---------
1 file changed, 46 insertions(+), 44 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index da4e373291f9..14761fec3789 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
struct device *dev = ctx->dev;
@@ -141,9 +143,9 @@ static int jh057n_init_sequence(struct jh057n *ctx)
return 0;
}

-static int jh057n_enable(struct drm_panel *panel)
+static int st7703_enable(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
int ret;

ret = jh057n_init_sequence(ctx);
@@ -156,17 +158,17 @@ static int jh057n_enable(struct drm_panel *panel)
return 0;
}

-static int jh057n_disable(struct drm_panel *panel)
+static int st7703_disable(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);

return mipi_dsi_dcs_set_display_off(dsi);
}

-static int jh057n_unprepare(struct drm_panel *panel)
+static int st7703_unprepare(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);

if (!ctx->prepared)
return 0;
@@ -178,9 +180,9 @@ static int jh057n_unprepare(struct drm_panel *panel)
return 0;
}

-static int jh057n_prepare(struct drm_panel *panel)
+static int st7703_prepare(struct drm_panel *panel)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
int ret;

if (ctx->prepared)
@@ -229,10 +231,10 @@ static const struct drm_display_mode default_mode = {
.height_mm = 130,
};

-static int jh057n_get_modes(struct drm_panel *panel,
+static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
- struct jh057n *ctx = panel_to_jh057n(panel);
+ struct st7703 *ctx = panel_to_st7703(panel);
struct drm_display_mode *mode;

mode = drm_mode_duplicate(connector->dev, &default_mode);
@@ -253,17 +255,17 @@ static int jh057n_get_modes(struct drm_panel *panel,
return 1;
}

-static const struct drm_panel_funcs jh057n_drm_funcs = {
- .disable = jh057n_disable,
- .unprepare = jh057n_unprepare,
- .prepare = jh057n_prepare,
- .enable = jh057n_enable,
- .get_modes = jh057n_get_modes,
+static const struct drm_panel_funcs st7703_drm_funcs = {
+ .disable = st7703_disable,
+ .unprepare = st7703_unprepare,
+ .prepare = st7703_prepare,
+ .enable = st7703_enable,
+ .get_modes = st7703_get_modes,
};

static int allpixelson_set(void *data, u64 val)
{
- struct jh057n *ctx = data;
+ struct st7703 *ctx = data;
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);

DRM_DEV_DEBUG_DRIVER(ctx->dev, "Setting all pixels on\n");
@@ -281,7 +283,7 @@ static int allpixelson_set(void *data, u64 val)
DEFINE_SIMPLE_ATTRIBUTE(allpixelson_fops, NULL,
allpixelson_set, "%llu\n");

-static void jh057n_debugfs_init(struct jh057n *ctx)
+static void st7703_debugfs_init(struct st7703 *ctx)
{
ctx->debugfs = debugfs_create_dir(DRV_NAME, NULL);

@@ -289,16 +291,16 @@ static void jh057n_debugfs_init(struct jh057n *ctx)
&allpixelson_fops);
}

-static void jh057n_debugfs_remove(struct jh057n *ctx)
+static void st7703_debugfs_remove(struct st7703 *ctx)
{
debugfs_remove_recursive(ctx->debugfs);
ctx->debugfs = NULL;
}

-static int jh057n_probe(struct mipi_dsi_device *dsi)
+static int st7703_probe(struct mipi_dsi_device *dsi)
{
struct device *dev = &dsi->dev;
- struct jh057n *ctx;
+ struct st7703 *ctx;
int ret;

ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
@@ -339,7 +341,7 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
return ret;
}

- drm_panel_init(&ctx->panel, dev, &jh057n_drm_funcs,
+ drm_panel_init(&ctx->panel, dev, &st7703_drm_funcs,
DRM_MODE_CONNECTOR_DSI);

ret = drm_panel_of_backlight(&ctx->panel);
@@ -362,13 +364,13 @@ static int jh057n_probe(struct mipi_dsi_device *dsi)
drm_mode_vrefresh(&default_mode),
mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);

- jh057n_debugfs_init(ctx);
+ st7703_debugfs_init(ctx);
return 0;
}

-static void jh057n_shutdown(struct mipi_dsi_device *dsi)
+static void st7703_shutdown(struct mipi_dsi_device *dsi)
{
- struct jh057n *ctx = mipi_dsi_get_drvdata(dsi);
+ struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
int ret;

ret = drm_panel_unprepare(&ctx->panel);
@@ -382,12 +384,12 @@ static void jh057n_shutdown(struct mipi_dsi_device *dsi)
ret);
}

-static int jh057n_remove(struct mipi_dsi_device *dsi)
+static int st7703_remove(struct mipi_dsi_device *dsi)
{
- struct jh057n *ctx = mipi_dsi_get_drvdata(dsi);
+ struct st7703 *ctx = mipi_dsi_get_drvdata(dsi);
int ret;

- jh057n_shutdown(dsi);
+ st7703_shutdown(dsi);

ret = mipi_dsi_detach(dsi);
if (ret < 0)
@@ -396,28 +398,28 @@ static int jh057n_remove(struct mipi_dsi_device *dsi)

drm_panel_remove(&ctx->panel);

- jh057n_debugfs_remove(ctx);
+ st7703_debugfs_remove(ctx);

return 0;
}

-static const struct of_device_id jh057n_of_match[] = {
+static const struct of_device_id st7703_of_match[] = {
{ .compatible = "rocktech,jh057n00900" },

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:35 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
This rename is done so that the driver matches the name of the
display controller and in preparation for adding support for more
panels to the driver.

This is just a basic file rename, with no code changes.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/Kconfig | 26 +++++++++----------
drivers/gpu/drm/panel/Makefile | 2 +-
...-jh057n00900.c => panel-sitronix-st7703.c} | 0
3 files changed, 14 insertions(+), 14 deletions(-)
rename drivers/gpu/drm/panel/{panel-rocktech-jh057n00900.c => panel-sitronix-st7703.c} (100%)

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 39055c1f0e2f..de2f2a452be5 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -283,19 +283,6 @@ config DRM_PANEL_RAYDIUM_RM68200
Say Y here if you want to enable support for Raydium RM68200
720x1280 DSI video mode panel.

-config DRM_PANEL_ROCKTECH_JH057N00900
- tristate "Rocktech JH057N00900 MIPI touchscreen panel"
- depends on OF
- depends on DRM_MIPI_DSI
- depends on BACKLIGHT_CLASS_DEVICE
- help
- Say Y here if you want to enable support for Rocktech JH057N00900
- MIPI DSI panel as e.g. used in the Librem 5 devkit. It has a
- resolution of 720x1440 pixels, a built in backlight and touch
- controller.
- Touch input support is provided by the goodix driver and needs to be
- selected separately.
-
config DRM_PANEL_RONBO_RB070D30
tristate "Ronbo Electronics RB070D30 panel"
depends on OF
@@ -395,6 +382,19 @@ config DRM_PANEL_SITRONIX_ST7701
ST7701 controller for 480X864 LCD panels with MIPI/RGB/SPI
system interfaces.

+config DRM_PANEL_SITRONIX_ST7703
+ tristate "Sitronix ST7703 based MIPI touchscreen panels"
+ depends on OF
+ depends on DRM_MIPI_DSI
+ depends on BACKLIGHT_CLASS_DEVICE
+ help
+ Say Y here if you want to enable support for Sitronix ST7703 based
+ panels, souch as Rocktech JH057N00900 MIPI DSI panel as e.g. used in
+ the Librem 5 devkit. It has a resolution of 720x1440 pixels, a built
+ in backlight and touch controller.
+ Touch input support is provided by the goodix driver and needs to be
+ selected separately.
+
config DRM_PANEL_SITRONIX_ST7789V
tristate "Sitronix ST7789V panel"
depends on OF && SPI
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index de74f282c433..e45ceac6286f 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -27,7 +27,6 @@ obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += panel-panasonic-vvx10f034n00.o
obj-$(CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN) += panel-raspberrypi-touchscreen.o
obj-$(CONFIG_DRM_PANEL_RAYDIUM_RM67191) += panel-raydium-rm67191.o
obj-$(CONFIG_DRM_PANEL_RAYDIUM_RM68200) += panel-raydium-rm68200.o
-obj-$(CONFIG_DRM_PANEL_ROCKTECH_JH057N00900) += panel-rocktech-jh057n00900.o
obj-$(CONFIG_DRM_PANEL_RONBO_RB070D30) += panel-ronbo-rb070d30.o
obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
obj-$(CONFIG_DRM_PANEL_SAMSUNG_S6D16D0) += panel-samsung-s6d16d0.o
@@ -41,6 +40,7 @@ obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o
obj-$(CONFIG_DRM_PANEL_SHARP_LS043T1LE01) += panel-sharp-ls043t1le01.o
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_ACX424AKP) += panel-sony-acx424akp.o
obj-$(CONFIG_DRM_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
diff --git a/drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
similarity index 100%
rename from drivers/gpu/drm/panel/panel-rocktech-jh057n00900.c
rename to drivers/gpu/drm/panel/panel-sitronix-st7703.c
--
2.27.0

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:35 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI LCD panel. It is based on
Sitronix ST7703 LCD controller just like rocktech,jh057n00900. It is
used in PinePhone.

Add a compatible for it.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../bindings/display/panel/rocktech,jh057n00900.yaml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml b/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
index 928ba42e7f8d..a6985cd947fb 100644
--- a/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
+++ b/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
@@ -18,7 +18,11 @@ allOf:

properties:
compatible:
- const: rocktech,jh057n00900
+ enum:
+ # Rocktech JH057N00900 5.5" 720x1440 TFT LCD panel
+ - rocktech,jh057n00900
+ # Xingbangda XBD599 5.99" 720x1440 TFT LCD panel
+ - xingbangda,xbd599

reg:
maxItems: 1
--
2.27.0

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:35 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Convert Rocktech MIPI DSI panel driver from txt to yaml bindings.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
---
.../display/panel/rocktech,jh057n00900.txt | 23 -------
.../display/panel/rocktech,jh057n00900.yaml | 66 +++++++++++++++++++
2 files changed, 66 insertions(+), 23 deletions(-)
delete mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt
create mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml

diff --git a/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt b/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt
deleted file mode 100644
index a372c5d84695..000000000000
--- a/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-Rocktech jh057n00900 5.5" 720x1440 TFT LCD panel
-
-Required properties:
-- compatible: should be "rocktech,jh057n00900"
-- reg: DSI virtual channel of the peripheral
-- reset-gpios: panel reset gpio
-- backlight: phandle of the backlight device attached to the panel
-- vcc-supply: phandle of the regulator that provides the vcc supply voltage.
-- iovcc-supply: phandle of the regulator that provides the iovcc supply
- voltage.
-
-Example:
-
- &mipi_dsi {
- panel@0 {
- compatible = "rocktech,jh057n00900";
- reg = <0>;
- backlight = <&backlight>;
- reset-gpios = <&gpio3 13 GPIO_ACTIVE_LOW>;
- vcc-supply = <&reg_2v8_p>;
- iovcc-supply = <&reg_1v8_p>;
- };
- };
diff --git a/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml b/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
new file mode 100644
index 000000000000..928ba42e7f8d
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/panel/rocktech,jh057n00900.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Rocktech JH057N00900 5.5" 720x1440 TFT LCD panel
+
+maintainers:
+ - Ondrej Jirman <me...@xff.cz>
+
+description: |
+ Rocktech JH057N00900 is a 720x1440 TFT LCD panel
+ connected using a MIPI-DSI video interface.
+
+allOf:
+ - $ref: panel-common.yaml#
+
+properties:
+ compatible:
+ const: rocktech,jh057n00900
+
+ reg:
+ maxItems: 1
+ description: DSI virtual channel
+
+ vcc-supply:
+ description: Panel power supply
+
+ iovcc-supply:
+ description: I/O voltage supply
+
+ reset-gpios:
+ description: GPIO used for the reset pin
+ maxItems: 1
+
+ backlight:
+ description: Backlight used by the panel
+ $ref: "/schemas/types.yaml#/definitions/phandle"
+
+required:
+ - compatible
+ - reg
+ - vcc-supply
+ - iovcc-supply
+ - reset-gpios
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/gpio/gpio.h>
+
+ dsi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ panel@0 {
+ compatible = "rocktech,jh057n00900";
+ reg = <0>;
+ vcc-supply = <&reg_2v8_p>;
+ iovcc-supply = <&reg_1v8_p>;
+ reset-gpios = <&gpio3 13 GPIO_ACTIVE_LOW>;
+ backlight = <&backlight>;
+ };
+ };
+...
--
2.27.0

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:36 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Parametrize the driver so that it can support more panels based
on st7703 controller.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 43 +++++++++++++------
1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 14761fec3789..4721132ad3b1 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -13,6 +13,7 @@
#include <linux/media-bus-format.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
+#include <linux/of_device.h>
#include <linux/regulator/consumer.h>

#include <video/display_timing.h>
@@ -56,6 +57,15 @@ struct st7703 {
bool prepared;

struct dentry *debugfs;
+ const struct st7703_panel_desc *desc;
+};
+
+struct st7703_panel_desc {
+ const struct drm_display_mode *mode;
+ unsigned int lanes;
+ unsigned long mode_flags;
+ enum mipi_dsi_pixel_format format;
+ int (*init_sequence)(struct st7703 *ctx);
};

static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
@@ -148,7 +158,7 @@ static int st7703_enable(struct drm_panel *panel)
struct st7703 *ctx = panel_to_st7703(panel);
int ret;

- ret = jh057n_init_sequence(ctx);
+ ret = ctx->desc->init_sequence(ctx);
if (ret < 0) {
DRM_DEV_ERROR(ctx->dev, "Panel init sequence failed: %d\n",
ret);
@@ -216,7 +226,7 @@ static int st7703_prepare(struct drm_panel *panel)
return ret;
}

-static const struct drm_display_mode default_mode = {
+static const struct drm_display_mode jh057n00900_mode = {
.hdisplay = 720,
.hsync_start = 720 + 90,
.hsync_end = 720 + 90 + 20,
@@ -231,17 +241,26 @@ static const struct drm_display_mode default_mode = {
.height_mm = 130,
};

+struct st7703_panel_desc jh057n00900_panel_desc = {
+ .mode = &jh057n00900_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO |
+ MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = jh057n_init_sequence,
+};
+
static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct st7703 *ctx = panel_to_st7703(panel);
struct drm_display_mode *mode;

- mode = drm_mode_duplicate(connector->dev, &default_mode);
+ mode = drm_mode_duplicate(connector->dev, ctx->desc->mode);
if (!mode) {
DRM_DEV_ERROR(ctx->dev, "Failed to add mode %ux%u@%u\n",
- default_mode.hdisplay, default_mode.vdisplay,
- drm_mode_vrefresh(&default_mode));
+ ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
+ drm_mode_vrefresh(ctx->desc->mode));
return -ENOMEM;
}

@@ -316,11 +335,11 @@ static int st7703_probe(struct mipi_dsi_device *dsi)
mipi_dsi_set_drvdata(dsi, ctx);

ctx->dev = dev;
+ ctx->desc = of_device_get_match_data(dev);

- dsi->lanes = 4;
- dsi->format = MIPI_DSI_FMT_RGB888;
- dsi->mode_flags = MIPI_DSI_MODE_VIDEO |
- MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
+ dsi->mode_flags = ctx->desc->mode_flags;
+ dsi->format = ctx->desc->format;
+ dsi->lanes = ctx->desc->lanes;

ctx->vcc = devm_regulator_get(dev, "vcc");
if (IS_ERR(ctx->vcc)) {
@@ -360,8 +379,8 @@ static int st7703_probe(struct mipi_dsi_device *dsi)
}

DRM_DEV_INFO(dev, "%ux%u@%u %ubpp dsi %udl - ready\n",
- default_mode.hdisplay, default_mode.vdisplay,
- drm_mode_vrefresh(&default_mode),
+ ctx->desc->mode->hdisplay, ctx->desc->mode->vdisplay,
+ drm_mode_vrefresh(ctx->desc->mode),
mipi_dsi_pixel_format_to_bpp(dsi->format), dsi->lanes);

st7703_debugfs_init(ctx);
@@ -404,7 +423,7 @@ static int st7703_remove(struct mipi_dsi_device *dsi)
}

static const struct of_device_id st7703_of_match[] = {
- { .compatible = "rocktech,jh057n00900" },
+ { .compatible = "rocktech,jh057n00900", .data = &jh057n00900_panel_desc },

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:36 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
It's better than having it spread around the driver.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 48 +++++++++----------
1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 4721132ad3b1..61872f623fff 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -153,6 +153,30 @@ static int jh057n_init_sequence(struct st7703 *ctx)
return 0;
}

+static const struct drm_display_mode jh057n00900_mode = {
+ .hdisplay = 720,
+ .hsync_start = 720 + 90,
+ .hsync_end = 720 + 90 + 20,
+ .htotal = 720 + 90 + 20 + 20,
+ .vdisplay = 1440,
+ .vsync_start = 1440 + 20,
+ .vsync_end = 1440 + 20 + 4,
+ .vtotal = 1440 + 20 + 4 + 12,
+ .clock = 75276,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .width_mm = 65,
+ .height_mm = 130,
+};
+
+struct st7703_panel_desc jh057n00900_panel_desc = {
+ .mode = &jh057n00900_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO |
+ MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = jh057n_init_sequence,
+};
+
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
@@ -226,30 +250,6 @@ static int st7703_prepare(struct drm_panel *panel)
return ret;
}

-static const struct drm_display_mode jh057n00900_mode = {
- .hdisplay = 720,
- .hsync_start = 720 + 90,
- .hsync_end = 720 + 90 + 20,
- .htotal = 720 + 90 + 20 + 20,
- .vdisplay = 1440,
- .vsync_start = 1440 + 20,
- .vsync_end = 1440 + 20 + 4,
- .vtotal = 1440 + 20 + 4 + 12,
- .clock = 75276,
- .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
- .width_mm = 65,
- .height_mm = 130,
-};
-
-struct st7703_panel_desc jh057n00900_panel_desc = {
- .mode = &jh057n00900_mode,
- .lanes = 4,
- .mode_flags = MIPI_DSI_MODE_VIDEO |
- MIPI_DSI_MODE_VIDEO_BURST | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
- .format = MIPI_DSI_FMT_RGB888,
- .init_sequence = jh057n_init_sequence,
-};
-
static int st7703_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
--
2.27.0

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:37 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Calling sleep out and display on is a controller specific part
of the initialization process. Move it out of the panel specific
initialization function to the enable callback.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 33 ++++++++++---------
1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 61872f623fff..96e39ec94900 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -84,8 +84,6 @@ static inline struct st7703 *panel_to_st7703(struct drm_panel *panel)
static int jh057n_init_sequence(struct st7703 *ctx)
{
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
- struct device *dev = ctx->dev;
- int ret;

/*
* Init sequence was supplied by the panel vendor. Most of the commands
@@ -136,20 +134,7 @@ static int jh057n_init_sequence(struct st7703 *ctx)
0x18, 0x00, 0x09, 0x0E, 0x29, 0x2D, 0x3C, 0x41,
0x37, 0x07, 0x0B, 0x0D, 0x10, 0x11, 0x0F, 0x10,
0x11, 0x18);
- msleep(20);
-
- ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
- if (ret < 0) {
- DRM_DEV_ERROR(dev, "Failed to exit sleep mode: %d\n", ret);
- return ret;
- }
- /* Panel is operational 120 msec after reset */
- msleep(60);
- ret = mipi_dsi_dcs_set_display_on(dsi);
- if (ret)
- return ret;

- DRM_DEV_DEBUG_DRIVER(dev, "Panel init sequence done\n");
return 0;
}

@@ -180,6 +165,7 @@ struct st7703_panel_desc jh057n00900_panel_desc = {
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
int ret;

ret = ctx->desc->init_sequence(ctx);
@@ -189,6 +175,23 @@ static int st7703_enable(struct drm_panel *panel)
return ret;
}

+ msleep(20);
+
+ ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
+ if (ret < 0) {

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:38 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
The reset pin is inverted, so if we don't assert reset, the actual gpio
will be high and may keep driving the IO port of the panel.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 7750179bca60..8996ced2b721 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -415,6 +415,7 @@ static int st7703_unprepare(struct drm_panel *panel)
if (!ctx->prepared)
return 0;

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:38 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah, Ondrej Jirman
From: Icenowy Zheng <ice...@aosc.io>

PinePhone uses PWM backlight and a XBD599 LCD panel over DSI for
display.

Backlight levels curve was optimized by Martijn Braam using a
lux meter.

Add its device nodes.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Martijn Braam <mar...@brixit.nl>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
Acked-by: Linus Walleij <linus....@linaro.org>
---
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index cefda145c3c9..85a7aa5efd32 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -16,6 +16,13 @@ aliases {
serial0 = &uart0;
};

+ backlight: backlight {
+ compatible = "pwm-backlight";
+ pwms = <&r_pwm 0 50000 PWM_POLARITY_INVERTED>;
+ enable-gpios = <&pio 7 10 GPIO_ACTIVE_HIGH>; /* PH10 */
+ /* Backlight configuration differs per PinePhone revision. */
+ };
+
chosen {
stdout-path = "serial0:115200n8";
};
@@ -84,6 +91,30 @@ &dai {
status = "okay";
};

+&de {
+ status = "okay";
+};
+
+&dphy {
+ status = "okay";
+};
+
+&dsi {
+ vcc-dsi-supply = <&reg_dldo1>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "okay";
+
+ panel@0 {
+ compatible = "xingbangda,xbd599";
+ reg = <0>;
+ reset-gpios = <&pio 3 23 GPIO_ACTIVE_LOW>; /* PD23 */
+ iovcc-supply = <&reg_dldo2>;
+ vcc-supply = <&reg_ldo_io0>;
+ backlight = <&backlight>;
+ };
+};
+
&ehci0 {
status = "okay";
};
@@ -188,6 +219,10 @@ &r_pio {
*/
};

+&r_pwm {
+ status = "okay";
+};
+
&r_rsb {

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:38 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
The datasheet suggests to issue sleep in after display off
as a part of the panel's shutdown sequence.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index dadb482b244d..7750179bca60 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -393,8 +393,19 @@ static int st7703_disable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+ int ret;
+
+ ret = mipi_dsi_dcs_set_display_off(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to turn off the display: %d\n", ret);

- return mipi_dsi_dcs_set_display_off(dsi);
+ ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
+ if (ret < 0)
+ DRM_DEV_ERROR(ctx->dev,
+ "Failed to enter sleep mode: %d\n", ret);
+
+ return 0;
}

static int st7703_unprepare(struct drm_panel *panel)
--
2.27.0

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:38 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Xingbangda XBD599 is a 5.99" 720x1440 MIPI-DSI LCD panel used in
PinePhone. Add support for it.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
Signed-off-by: Ondrej Jirman <meg...@megous.com>
Reviewed-by: Linus Walleij <linus....@linaro.org>
---
drivers/gpu/drm/panel/panel-sitronix-st7703.c | 199 +++++++++++++++++-
1 file changed, 197 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sitronix-st7703.c b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
index 96e39ec94900..dadb482b244d 100644
--- a/drivers/gpu/drm/panel/panel-sitronix-st7703.c
+++ b/drivers/gpu/drm/panel/panel-sitronix-st7703.c
@@ -39,10 +39,11 @@
#define ST7703_CMD_SETEXTC 0xB9
#define ST7703_CMD_SETMIPI 0xBA
#define ST7703_CMD_SETVDC 0xBC
-#define ST7703_CMD_UNKNOWN0 0xBF
+#define ST7703_CMD_UNKNOWN_BF 0xBF
#define ST7703_CMD_SETSCR 0xC0
#define ST7703_CMD_SETPOWER 0xC1
#define ST7703_CMD_SETPANEL 0xCC
+#define ST7703_CMD_UNKNOWN_C6 0xC6
#define ST7703_CMD_SETGAMMA 0xE0
#define ST7703_CMD_SETEQ 0xE3
#define ST7703_CMD_SETGIP1 0xE9
@@ -109,7 +110,7 @@ static int jh057n_init_sequence(struct st7703 *ctx)
msleep(20);

dsi_generic_write_seq(dsi, ST7703_CMD_SETVCOM, 0x3F, 0x3F);
- dsi_generic_write_seq(dsi, ST7703_CMD_UNKNOWN0, 0x02, 0x11, 0x00);
+ dsi_generic_write_seq(dsi, ST7703_CMD_UNKNOWN_BF, 0x02, 0x11, 0x00);
dsi_generic_write_seq(dsi, ST7703_CMD_SETGIP1,
0x82, 0x10, 0x06, 0x05, 0x9E, 0x0A, 0xA5, 0x12,
0x31, 0x23, 0x37, 0x83, 0x04, 0xBC, 0x27, 0x38,
@@ -162,6 +163,199 @@ struct st7703_panel_desc jh057n00900_panel_desc = {
.init_sequence = jh057n_init_sequence,
};

+#define dsi_dcs_write_seq(dsi, cmd, seq...) do { \
+ static const u8 d[] = { seq }; \
+ int ret; \
+ ret = mipi_dsi_dcs_write(dsi, cmd, d, ARRAY_SIZE(d)); \
+ if (ret < 0) \
+ return ret; \
+ } while (0)
+
+
+static int xbd599_init_sequence(struct st7703 *ctx)
+{
+ struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+
+static const struct drm_display_mode xbd599_mode = {
+ .hdisplay = 720,
+ .hsync_start = 720 + 40,
+ .hsync_end = 720 + 40 + 40,
+ .htotal = 720 + 40 + 40 + 40,
+ .vdisplay = 1440,
+ .vsync_start = 1440 + 18,
+ .vsync_end = 1440 + 18 + 10,
+ .vtotal = 1440 + 18 + 10 + 17,
+ .clock = 69000,
+ .flags = DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC,
+ .width_mm = 68,
+ .height_mm = 136,
+};
+
+static const struct st7703_panel_desc xbd599_desc = {
+ .mode = &xbd599_mode,
+ .lanes = 4,
+ .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE,
+ .format = MIPI_DSI_FMT_RGB888,
+ .init_sequence = xbd599_init_sequence,
+};
+
static int st7703_enable(struct drm_panel *panel)
{
struct st7703 *ctx = panel_to_st7703(panel);
@@ -427,6 +621,7 @@ static int st7703_remove(struct mipi_dsi_device *dsi)

static const struct of_device_id st7703_of_match[] = {
{ .compatible = "rocktech,jh057n00900", .data = &jh057n00900_panel_desc },
+ { .compatible = "xingbangda,xbd599", .data = &xbd599_desc },

Ondrej Jirman

unread,
Jul 1, 2020, 12:29:40 PM7/1/20
to linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, Ondrej Jirman, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Pinephone has a Goodix GT917S capacitive touchscreen controller on
I2C0 bus. Add support for it.

Signed-off-by: Ondrej Jirman <meg...@megous.com>
Acked-by: Linus Walleij <linus....@linaro.org>
---
.../dts/allwinner/sun50i-a64-pinephone.dtsi | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index 85a7aa5efd32..2d5694446d17 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -123,6 +123,25 @@ &ehci1 {
status = "okay";
};

+&i2c0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&i2c0_pins>;
+ status = "okay";
+
+ touchscreen@5d {
+ compatible = "goodix,gt917s", "goodix,gt911";
+ reg = <0x5d>;
+ interrupt-parent = <&pio>;
+ interrupts = <7 4 IRQ_TYPE_LEVEL_HIGH>; /* PH4 */
+ irq-gpios = <&pio 7 4 GPIO_ACTIVE_HIGH>; /* PH4 */
+ reset-gpios = <&pio 7 11 GPIO_ACTIVE_HIGH>; /* PH11 */
+ AVDD28-supply = <&reg_ldo_io0>;
+ VDDIO-supply = <&reg_ldo_io0>;
+ touchscreen-size-x = <720>;
+ touchscreen-size-y = <1440>;
+ };
+};
+
&i2c1 {

Ondřej Jirman

unread,
Jul 1, 2020, 12:30:21 PM7/1/20
to Sam Ravnborg, linux...@googlegroups.com, Thierry Reding, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Hello Sam,

On Wed, Jul 01, 2020 at 05:25:32PM +0200, Sam Ravnborg wrote:
> Hi Ondrej.
>
> On Wed, Jul 01, 2020 at 12:31:13PM +0200, Ondrej Jirman wrote:
> > This patchset adds support for the LCD panel of PinePhone.
> >
> > I've tested this on PinePhone 1.0 and 1.2.
> >
> > Please take a look.
> >
> > thank you and regards,
> > Ondrej Jirman
> >
> > Changes in v6:
> > - Fixed spacing in yaml
> > - Fixed wrong vccio->iovcc supply name in the bindings doc
> > - I noticed that the original driver uses a delay of 20ms in the init
> > function to achieve a combined total of 120ms required from post-reset
> > to display_on. I've added a similar delay to xbd599_init, so that
> > xbd599 panel also has the right timing. (patch 9)
> > - v5->v6 diff: https://megous.com/dl/tmp/v5-v6.patch
> > - Added review/ack tags
> > - Learned to run dt_binding_check by myself ;)
> The patch-set does not apply clean on top of drm-misc-next - due to
> vrefresh removal.
> Please re-spin.

Sorry for that. Rebased and retested.

thank you,
o.

> Sam

Linus Walleij

unread,
Jul 1, 2020, 12:38:08 PM7/1/20
to Ondřej Jirman, Sam Ravnborg, linux-sunxi, Thierry Reding, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, open list:DRM PANEL DRIVERS, open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, linux-...@vger.kernel.org, Linux ARM, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Sam will you apply it? I was in the middle of applying and ran into the same
issue :D

Yours,
Linus Walleij

Ondřej Jirman

unread,
Jul 1, 2020, 12:42:19 PM7/1/20
to Guido Günther, linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Hello,

On Wed, Jul 01, 2020 at 05:54:05PM +0200, Guido Günther wrote:
> Hi,
> On Wed, Jul 01, 2020 at 12:31:13PM +0200, Ondrej Jirman wrote:
> > This patchset adds support for the LCD panel of PinePhone.
>
> I gave this a quick spin on the Librem5 devkit so
>
> Tested-by: Guido Günther <a...@sigxcpu.org>
>
> but please also adjust MAINTAINERS so we stay in the loop on driver
> changes.

Ah, right. I'll send a quick followup patch[1] after this gets merged,
or add it to v8 if there will be a need for v8. Thanks for noticing.

[1] https://megous.com/dl/tmp/0001-MAINTAINERS-Update-entry-for-st7703-driver-after-the.patch

And thanks for testing, too. :)

regards,
o.

> Cheers,
> -- Guido
>
> >
> > I've tested this on PinePhone 1.0 and 1.2.
> >
> > Please take a look.
> >
> > thank you and regards,
> > Ondrej Jirman
> >
> > Changes in v6:
> > - Fixed spacing in yaml
> > - Fixed wrong vccio->iovcc supply name in the bindings doc
> > - I noticed that the original driver uses a delay of 20ms in the init
> > function to achieve a combined total of 120ms required from post-reset
> > to display_on. I've added a similar delay to xbd599_init, so that
> > xbd599 panel also has the right timing. (patch 9)
> > - v5->v6 diff: https://megous.com/dl/tmp/v5-v6.patch
> > - Added review/ack tags
> > - Learned to run dt_binding_check by myself ;)
> >
> > .../drm/panel/panel-rocktech-jh057n00900.c | 424 -----------
> > drivers/gpu/drm/panel/panel-sitronix-st7703.c | 656 ++++++++++++++++++
> > 9 files changed, 815 insertions(+), 461 deletions(-)
> > delete mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt
> > create mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml

Icenowy Zheng

unread,
Jul 1, 2020, 1:15:18 PM7/1/20
to Ondrej Jirman, linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah


于 2020年7月1日 GMT+08:00 下午6:31:26, Ondrej Jirman <meg...@megous.com> 写到:
>Pinephone has a Goodix GT917S capacitive touchscreen controller on
>I2C0 bus. Add support for it.
>
>Signed-off-by: Ondrej Jirman <meg...@megous.com>
>Acked-by: Linus Walleij <linus....@linaro.org>
>---
> .../dts/allwinner/sun50i-a64-pinephone.dtsi | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
>diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
>b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
>index 85a7aa5efd32..2d5694446d17 100644
>--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
>+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
>@@ -123,6 +123,25 @@ &ehci1 {
> status = "okay";
> };
>
>+&i2c0 {
>+ pinctrl-names = "default";
>+ pinctrl-0 = <&i2c0_pins>;
>+ status = "okay";
>+
>+ touchscreen@5d {
>+ compatible = "goodix,gt917s", "goodix,gt911";

Please drop gt911 here. GT917S belong to the GT1x product line, not the same line with GT911.

You will see this in the driver.

Ondřej Jirman

unread,
Jul 1, 2020, 2:48:57 PM7/1/20
to Sam Ravnborg, linux...@googlegroups.com, Thierry Reding, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, Icenowy Zheng, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Hello Sam,

On Wed, Jul 01, 2020 at 07:30:18PM +0200, Sam Ravnborg wrote:
> Hi Ondrej.
>
> On Wed, Jul 01, 2020 at 06:29:15PM +0200, Ondrej Jirman wrote:
> > This patchset adds support for the LCD panel of PinePhone.
> >
> > I've tested this on PinePhone 1.0 and 1.2.
>
> Thanks for this nive sereis.
> Applied the first 11 patches to drm-misc-next.
> The DTS files needs to go in via another tree.

Thank you very much, too. :)

regards,
o.

> Sam

Ondřej Jirman

unread,
Jul 1, 2020, 2:57:45 PM7/1/20
to Icenowy Zheng, linux...@googlegroups.com, Thierry Reding, Sam Ravnborg, David Airlie, Daniel Vetter, Guido Günther, Purism Kernel Team, Rob Herring, Maxime Ripard, Chen-Yu Tsai, Linus Walleij, dri-...@lists.freedesktop.org, devic...@vger.kernel.org, linux-...@vger.kernel.org, linux-ar...@lists.infradead.org, Samuel Holland, Martijn Braam, Luca Weiss, Bhushan Shah
Hi Icenowy,
Right. I'll do so in v8.

thnk you and regards,
o.

Rob Herring

unread,
Jul 2, 2020, 4:51:50 PM7/2/20
to Ondrej Jirman, David Airlie, Sam Ravnborg, Daniel Vetter, Guido Günther, linux-...@vger.kernel.org, Purism Kernel Team, Chen-Yu Tsai, Samuel Holland, devic...@vger.kernel.org, Bhushan Shah, Thierry Reding, linux...@googlegroups.com, Luca Weiss, Martijn Braam, Icenowy Zheng, Maxime Ripard, linux-ar...@lists.infradead.org, dri-...@lists.freedesktop.org, Linus Walleij, Rob Herring
On Wed, 01 Jul 2020 18:29:17 +0200, Ondrej Jirman wrote:
> Convert Rocktech MIPI DSI panel driver from txt to yaml bindings.
>
> Signed-off-by: Ondrej Jirman <meg...@megous.com>
> ---
> .../display/panel/rocktech,jh057n00900.txt | 23 -------
> .../display/panel/rocktech,jh057n00900.yaml | 66 +++++++++++++++++++
> 2 files changed, 66 insertions(+), 23 deletions(-)
> delete mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt
> create mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
>


My bot found errors running 'make dt_binding_check' on your patch:

/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: '#address-cells', '#size-cells', 'port@0' do not match any of the regexes: 'pinctrl-[0-9]+'
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'vcc-supply' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'iovcc-supply' is a required property
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'reset-gpios' is a required property


See https://patchwork.ozlabs.org/patch/1320690

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure dt-schema is up to date:

pip3 install git+https://github.com/devicetree-org/dt-schema.git@master --upgrade

Please check and re-submit.

Ondřej Jirman

unread,
Jul 2, 2020, 5:03:57 PM7/2/20
to Rob Herring, David Airlie, Sam Ravnborg, Daniel Vetter, Guido Günther, linux-...@vger.kernel.org, Purism Kernel Team, Chen-Yu Tsai, Samuel Holland, devic...@vger.kernel.org, Bhushan Shah, Thierry Reding, linux...@googlegroups.com, Luca Weiss, Martijn Braam, Icenowy Zheng, Maxime Ripard, linux-ar...@lists.infradead.org, dri-...@lists.freedesktop.org, Linus Walleij, Rob Herring
On Thu, Jul 02, 2020 at 02:51:43PM -0600, Rob Herring wrote:
> On Wed, 01 Jul 2020 18:29:17 +0200, Ondrej Jirman wrote:
> > Convert Rocktech MIPI DSI panel driver from txt to yaml bindings.
> >
> > Signed-off-by: Ondrej Jirman <meg...@megous.com>
> > ---
> > .../display/panel/rocktech,jh057n00900.txt | 23 -------
> > .../display/panel/rocktech,jh057n00900.yaml | 66 +++++++++++++++++++
> > 2 files changed, 66 insertions(+), 23 deletions(-)
> > delete mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.txt
> > create mode 100644 Documentation/devicetree/bindings/display/panel/rocktech,jh057n00900.yaml
> >
>
>
> My bot found errors running 'make dt_binding_check' on your patch:
>
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: '#address-cells', '#size-cells', 'port@0' do not match any of the regexes: 'pinctrl-[0-9]+'
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'vcc-supply' is a required property
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'iovcc-supply' is a required property
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'reset-gpios' is a required property

Paths look bogus ^^^^

It should be .../rocktech,jh057n00900.yaml: ...

regards,
o.

Ondřej Jirman

unread,
Jul 3, 2020, 6:44:51 AM7/3/20
to Sam Ravnborg, Rob Herring, David Airlie, Daniel Vetter, Guido Günther, linux-...@vger.kernel.org, Purism Kernel Team, Chen-Yu Tsai, Samuel Holland, devic...@vger.kernel.org, Bhushan Shah, Thierry Reding, linux...@googlegroups.com, Luca Weiss, Martijn Braam, Icenowy Zheng, Maxime Ripard, linux-ar...@lists.infradead.org, dri-...@lists.freedesktop.org, Linus Walleij, Rob Herring
Hello Sam,

On Fri, Jul 03, 2020 at 07:11:55AM +0200, Sam Ravnborg wrote:
> Hi Ondrej.
>
> > > My bot found errors running 'make dt_binding_check' on your patch:
> > >
> > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: '#address-cells', '#size-cells', 'port@0' do not match any of the regexes: 'pinctrl-[0-9]+'
> > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'vcc-supply' is a required property
> > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'iovcc-supply' is a required property
> > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'reset-gpios' is a required property
> >
> > Paths look bogus ^^^^
> >
> > It should be .../rocktech,jh057n00900.yaml: ...
>
> The example in nwl-dsi.yaml contains:
> compatible = "rocktech,jh057n00900";
>
> So the example is checked against your updated binding.
> And the binding check fails because the example is no longer valid.

Ah, now I understand.

> This needs to be fixed as we do not wat to introduce new errors.
> Either the example or the binding needs the fix.

I think we can unrequire the supplies, but reset is needed really.

The panel only has one port, so there should be no address/size-cells
in the example, and port@0 should be just port to match existing binding.
If it had multiple ports, port@0 would have to be inside ports { } node
anyway, according to the existing binding. Then add reset-gpios to
the example...

And that should fix it.

I'll prepare the patch shortly.

regards,
o.

> Sam

Ondřej Jirman

unread,
Jul 3, 2020, 7:13:27 AM7/3/20
to Sam Ravnborg, Rob Herring, David Airlie, Daniel Vetter, Guido Günther, linux-...@vger.kernel.org, Purism Kernel Team, Chen-Yu Tsai, Samuel Holland, devic...@vger.kernel.org, Bhushan Shah, Thierry Reding, linux...@googlegroups.com, Luca Weiss, Martijn Braam, Icenowy Zheng, Maxime Ripard, linux-ar...@lists.infradead.org, dri-...@lists.freedesktop.org, Linus Walleij, Rob Herring
On Fri, Jul 03, 2020 at 12:44:48PM +0200, megous hlavni wrote:
> Hello Sam,
>
> On Fri, Jul 03, 2020 at 07:11:55AM +0200, Sam Ravnborg wrote:
> > Hi Ondrej.
> >
> > > > My bot found errors running 'make dt_binding_check' on your patch:
> > > >
> > > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: '#address-cells', '#size-cells', 'port@0' do not match any of the regexes: 'pinctrl-[0-9]+'
> > > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'vcc-supply' is a required property
> > > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'iovcc-supply' is a required property
> > > > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/display/bridge/nwl-dsi.example.dt.yaml: panel@0: 'reset-gpios' is a required property
> > >
> > > Paths look bogus ^^^^
> > >
> > > It should be .../rocktech,jh057n00900.yaml: ...
> >
> > The example in nwl-dsi.yaml contains:
> > compatible = "rocktech,jh057n00900";
> >
> > So the example is checked against your updated binding.
> > And the binding check fails because the example is no longer valid.
>
> Ah, now I understand.
>
> > This needs to be fixed as we do not wat to introduce new errors.
> > Either the example or the binding needs the fix.
>
> I think we can unrequire the supplies, but reset is needed really.

Hmm, that's probably wrong kind of thinking. Panel has the supplies, and
obviously requires them, so the dts must describe them somehow, even if
they are the fixed supplies. So I'll not unrequire them.
Reply all
Reply to author
Forward
0 new messages