diff --git a/lk2nd/device/2nd/spi-display.c b/lk2nd/device/2nd/spi-display.c index e55fe9c..c123a39 100644 --- a/lk2nd/device/2nd/spi-display.c +++ b/lk2nd/device/2nd/spi-display.c @@ -15,20 +15,44 @@ #include "device.h" +static const unsigned char *find_panel_init_in_dev(const void *dtb, + int dev_node, const char *name, const char **found_name, int *len) +{ + int panel_node, node; + const void *prop; + + panel_node = fdt_subnode_offset(dtb, dev_node, "panel"); + if(panel_node < 0) + return NULL; + + fdt_for_each_subnode(node, dtb, panel_node) { + const char *node_name = fdt_get_name(dtb, node, NULL); + + if(name && (!node_name || strcmp(node_name, name))) + continue; + + prop = fdt_getprop(dtb, node, "lk2nd,panel-init", len); + if(prop && *len > 0) { + if(found_name) + *found_name = node_name; + return prop; + } + } + return NULL; +} + /** * find_panel_init() - Look up the lk2nd,panel-init stream for the detected panel. * - * The same QCDT image carries device nodes for several feature phones. Search - * all of them instead of relying on the matched device node, so the panel - * init also works when lk2nd was forced to a compatible via the cmdline. - * When name is NULL, the first panel node carrying an init stream is used; - * that lets a chain-loaded diagnostic probe work without aboot panel tags. + * Searches the active compatible node first, then falls back across other + * /lk2nd device nodes so a forced compatible still finds panel streams. + * When name is NULL, the first panel node carrying an init stream is used. */ static const unsigned char *find_panel_init(const void *dtb, const char *name, const char **found_name, int *len) { - int lk2nd_node, dev_node, panel_node, node; - const void *prop; + int lk2nd_node, dev_node; + const unsigned char *prop; if(!dtb) return NULL; @@ -37,25 +61,21 @@ static const unsigned char *find_panel_init(const void *dtb, const char *name, if(lk2nd_node < 0) return NULL; - fdt_for_each_subnode(dev_node, dtb, lk2nd_node) { - panel_node = fdt_subnode_offset(dtb, dev_node, "panel"); - if(panel_node < 0) - continue; - - fdt_for_each_subnode(node, dtb, panel_node) { - const char *node_name = fdt_get_name(dtb, node, NULL); - - if(name && (!node_name || strcmp(node_name, name))) - continue; - - prop = fdt_getprop(dtb, node, "lk2nd,panel-init", len); - if(prop && *len > 0) { - if(found_name) - *found_name = node_name; - return prop; + if(lk2nd_dev.compatible) { + fdt_for_each_subnode(dev_node, dtb, lk2nd_node) { + if(fdt_node_check_compatible(dtb, dev_node, lk2nd_dev.compatible) == 0) { + prop = find_panel_init_in_dev(dtb, dev_node, name, found_name, len); + if(prop) + return prop; } } } + + fdt_for_each_subnode(dev_node, dtb, lk2nd_node) { + prop = find_panel_init_in_dev(dtb, dev_node, name, found_name, len); + if(prop) + return prop; + } return NULL; } @@ -228,11 +248,11 @@ static int spi_display_setup(void) bool have_init; /* A chain-loaded lk2nd does not inherit aboot's mdss_mdp3.panel tag. - * The beats QCDT node is authoritative: use its only panel init stream - * and keep the known SPI interface even when fastboot boot replaced the - * original cmdline. */ + * The device QCDT node is authoritative: keep the known SPI interface + * even when fastboot boot replaced the original cmdline. */ if(lk2nd_dev.compatible && - !strcmp(lk2nd_dev.compatible, "nokia,beatles") && + (!strcmp(lk2nd_dev.compatible, "nokia,beatles") || + !strcmp(lk2nd_dev.compatible, "nokia,coconut")) && (!lk2nd_dev.panel.intf || strcmp(lk2nd_dev.panel.intf, "spi"))) lk2nd_dev.panel.intf = "spi"; diff --git a/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts b/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts index 0bd2846..859e114 100644 --- a/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts +++ b/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts @@ -68,3 +68,4 @@ }; #include "nokia-beatles.dtsi" +#include "nokia-coconut.dtsi" diff --git a/lk2nd/device/dts/msm8909/nokia-coconut.dtsi b/lk2nd/device/dts/msm8909/nokia-coconut.dtsi new file mode 100644 index 0000000..c5b2a03 --- /dev/null +++ b/lk2nd/device/dts/msm8909/nokia-coconut.dtsi @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: BSD-3-Clause +/* + * Nokia 800 Tough (nokia-coconut) lk2nd device node. + * + * Shares the MSM8905 QRD SKUB board family with the CAT B35, Nokia 8110 4G, + * and Nokia 2720 Flip. The 800 Tough drives a 240x320 RGB565 command-mode + * SPI panel on BLSP1 QUP5. + * + * lk2nd,panel-init holds the downstream KaiOS qcom,mdss-spi-on-command byte + * stream in [wait dlen payload...] format so lk2nd can initialize the panel + * deterministically when booted directly or chain-loaded. + */ + +&lk2nd { + nokia-coconut { + model = "Nokia 800 Tough"; + compatible = "nokia,coconut"; + lk2nd,match-panel; + lk2nd,dtb-files = "msm8905-nokia-coconut"; + lk2nd,menu-key-strings = "Up and down keys", "Power key"; + + panel { + compatible = "nokia,coconut-panel"; + + qcom,mdss_spi_gc9305_qvga_cmd { + compatible = "nokia,coconut-gc9305-panel"; + }; + + qcom,mdss_spi_gc9305_v2_qvga_cmd { + compatible = "nokia,coconut-gc9305-v2-panel"; + lk2nd,panel-init = [ + 00 01 fe + 00 01 ef + 00 02 3a 05 + 00 02 35 00 + 00 05 2a 00 00 00 ef + 00 05 2b 00 00 01 3f + 00 01 2c + 78 01 11 + 00 01 29 + 00 01 2c + ]; + }; + + qcom,mdss_spi_gc9305_3rd_qvga_cmd { + compatible = "nokia,coconut-gc9305-3rd-panel"; + }; + + qcom,mdss_spi_st7789_qvga_cmd { + compatible = "nokia,coconut-st7789-panel"; + }; + + qcom,mdss_spi_gc9306_qvga_cmd { + compatible = "nokia,coconut-gc9306-panel"; + }; + }; + }; +};