// SPDX-License-Identifier: GPL-2.0+ /* * MIPI-DSI Novatek NT35560-based panel controller. * * Supported panels include: * Sony ACX424AKM - a 480x854 AMOLED DSI panel * Sony ACX424AKP - a 480x864 AMOLED DSI panel * * Copyright (C) Linaro Ltd. 2019-2021 * Author: Linus Walleij * Based on code and know-how from Marcus Lorentzon * Copyright (C) ST-Ericsson SA 2010 * Based on code and know-how from Johan Olson and Joakim Wesslen * Copyright (C) Sony Ericsson Mobile Communications 2010
*/ #include <linux/backlight.h> #include <linux/delay.h> #include <linux/gpio/consumer.h> #include <linux/module.h> #include <linux/of.h> #include <linux/regulator/consumer.h>
/* * Sony seems to use vendor ID 0x81
*/ #define DISPLAY_SONY_ACX424AKP_ID1 0x8103 #define DISPLAY_SONY_ACX424AKP_ID2 0x811a #define DISPLAY_SONY_ACX424AKP_ID3 0x811b /* * The fourth ID looks like a bug, vendor IDs begin at 0x80 * and panel 00 ... seems like default values.
*/ #define DISPLAY_SONY_ACX424AKP_ID4 0x8000
/* Set up PWM dutycycle ONE byte (differs from the standard) */
dev_dbg(nt->dev, "calculated duty cycle %02x\n", pwm_ratio);
ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
&pwm_ratio, 1); if (ret < 0) {
dev_err(nt->dev, "failed to set display PWM ratio (%d)\n", ret); return ret;
}
/* * Sequence to write PWMDIV: * address data * 0xF3 0xAA CMD2 Unlock * 0x00 0x01 Enter CMD2 page 0 * 0X7D 0x01 No reload MTP of CMD2 P1 * 0x22 PWMDIV * 0x7F 0xAA CMD2 page 1 lock
*/
par = 0xaa;
ret = mipi_dsi_dcs_write(dsi, 0xf3, &par, 1); if (ret < 0) {
dev_err(nt->dev, "failed to unlock CMD 2 (%d)\n", ret); return ret;
}
par = 0x01;
ret = mipi_dsi_dcs_write(dsi, 0x00, &par, 1); if (ret < 0) {
dev_err(nt->dev, "failed to enter page 1 (%d)\n", ret); return ret;
}
par = 0x01;
ret = mipi_dsi_dcs_write(dsi, 0x7d, &par, 1); if (ret < 0) {
dev_err(nt->dev, "failed to disable MTP reload (%d)\n", ret); return ret;
}
ret = mipi_dsi_dcs_write(dsi, 0x22, &pwm_div, 1); if (ret < 0) {
dev_err(nt->dev, "failed to set PWM divisor (%d)\n", ret); return ret;
}
par = 0xaa;
ret = mipi_dsi_dcs_write(dsi, 0x7f, &par, 1); if (ret < 0) {
dev_err(nt->dev, "failed to lock CMD 2 (%d)\n", ret); return ret;
}
/* Enable backlight */
par = 0x24;
ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY,
&par, 1); if (ret < 0) {
dev_err(nt->dev, "failed to enable display backlight (%d)\n", ret); return ret;
}
ret = nt35560_read_id(nt); if (ret) {
dev_err(nt->dev, "failed to read panel ID (%d)\n", ret); goto err_power_off;
}
/* Enabe tearing mode: send TE (tearing effect) at VBLANK */
ret = mipi_dsi_dcs_set_tear_on(dsi,
MIPI_DSI_DCS_TEAR_MODE_VBLANK); if (ret) {
dev_err(nt->dev, "failed to enable vblank TE (%d)\n", ret); goto err_power_off;
}
/* * Set MDDI * * This presumably deactivates the Qualcomm MDDI interface and * selects DSI, similar code is found in other drivers such as the * Sharp LS043T1LE01 which makes us suspect that this panel may be * using a Novatek NT35565 or similar display driver chip that shares * this command. Due to the lack of documentation we cannot know for * sure.
*/
ret = mipi_dsi_dcs_write(dsi, NT35560_DCS_SET_MDDI,
&mddi, sizeof(mddi)); if (ret < 0) {
dev_err(nt->dev, "failed to set MDDI (%d)\n", ret); goto err_power_off;
}
/* Exit sleep mode */
ret = mipi_dsi_dcs_exit_sleep_mode(dsi); if (ret) {
dev_err(nt->dev, "failed to exit sleep mode (%d)\n", ret); goto err_power_off;
}
msleep(140);
ret = mipi_dsi_dcs_set_display_on(dsi); if (ret) {
dev_err(nt->dev, "failed to turn display on (%d)\n", ret); goto err_power_off;
} if (nt->video_mode) { /* In video mode turn peripheral on */
ret = mipi_dsi_turn_on_peripheral(dsi); if (ret) {
dev_err(nt->dev, "failed to turn on peripheral\n"); goto err_power_off;
}
}
ret = mipi_dsi_dcs_set_display_off(dsi); if (ret) {
dev_err(nt->dev, "failed to turn display off (%d)\n", ret); return ret;
}
/* Enter sleep mode */
ret = mipi_dsi_dcs_enter_sleep_mode(dsi); if (ret) {
dev_err(nt->dev, "failed to enter sleep mode (%d)\n", ret); return ret;
}
msleep(85);
dsi->lanes = 2;
dsi->format = MIPI_DSI_FMT_RGB888; /* * FIXME: these come from the ST-Ericsson vendor driver for the * HREF520 and seems to reflect limitations in the PLLs on that * platform, if you have the datasheet, please cross-check the * actual max rates.
*/
dsi->lp_rate = 19200000;
dsi->hs_rate = 420160000;
if (nt->video_mode) /* Burst mode using event for sync */
dsi->mode_flags =
MIPI_DSI_MODE_VIDEO |
MIPI_DSI_MODE_VIDEO_BURST; else
dsi->mode_flags =
MIPI_DSI_CLOCK_NON_CONTINUOUS;
nt->supply = devm_regulator_get(dev, "vddi"); if (IS_ERR(nt->supply)) return PTR_ERR(nt->supply);
/* This asserts RESET by default */
nt->reset_gpio = devm_gpiod_get_optional(dev, "reset",
GPIOD_OUT_HIGH); if (IS_ERR(nt->reset_gpio)) return dev_err_probe(dev, PTR_ERR(nt->reset_gpio), "failed to request GPIO\n");
nt->panel.backlight = devm_backlight_device_register(dev, "nt35560", dev, nt,
&nt35560_bl_ops, &nt35560_bl_props); if (IS_ERR(nt->panel.backlight)) return dev_err_probe(dev, PTR_ERR(nt->panel.backlight), "failed to register backlight device\n");
drm_panel_add(&nt->panel);
ret = mipi_dsi_attach(dsi); if (ret < 0) {
drm_panel_remove(&nt->panel); return ret;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.