From nobody Thu Apr 9 20:26:03 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4146A3ED5C8 for ; Thu, 5 Mar 2026 19:57:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772740651; cv=none; b=ZLBSPx+4ymvsvTFFl6OIyXYT2d2APK2CAXmL1oQKMSqrrudvmpoCyg6MKAHc7sJjl8KE8HRujpsOwVMGUQ181kYmq4um4vivKQ04lCZPO2Tc+C1Cs+Gq3D7PtHqjAYkZBuJTjhWw51Zr2kznV4umel1BOMYB/KDOPXJVw8eteHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772740651; c=relaxed/simple; bh=ujvbhvdxFxvp+dEVlmpX9OLStQw937Z/KLIDIgyo1gA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J3vG4Rynl+EBzeTrQzoVQGJN1coOeDP4rsZJHbkruzYsATPCopOoFdU3qK5NqKOyHVDTbogJ44Nn0giV0k4zP7S1rLKvCJ6N/A/6kc4K6uBRWhQDO9BjFgZXroNCUDmUXHkYcJMU91gBAkkI61DRutGU3Zo0dweBQAHyubkL4xk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UI9kdQw8; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UI9kdQw8" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-439c6fc2910so1722291f8f.0 for ; Thu, 05 Mar 2026 11:57:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772740644; x=1773345444; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZtSz5l75Rw6ZqIXeFcoTcvd2i9c8nNbyLRXNmlkxqoo=; b=UI9kdQw83t32crcOuu4ZN+pCyFZuXGHNUq0X2JqOBQZoMh7haLTpnzO+r0xgh1qZWQ 49qq8B0miepnx7d6k/4O4eUt7gxI49MCrWoZbYFCJbGolfN2oHXxKO0DE9Ws2m3ywsBP /ZCs+/+0GYiKbMJCVkm+osZkMj/nV896Ft5ahaHXBXwAbtx0KT0LFiX/hsfIoUxha0Xb nVfFM/7FZK0a2LV2pDVuRQ/e4QHO/wOzxieshl0UHvp06wwVdFn8IH8SqLwnI6Wy+U4v B3gkK3F3bouH9hyulcGYYuV5CsWjgt0hBO8Jquv9Hv5JUHcvW5rK3RGL2Qxh2Nsgv7hl fL5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772740644; x=1773345444; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZtSz5l75Rw6ZqIXeFcoTcvd2i9c8nNbyLRXNmlkxqoo=; b=gcFxhMpS/7vjMJows7MZc9w2/w/cliaKqgPHmazxOFfcp5tvOEn3tQd08MoNh9VxJM /LX/UcE5vBNHT2ajHK6I8CKguVznOLiyTN1U18TSVkKZLWa+pcbM3cgObk4SclHuj2W+ DTeHtQxa8jopficGBnOG9TChinfrhQQz1pzqTpXjVOPp+SnlzC2l3itHfMG1ex2/0fsj PbXODJZ/G3/gH9QQO3TnGIKi5vvUt28g9w3ELkf7Hjin2WT0JBABK2KqUSQuhNj6j+3A JcPaAomOW5pUM5x7u23+8jNo+9oRttoKNGd5uyUATUmptBKJzAnLCyEdMD3w+9atYY5l r8Bg== X-Forwarded-Encrypted: i=1; AJvYcCW5lisq2Zh9BiiSBxJ2AobvwsZakQVCiSEcBgb++ofUrbX07KbJzHp5VrmvUn4bLwWOWckurhwQm9yt/mM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+CPzyL4UkBljGdCiEWjWmUY7ZvXS38np5a5gISPtVqLgyNUcU Hj9B+XKcZP1zXKK411A4gsed90LUrZuO8Bx6MHxesPFkOFDhUtWbfZER X-Gm-Gg: ATEYQzxrCWaiIgcl4itADo0AISLwwZ+Tu6OFHMCF0r6ebrYF0HOH57FKsLqJAfnCoA8 ds2cP7j8tp3MqRFtys8m3D//Hdw5uqI6gV6mn3v5y25B+Kz3ay+Oq40AuJJoi6Z4Ib8W+3Z43LC 6QWHcjEQ95nXeCD3eKb/KGjENAg8rc9+neY26e1AEEG+ZI/TBuAxIGpCHx2+uansGePV0zftTpH mG4gwaYHCmoJSopb8hIEU5ATSqXDz3EBP+VEwRL+W6f849oswoWTRetOPauNj5LldzD4sdERMnU PG3TmEXwGAp5QtZmCBFgWGggOXZrpgClpSgGV9wskXW2KDGt9SdcLQDTzIpgOzJaVzI4hLVEsCH gTGW3OXBNyK8V/0/nDKfQP0YirldweG12l0rF10mwYVtMgL7uIZmHDjlqac4+O7m3TJqR8bdl4Y GKiXuCLLeCSHJuxQjHHwM= X-Received: by 2002:a5d:5f85:0:b0:431:8f8:7f24 with SMTP id ffacd0b85a97d-439d72595bdmr1734488f8f.39.1772740643877; Thu, 05 Mar 2026 11:57:23 -0800 (PST) Received: from luca-vm.lan ([154.61.61.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439bb686a32sm26974297f8f.13.2026.03.05.11.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 11:57:23 -0800 (PST) From: Luca Leonardo Scorcia To: dri-devel@lists.freedesktop.org Cc: Luca Leonardo Scorcia , Jagan Teki , Neil Armstrong , Jessica Zhang , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Heiko Stuebner , Marek Vasut , "Kael D'Alcamo" , Lad Prabhakar , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: display: panel: Add compatibles for Zhunyi Z40046 Date: Thu, 5 Mar 2026 19:56:30 +0000 Message-ID: <20260305195650.119196-2-l.scorcia@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260305195650.119196-1-l.scorcia@gmail.com> References: <20260305195650.119196-1-l.scorcia@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Zhunyi Z40046 is a 480x800 24-bit WVGA DSI panel based on the Fitipower JD9161Z DSI controller found in the Xiaomi Mi Smart Clock x04g, apparently in two different variants. The Fitipower JD9161Z LCD driver IC is very similar to the Jadard JD9365DA-H3, it just uses a different initialization sequence. Since this is the first supported device from this vendor, document its name to the vendor-prefixes.yaml file as well. Signed-off-by: Luca Leonardo Scorcia --- .../devicetree/bindings/display/panel/jadard,jd9365da-h3.yaml | 2 ++ Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/display/panel/jadard,jd9365d= a-h3.yaml b/Documentation/devicetree/bindings/display/panel/jadard,jd9365da= -h3.yaml index 5802fb3c9ffe..da17072ffaaa 100644 --- a/Documentation/devicetree/bindings/display/panel/jadard,jd9365da-h3.ya= ml +++ b/Documentation/devicetree/bindings/display/panel/jadard,jd9365da-h3.ya= ml @@ -23,6 +23,8 @@ properties: - melfas,lmfbx101117480 - radxa,display-10hd-ad001 - radxa,display-8hd-ad002 + - zhunyi,z40046v1 + - zhunyi,z40046v2 - const: jadard,jd9365da-h3 =20 reg: diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Docum= entation/devicetree/bindings/vendor-prefixes.yaml index ee7fd3cfe203..18121440dc22 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -1913,6 +1913,8 @@ patternProperties: description: Shenzhen Zkmagic Technology Co., Ltd. "^zte,.*": description: ZTE Corp. + "^zhunyi,.*": + description: Shenzhen Zhunyi Technology Co., Ltd. "^zyxel,.*": description: ZyXEL Communications Corp. =20 --=20 2.43.0 From nobody Thu Apr 9 20:26:03 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83EE73FD14D for ; Thu, 5 Mar 2026 19:57:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772740656; cv=none; b=ieuOrefpKkp+uIj2cqgvJu2JfSFbptPc3TFsjEp0ywrtfwAX4vIgQ740t9HeVF4ugYzsbYV24c0LR0HAq4jDuo/1zral3nNOaYZqLLAOIdZmzmKchlX6COV5nthOAdTzNafHFVw9q38HY0ZH1IF76i+K+/AhVuqfqA5xdX3vTog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772740656; c=relaxed/simple; bh=pePllyxby7JhdwUh5/jJkZZqOJyp92crYJpaKce4nt4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P29E1Eou3c+MYEcwvsMYAbd+/xZE0Gq/Ix7jugMKtLd9vMUb+MWM7eceXwqSeTB1oil1l1x/dj4v5OXk9+KAxt4Yv67JEPK9Xu6Pdu5wxnZEEAE7FxCCJpheDSoV6yQlLBUPQ2PwdfEqN8u314noe3Itt/aIpF6KSi8l1NgRrpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GJBDXs2A; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GJBDXs2A" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-439c9eb5d36so2071423f8f.2 for ; Thu, 05 Mar 2026 11:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772740647; x=1773345447; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8g4jD+lM4KD2+vvthvQvaKxkXysJFhQZ5m0wfrvK+Hg=; b=GJBDXs2A1JiSwPz0sqykvW4HBWcugEoqk1an3jO+nM+YjkFBFzl6MolWQug8ZpUAaS C4F8QZoIaw66re5qjb6g4uziPfp8pE0Y0+Q+4HU+Wmh7evK9U6atC0YLM0OdeBvf1I+Q YBNpNVoYBI7oaha11s81hM/w9rtrOPhP5XcFbk4b4amfUCQ6J4xkt6cJAL+WHQ14e/Tt K1Dryec85RqFwa1reobW+77M9bLyjXZD/fF6SB2YfyyyMP2k5N7CGmZhMOaxkv/D0mnP s9iXjuhkJEnsYRv4yckURBi8mXxfO3VyaPVMsNUe+U+CTUaeWU9iPb4jMdPEz3hYmtci d+Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772740647; x=1773345447; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8g4jD+lM4KD2+vvthvQvaKxkXysJFhQZ5m0wfrvK+Hg=; b=uKQg8w36AwrZNsHv7gr1p+NnuZuIg77Yj0k21VraCqasLmuBNKaskco2sKsJzU9igo YDAnNq+KPtqqk/7gBUgarVcdmgO4u6hcNsXYCiIFwwKGYBAlmTVB2n1O83G24/FpgPQv 4bTmZppdmsaz6nbXVUv3jyuqk5zd1QNuZzcSOZZ2fIZovVln5uaccPUJDLrohAJUzrVO fDAqXyfJekk742/spMsIF0H4pnhjJNf82NwtFCYnxfyGKpYKQRtkXmuMsOeGvMgxX86u Wynp71u2lvjJ7ZDUvI8AiY0LPAtj1FsTKBi9f+okJ3tQXMmSn0SaAs4c2PBJZNbpuo8q mjXw== X-Forwarded-Encrypted: i=1; AJvYcCV/YfITSM8Mue+MmJ7lCH9bU2gkOcUV98BpUaObS2Zv2ezHWVi93MC4M5RLIA18826jm6Y4SLtQLebYuHY=@vger.kernel.org X-Gm-Message-State: AOJu0YwJkUe1yG4P60Dp9U96ZRzhC+WJLRrmKveLweKzBpFxzDvrStq5 gxJx0QNK47PzO2K9TCsdupDBJlLW/B58CMeU6URMC1M3RgGTrDXjz18B X-Gm-Gg: ATEYQzw4r5wuiIKa4Sq/TJxg+0ioCTwTXDtR1PQdo822u5YVOdwEWaPgR5XVUjHajjq cHCUNo6zcNKEzx0Uq4FzisNqDOoF3Fv/84D7oQ4zXCrtJAwVMXjdEmRmy+tMtKra+0vy5LPOE9o mbVlCJ+O/vPNAqZqp7uMd7CCeWEeJCBHgi786wOERGrCWGDaZ9kkkXie4B2Zbv2Z9gJSIjUMLFR 3Knm1+Vva0/S3Z0UME+4Aw9vanZLZ1s37GR9h63QasdnEl64vW8+pSYDnRWe0UrwyaNjO6uXBN4 Gau8DAmlhLFqvJPQVRBMqfrYOPoJxbl65W9KVSbIE0+5kZLzojD4qHsqIDhJb/5wPbq9InbxhyN /XqDGVq6xwKXiaT25JSYoy1mz/YOPqC4kmtv++7ocVVHYPYXpMcu2aKoTQJ72rnxTwdPgaHeBrD ZhOoVuZYgag8ZFKgT3O8wRPtgkxND0rg== X-Received: by 2002:a05:6000:3112:b0:439:d750:42f6 with SMTP id ffacd0b85a97d-439d7504334mr1415838f8f.24.1772740646285; Thu, 05 Mar 2026 11:57:26 -0800 (PST) Received: from luca-vm.lan ([154.61.61.58]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439bb686a32sm26974297f8f.13.2026.03.05.11.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Mar 2026 11:57:25 -0800 (PST) From: Luca Leonardo Scorcia To: dri-devel@lists.freedesktop.org Cc: Luca Leonardo Scorcia , Jagan Teki , Neil Armstrong , Jessica Zhang , David Airlie , Simona Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Marek Vasut , Lad Prabhakar , "Kael D'Alcamo" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] drm/panel: jd9365da: Support for Zhunyi Z40046 panels Date: Thu, 5 Mar 2026 19:56:31 +0000 Message-ID: <20260305195650.119196-3-l.scorcia@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260305195650.119196-1-l.scorcia@gmail.com> References: <20260305195650.119196-1-l.scorcia@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Zhunyi Z40046 is a 480x800 24-bit WVGA DSI panel based on the Fitipower JD9161Z DSI controller found in the Xiaomi Mi Smart Clock x04g, apparently in two different variants. The Fitipower JD9161Z LCD driver IC is very similar to the Jadard JD9365DA-H3, it just uses different initialization sequences. The two initialization sequences for the panel have been extracted from Android original firmware for the Xiaomi Smart Clock. Variant v1 tested on device. Variant v2 not tested. Signed-off-by: Luca Leonardo Scorcia --- .../gpu/drm/panel/panel-jadard-jd9365da-h3.c | 308 ++++++++++++++++++ 1 file changed, 308 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c b/drivers/gpu= /drm/panel/panel-jadard-jd9365da-h3.c index 5386a06fcd08..9bcf846684e4 100644 --- a/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c +++ b/drivers/gpu/drm/panel/panel-jadard-jd9365da-h3.c @@ -46,11 +46,22 @@ struct jadard { struct gpio_desc *reset; }; =20 +#define JD9161Z_DCS_SWITCH_PAGE 0xde + +#define jd9161z_switch_page(dsi_ctx, page) \ + mipi_dsi_dcs_write_seq_multi(dsi_ctx, JD9161Z_DCS_SWITCH_PAGE, (page)) + #define JD9365DA_DCS_SWITCH_PAGE 0xe0 =20 #define jd9365da_switch_page(dsi_ctx, page) \ mipi_dsi_dcs_write_seq_multi(dsi_ctx, JD9365DA_DCS_SWITCH_PAGE, (page)) =20 +static void jd9161z_enable_standard_cmds(struct mipi_dsi_multi_context *ds= i_ctx) +{ + // Enable access to DCS and internal commands + mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xdf, 0x91, 0x62, 0xf3); +} + static void jadard_enable_standard_cmds(struct mipi_dsi_multi_context *dsi= _ctx) { mipi_dsi_dcs_write_seq_multi(dsi_ctx, 0xe1, 0x93); @@ -1366,6 +1377,295 @@ static const struct jadard_panel_desc anbernic_rgds= _display_desc =3D { MIPI_DSI_CLOCK_NON_CONTINUOUS | MIPI_DSI_MODE_LPM, }; =20 +// Sequence retrieved from Xiaomi Mi Smart Clock x04g kernel in boot.bin +static int zhunyi_z40046_init_cmds_v1(struct jadard *jadard_data) +{ + struct mipi_dsi_multi_context dsi_ctx =3D { .dsi =3D jadard_data->dsi }; + + // Init configuration sequence + jd9161z_switch_page(&dsi_ctx, 0x00); + jd9161z_enable_standard_cmds(&dsi_ctx); + + // GAMMA_SET (pos/neg voltage of gamma power) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb7, + 0x10, 0x04, 0x86, 0x00, 0x1b, 0x35); + + // DCDC_SEL (power mode and charge pump settings) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xbb, + 0x69, 0x0b, 0x30, 0xb2, 0xb2, 0xc0, 0xe0, 0x20, + 0xf0, 0x50, 0x60, + ); + + // VDDD_CTRL (control logic voltage setting) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xbc, + 0x73, 0x14); + + // SETRGBCYC (display waveform cycle of RGB mode) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc3, + 0x74, 0x04, 0x08, 0x0e, 0x00, 0x0e, 0x0c, 0x08, + 0x0e, 0x00, 0x0e, 0x82, 0x0a, 0x82, + ); + + // SET_TCON (timing control setting) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc4, + 0x10, 0x90, 0x92, 0x0e, 0x0b, 0x04); + + // SET_R_GAMMA (set red gamma output voltage) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc8, + 0x7e, 0x76, 0x68, 0x57, 0x4c, 0x39, 0x3a, 0x23, + 0x3d, 0x3d, 0x40, 0x61, 0x54, 0x64, 0x5d, 0x62, + 0x5a, 0x50, 0x32, 0x7e, 0x76, 0x68, 0x57, 0x4c, + 0x39, 0x3a, 0x23, 0x3d, 0x3d, 0x40, 0x61, 0x54, + 0x64, 0x5d, 0x62, 0x5a, 0x50, 0x32, + ); + + // SET_GIP_L (CGOUTx_L signal mapping, gs_panel =3D 0) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd0, + 0x1f, 0x0a, 0x08, 0x06, 0x04, 0x1f, 0x00, 0x1f, + 0x17, 0x1f, 0x18, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + ); + + // SET_GIP_R (CGOUTx_R signal mapping, gs_panel =3D 0) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd1, + 0x1f, 0x0b, 0x09, 0x07, 0x05, 0x1f, 0x01, 0x1f, + 0x17, 0x1f, 0x18, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + ); + + // SETGIP1 (GIP signal timing 1) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd4, + 0x10, 0x00, 0x00, 0x03, 0x60, 0x05, 0x10, 0x00, + 0x02, 0x06, 0x68, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x00, 0x06, 0x78, 0x71, 0x07, 0x06, 0x68, 0x0c, + 0x25, 0x00, 0x63, 0x03, 0x00, + ); + + // SETGIP2 (GIP signal timing 1) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd5, + 0x20, 0x10, 0x8c, 0x18, 0x00, 0x80, 0x00, 0x08, + 0x00, 0x00, 0x06, 0x60, 0x00, 0x81, 0x70, 0x02, + 0x30, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, + 0x03, 0x60, 0x83, 0x90, 0x00, 0x00, 0x03, 0x4f, + 0x03, 0x00, 0x1f, 0x3f, 0x00, 0x00, 0x00, 0x00, + ); + + jd9161z_switch_page(&dsi_ctx, 0x04); + + // ? + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb0, + 0x24, 0x01); + + jd9161z_switch_page(&dsi_ctx, 0x02); + + // SETRGBCYC2 (RGB IF source switch control timing) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc1, + 0x71); + + // ? + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc2, + 0x00, 0x18, 0x08, 0x1e, 0x25, 0x7c, 0xc7, + ); + + jd9161z_switch_page(&dsi_ctx, 0x00); + + mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK); + + mipi_dsi_msleep(&dsi_ctx, 120); + + mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx); + + mipi_dsi_msleep(&dsi_ctx, 120); + + mipi_dsi_dcs_set_display_on_multi(&dsi_ctx); + + mipi_dsi_msleep(&dsi_ctx, 5); + + return dsi_ctx.accum_err; +}; + +static const struct jadard_panel_desc zhunyi_z40046v1_desc =3D { + .mode =3D { + .clock =3D 26700, + + .hdisplay =3D 480, + .hsync_start =3D 480 + 20, + .hsync_end =3D 480 + 20 + 20, + .htotal =3D 480 + 20 + 20 + 20, + + .vdisplay =3D 800, + .vsync_start =3D 800 + 12, + .vsync_end =3D 800 + 12 + 4, + .vtotal =3D 800 + 12 + 4 + 8, + + .width_mm =3D 52, + .height_mm =3D 86, + .flags =3D DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, + .type =3D DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, + }, + .lanes =3D 2, + .format =3D MIPI_DSI_FMT_RGB888, + .mode_flags =3D MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | + MIPI_DSI_MODE_LPM, + .lp11_before_reset =3D true, + .reset_before_power_off_vcioo =3D true, + .vcioo_to_lp11_delay_ms =3D 5, + .lp11_to_reset_delay_ms =3D 10, + .backlight_off_to_display_off_delay_ms =3D 100, + .display_off_to_enter_sleep_delay_ms =3D 50, + .enter_sleep_to_reset_down_delay_ms =3D 100, + .init =3D zhunyi_z40046_init_cmds_v1, +}; + +// Sequence retrieved from Xiaomi Mi Smart Clock x04g kernel in boot.bin +static int zhunyi_z40046_init_cmds_v2(struct jadard *jadard_data) +{ + struct mipi_dsi_multi_context dsi_ctx =3D { .dsi =3D jadard_data->dsi }; + + // Init configuration sequence + jd9161z_switch_page(&dsi_ctx, 0x00); + jd9161z_enable_standard_cmds(&dsi_ctx); + + // GAMMA_SET (pos/neg voltage of gamma power) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xb7, + 0x10, 0x08, 0x42, 0x00, 0x56, 0x42, + ); + + // DCDC_SEL (power mode and charge pump settings) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xbb, + 0x52, 0x0f, 0xb2, 0xb2, 0xb2, 0xc0, 0xd0, 0x50, + 0xf0, 0x40, 0x50, + ); + + // VDDD_CTRL (control logic voltage setting) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xbc, + 0x73, 0x14); + + // SETRGBCYC (display waveform cycle of RGB mode) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc3, + 0x04, 0x07, 0x0b, 0x17, 0x00, 0x17, 0x04, 0x17, + 0x17, 0x00, 0x17, 0x82, 0x0b, 0x82, + ); + + // SET_TCON (timing control setting) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc4, + 0x10, 0x90, 0x92, 0x0e, 0x06, + ); + + // SET_R_GAMMA (set red gamma output voltage) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc8, + 0x7f, 0x78, 0x69, 0x56, 0x47, 0x33, 0x34, 0x1e, + 0x3b, 0x3e, 0x43, 0x67, 0x5d, 0x6f, 0x68, 0x70, + 0x6a, 0x61, 0x3c, 0x7f, 0x78, 0x69, 0x56, 0x47, + 0x33, 0x34, 0x1e, 0x3b, 0x3e, 0x43, 0x67, 0x5d, + 0x6f, 0x68, 0x70, 0x6a, 0x61, 0x3c, + ); + + // SET_GIP_L (CGOUTx_L signal mapping, gs_panel =3D 0) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd0, + 0x1f, 0x1e, 0x07, 0x05, 0x01, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + ); + + // SET_GIP_R (CGOUTx_R signal mapping, gs_panel =3D 0) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd1, + 0x1f, 0x1e, 0x06, 0x04, 0x00, 0x1f, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + ); + + // SET_GIP_L_GS (CGOUTx_L signal mapping, gs_panel =3D 1) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd2, + 0x1f, 0x1f, 0x04, 0x06, 0x00, 0x1e, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + ); + + // SET_GIP_R_GS (CGOUTx_R signal mapping, gs_panel =3D 1) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd3, + 0x1f, 0x1f, 0x05, 0x07, 0x01, 0x1e, 0x1f, 0x1f, + 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, + ); + + // SETGIP1 (GIP signal timing 1) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd4, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, + 0x03, 0x03, 0x68, 0x03, 0x40, 0x05, 0x00, 0x00, + 0x00, 0xcc, 0x2d, 0x31, 0x02, 0x03, 0x68, 0x0c, + 0x25, 0x00, 0x63, 0x03, 0x00, + ); + + // SETGIP2 (GIP signal timing 1) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xd5, + 0x30, 0x08, 0x80, 0x18, 0x00, 0x00, 0x00, 0x18, + 0x00, 0x00, 0x06, 0x60, 0x00, 0x07, 0x50, 0x00, + 0x33, 0xc0, 0x00, 0x60, 0xc0, 0x00, 0x00, 0x00, + 0x03, 0x60, 0x06, 0x10, 0x00, 0x00, 0x0f, 0x4f, + 0x00, 0x10, 0x1f, 0x3f, + ); + + jd9161z_switch_page(&dsi_ctx, 0x02); + + // SETRGBCYC2 (RGB IF source switch control timing) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc1, + 0x60); + + // ? + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xc2, + 0x00, 0x18, 0x08, 0x1e, 0x25, 0x7c, 0xc7, + ); + + jd9161z_switch_page(&dsi_ctx, 0x00); + + // GAS_CTRL (GAS function control) + mipi_dsi_dcs_write_seq_multi(&dsi_ctx, 0xbe, + 0x4e, + ); + + mipi_dsi_dcs_set_tear_on_multi(&dsi_ctx, MIPI_DSI_DCS_TEAR_MODE_VBLANK); + + mipi_dsi_msleep(&dsi_ctx, 120); + + mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx); + + mipi_dsi_msleep(&dsi_ctx, 120); + + mipi_dsi_dcs_set_display_on_multi(&dsi_ctx); + + mipi_dsi_msleep(&dsi_ctx, 5); + + return dsi_ctx.accum_err; +}; + +static const struct jadard_panel_desc zhunyi_z40046v2_desc =3D { + .mode =3D { + .clock =3D 26700, + + .hdisplay =3D 480, + .hsync_start =3D 480 + 20, + .hsync_end =3D 480 + 20 + 20, + .htotal =3D 480 + 20 + 20 + 20, + + .vdisplay =3D 800, + .vsync_start =3D 800 + 12, + .vsync_end =3D 800 + 12 + 4, + .vtotal =3D 800 + 12 + 4 + 8, + + .width_mm =3D 52, + .height_mm =3D 86, + .flags =3D DRM_MODE_FLAG_NHSYNC | DRM_MODE_FLAG_NVSYNC, + .type =3D DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, + }, + .lanes =3D 2, + .format =3D MIPI_DSI_FMT_RGB888, + .mode_flags =3D MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | + MIPI_DSI_MODE_LPM, + .lp11_before_reset =3D true, + .reset_before_power_off_vcioo =3D true, + .vcioo_to_lp11_delay_ms =3D 5, + .lp11_to_reset_delay_ms =3D 10, + .backlight_off_to_display_off_delay_ms =3D 100, + .display_off_to_enter_sleep_delay_ms =3D 50, + .enter_sleep_to_reset_down_delay_ms =3D 100, + .init =3D zhunyi_z40046_init_cmds_v2, +}; + static int jadard_dsi_probe(struct mipi_dsi_device *dsi) { struct device *dev =3D &dsi->dev; @@ -1463,6 +1763,14 @@ static const struct of_device_id jadard_of_match[] = =3D { .compatible =3D "radxa,display-8hd-ad002", .data =3D &radxa_display_8hd_ad002_desc }, + { + .compatible =3D "zhunyi,z40046v1", + .data =3D &zhunyi_z40046v1_desc + }, + { + .compatible =3D "zhunyi,z40046v2", + .data =3D &zhunyi_z40046v2_desc + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, jadard_of_match); --=20 2.43.0