Skip to content

Instantly share code, notes, and snippets.

@lupyuen
Last active October 1, 2022 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lupyuen/43204d20c35ecb23dfbff12f2f570565 to your computer and use it in GitHub Desktop.
Save lupyuen/43204d20c35ecb23dfbff12f2f570565 to your computer and use it in GitHub Desktop.
Reverse Engineering PinePhone's LCD Display (MIPI DSI): https://lupyuen.github.io/articles/dsi

Reverse Engineering PinePhone's LCD Display (MIPI DSI)

Read the article: lupyuen.github.io/articles/dsi

This all-in-one display handler might be helpful for validating that our driver works correctly:

Initialise MIPI DSI

sun6i_dsi_encoder_enable: sun6i_mipi_dsi.c calls D-PHY:

Initialise ST7703 LCD Controller

xbd599_init_sequence: panel-sitronix-st7703.c

Data Type = MIPI_DSI_DCS_LONG_WRITE: mipi_display.h

	MIPI_DSI_DCS_LONG_WRITE				= 0x39,

DSI Video Mode

Video Mode: panel-sitronix-st7703.c

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,
};

Video Mode: sun6i_mipi_dsi.c

	regmap_write(dsi->regs, SUN6I_DSI_BASIC_CTL1_REG,
		     SUN6I_DSI_BASIC_CTL1_VIDEO_ST_DELAY(delay) |
		     SUN6I_DSI_BASIC_CTL1_VIDEO_FILL |
		     SUN6I_DSI_BASIC_CTL1_VIDEO_PRECISION |
		     SUN6I_DSI_BASIC_CTL1_VIDEO_MODE);

PinePhone MIPI DSI Driver

A64 MIPI DSI Driver: sun6i_mipi_dsi.c

sun6i_dsi_dcs_write_short: sun6i_mipi_dsi.c

  • Calls sun6i_dsi_start(dsi, DSI_START_LPTX);

sun6i_dsi_dcs_write_long: sun6i_mipi_dsi.c

  • Calls sun6i_dsi_start(dsi, DSI_START_LPTX);
  • sun6i_dsi_inst_wait_for_completion

sun6i_dsi_dcs_read: sun6i_mipi_dsi.c

sun6i_dsi_transfer: sun6i_mipi_dsi.c

sun6i_dsi_start: sun6i_mipi_dsi.c

sun6i_dsi_encoder_enable: sun6i_mipi_dsi.c

PinePhone MIPI D-PHY Driver

A64 MIPI D-PHY Driver: phy-sun6i-mipi-dphy.c

sun6i_dphy_tx_power_on: phy-sun6i-mipi-dphy.c

sun6i_dphy_rx_power_on: phy-sun6i-mipi-dphy.c

sun6i_dphy_power_on: phy-sun6i-mipi-dphy.c

PinePhone A64 uses A31 MIPI DSI Driver

sun6i_mipi_dsi.c

MODULE_DESCRIPTION("Allwinner A31 DSI Driver");

sun6i_mipi_dsi.c

static const struct of_device_id sun6i_dsi_of_table[] = {
	{ .compatible = "allwinner,sun6i-a31-mipi-dsi" },
	{ .compatible = "allwinner,sun50i-a64-mipi-dsi" },
	{ }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment