- Remove LK2ND_VERSION from lk2nd/device/menu/menu.c (display_fastboot_menu and display_default_image_on_screen) in bootloader/lk2nd/nokia-beatles.patch so the BANANARCHY LINUX boot splash renders intact and boot/Fastboot-recovery screens carry no OS version tag.
- Replace -a1109-r3 / -a1114-r1 / -a1120-r1 suffixes in scripts/build-lk2nd-{beatles,coconut,sparkler}.sh with OS-version-neutral bananarchy-<target>{,-diag,-display} tags and enforce this in scripts/check-lk2nd-{beatles,coconut,sparkler}.py and scripts/check-rebuild.sh.
- Rebuild all 9 lk2nd images and refresh the a1120 (cocojamboo) display lk2nd and archive SHA-256 hashes in scripts/check-rebuild.sh, CHANGELOG.md, bootloader/lk2nd/README.md, and AGENTS.md.
1237 lines
38 KiB
Diff
1237 lines
38 KiB
Diff
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
|
|
index b44a5c2..a227768 100644
|
|
--- a/app/aboot/aboot.c
|
|
+++ b/app/aboot/aboot.c
|
|
@@ -61,6 +61,10 @@
|
|
#include <decompress.h>
|
|
#include <platform/timer.h>
|
|
#include <sys/types.h>
|
|
+
|
|
+/* Set by lk2nd's "oem scan-boot" command. */
|
|
+extern bool lk2nd_scan_only;
|
|
+
|
|
#if USE_RPMB_FOR_DEVINFO
|
|
#include <rpmb.h>
|
|
#endif
|
|
@@ -1248,6 +1252,13 @@ void boot_linux(void *kernel, unsigned *tags,
|
|
#endif
|
|
|
|
tags_done:
|
|
+ if(lk2nd_scan_only) {
|
|
+ dprintf(INFO, "scan-only: final kernel cmdline/DTB ready, staying in fastboot\n");
|
|
+ if(final_cmdline)
|
|
+ free(final_cmdline);
|
|
+ return;
|
|
+ }
|
|
+
|
|
#if VERIFIED_BOOT
|
|
if (VB_M <= target_get_vb_version())
|
|
{
|
|
diff --git a/lk2nd/boot/extlinux.c b/lk2nd/boot/extlinux.c
|
|
index 5bcf607..5145c1d 100644
|
|
--- a/lk2nd/boot/extlinux.c
|
|
+++ b/lk2nd/boot/extlinux.c
|
|
@@ -19,6 +19,14 @@
|
|
|
|
#include "boot.h"
|
|
|
|
+/* Set by the "oem scan-boot" fastboot command. boot_linux() applies the
|
|
+ final cmdline/DT updates and returns before the kernel jump. */
|
|
+bool lk2nd_scan_only = false;
|
|
+
|
|
+/* Staged by "oem scan-dtb" after lk2nd's final DT updates so the exact
|
|
+ DTB handed to the kernel can be inspected offline. */
|
|
+void *lk2nd_last_kernel_dtb;
|
|
+
|
|
struct label {
|
|
const char *name;
|
|
const char *kernel;
|
|
@@ -607,6 +615,8 @@ static void lk2nd_boot_label(struct label *label)
|
|
return;
|
|
}
|
|
|
|
+ lk2nd_last_kernel_dtb = addrs.tags;
|
|
+
|
|
if (label->dtboverlays) {
|
|
ret = fdt_open_into(addrs.tags, addrs.tags, MAX_TAGS_SIZE);
|
|
if (ret < 0) {
|
|
@@ -649,7 +659,14 @@ static void lk2nd_boot_label(struct label *label)
|
|
arch_clean_invalidate_cache_range((addr_t)addrs.ramdisk, ramdisk_size);
|
|
}
|
|
|
|
- boot_linux(addrs.kernel,
|
|
+ if(lk2nd_scan_only) {
|
|
+ dprintf(INFO, "scan-only: kernel=%s dtb=%s initramfs=%s\n",
|
|
+ label->kernel, label->dtb,
|
|
+ label->initramfs ? label->initramfs : "(none)");
|
|
+ dprintf(INFO, "scan-only: cmdline=%s\n", label->cmdline);
|
|
+ }
|
|
+
|
|
+ boot_linux(addrs.kernel,
|
|
addrs.tags,
|
|
label->cmdline,
|
|
board_machtype(),
|
|
diff --git a/lk2nd/device/2nd/rules.mk b/lk2nd/device/2nd/rules.mk
|
|
index 06d2dd5..8b5e670 100644
|
|
--- a/lk2nd/device/2nd/rules.mk
|
|
+++ b/lk2nd/device/2nd/rules.mk
|
|
@@ -8,6 +8,7 @@ MODULES += \
|
|
|
|
OBJS += \
|
|
$(LOCAL_DIR)/device.o \
|
|
+ $(LOCAL_DIR)/scan-boot.o \
|
|
$(LOCAL_DIR)/match.o \
|
|
$(LOCAL_DIR)/parse-cmdline.o \
|
|
$(LOCAL_DIR)/parse-tags.o \
|
|
diff --git a/lk2nd/device/2nd/scan-boot.c b/lk2nd/device/2nd/scan-boot.c
|
|
new file mode 100644
|
|
index 0000000..f859cf4
|
|
--- /dev/null
|
|
+++ b/lk2nd/device/2nd/scan-boot.c
|
|
@@ -0,0 +1,37 @@
|
|
+// SPDX-License-Identifier: BSD-3-Clause
|
|
+/*
|
|
+ * "oem scan-boot" runs the whole extlinux scan while lk2nd stays in
|
|
+ * fastboot. boot_linux() applies the final cmdline/DT updates and returns
|
|
+ * before the kernel jump when lk2nd_scan_only is set, so "fastboot oem
|
|
+ * log" shows the boot scan and "oem scan-dtb" stages the final DTB.
|
|
+ */
|
|
+
|
|
+#include <debug.h>
|
|
+#include <fastboot.h>
|
|
+#include <libfdt.h>
|
|
+
|
|
+#include <lk2nd/boot.h>
|
|
+
|
|
+extern bool lk2nd_scan_only;
|
|
+extern void *lk2nd_last_kernel_dtb;
|
|
+
|
|
+static void cmd_oem_scan_dtb(const char *arg, void *data, unsigned sz)
|
|
+{
|
|
+ if (!lk2nd_last_kernel_dtb) {
|
|
+ fastboot_fail("run oem scan-boot first");
|
|
+ return;
|
|
+ }
|
|
+ fastboot_stage(lk2nd_last_kernel_dtb, fdt_totalsize(lk2nd_last_kernel_dtb));
|
|
+}
|
|
+FASTBOOT_REGISTER("oem scan-dtb", cmd_oem_scan_dtb);
|
|
+
|
|
+static void cmd_oem_scan_boot(const char *arg, void *data, unsigned sz)
|
|
+{
|
|
+ lk2nd_scan_only = true;
|
|
+ dprintf(INFO, "scan-boot: running extlinux scan without booting\n");
|
|
+ lk2nd_boot();
|
|
+ lk2nd_scan_only = false;
|
|
+ dprintf(INFO, "scan-boot: done\n");
|
|
+ fastboot_okay("");
|
|
+}
|
|
+FASTBOOT_REGISTER("oem scan-boot", cmd_oem_scan_boot);
|
|
diff --git a/lk2nd/device/2nd/spi-display.c b/lk2nd/device/2nd/spi-display.c
|
|
index 81595db..e55fe9c 100644
|
|
--- a/lk2nd/device/2nd/spi-display.c
|
|
+++ b/lk2nd/device/2nd/spi-display.c
|
|
@@ -3,7 +3,11 @@
|
|
|
|
#include <debug.h>
|
|
#include <dev/fbcon.h>
|
|
+#include <fastboot.h>
|
|
+#include <libfdt.h>
|
|
#include <mdp4.h>
|
|
+#include <mdss_spi.h>
|
|
+#include <stdint.h>
|
|
#include <string.h>
|
|
#include <target/display.h>
|
|
|
|
@@ -11,44 +15,351 @@
|
|
|
|
#include "device.h"
|
|
|
|
+/**
|
|
+ * 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.
|
|
+ */
|
|
+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;
|
|
+
|
|
+ if(!dtb)
|
|
+ return NULL;
|
|
+
|
|
+ lk2nd_node = fdt_path_offset(dtb, "/lk2nd");
|
|
+ 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;
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ return NULL;
|
|
+}
|
|
+
|
|
+static bool cmdline_flag(const char *flag)
|
|
+{
|
|
+ const char *p = lk2nd_dev.cmdline;
|
|
+ size_t len = strlen(flag);
|
|
+
|
|
+ if(!p)
|
|
+ return false;
|
|
+ while((p = strstr(p, flag))) {
|
|
+ if((p == lk2nd_dev.cmdline || p[-1] == ' ') &&
|
|
+ (p[len] == '\0' || p[len] == ' '))
|
|
+ return true;
|
|
+ p += len;
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
static void mdss_spi_flush(void)
|
|
{
|
|
- mdss_spi_on(NULL, fbcon_display());
|
|
+ mdss_spi_on(NULL, fbcon_display());
|
|
+}
|
|
+
|
|
+static struct fbcon_config spi_fb;
|
|
+static bool spi_ready;
|
|
+
|
|
+/**
|
|
+ * Bananarchy boot splash for the 240x320 RGB565 framebuffer.
|
|
+ *
|
|
+ * The old striped test pattern was useful to prove lk2nd owned the panel,
|
|
+ * but it is not a boot screen. This draws a compact branded splash with a
|
|
+ * banana crescent, wordmark and progress bar using only integer RGB565
|
|
+ * writes, so it needs no image decoder, font file or extra library.
|
|
+ * Deliberately does not call fbcon_flush(): flushing a full frame over SPI
|
|
+ * before the bus is known to work used to wedge lk2nd before USB init.
|
|
+ */
|
|
+#define SPLASH_RGB(r, g, b) \
|
|
+ ((uint16_t)((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3)))
|
|
+#define SPLASH_BG SPLASH_RGB(8, 12, 26)
|
|
+#define SPLASH_BG2 SPLASH_RGB(16, 24, 48)
|
|
+#define SPLASH_YELLOW SPLASH_RGB(250, 210, 60)
|
|
+#define SPLASH_WHITE SPLASH_RGB(235, 240, 248)
|
|
+#define SPLASH_BLUE SPLASH_RGB(90, 150, 240)
|
|
+#define SPLASH_GREY SPLASH_RGB(90, 100, 120)
|
|
+#define SPLASH_BROWN SPLASH_RGB(96, 64, 24)
|
|
+
|
|
+struct splash_glyph {
|
|
+ char ch;
|
|
+ unsigned char col[5];
|
|
+};
|
|
+
|
|
+/* 5x7 column-major bitmap font: each byte is one column, bit 0 is top. */
|
|
+static const struct splash_glyph splash_font[] = {
|
|
+ {'A', {0x7e, 0x11, 0x11, 0x11, 0x7e}}, {'B', {0x7f, 0x49, 0x49, 0x49, 0x36}},
|
|
+ {'C', {0x3e, 0x41, 0x41, 0x41, 0x22}}, {'D', {0x7f, 0x41, 0x41, 0x22, 0x1c}},
|
|
+ {'E', {0x7f, 0x49, 0x49, 0x49, 0x41}}, {'F', {0x7f, 0x09, 0x09, 0x09, 0x01}},
|
|
+ {'G', {0x3e, 0x41, 0x49, 0x49, 0x7a}}, {'H', {0x7f, 0x08, 0x08, 0x08, 0x7f}},
|
|
+ {'I', {0x00, 0x41, 0x7f, 0x41, 0x00}}, {'J', {0x20, 0x40, 0x41, 0x3f, 0x01}},
|
|
+ {'K', {0x7f, 0x08, 0x14, 0x22, 0x41}}, {'L', {0x7f, 0x40, 0x40, 0x40, 0x40}},
|
|
+ {'M', {0x7f, 0x02, 0x0c, 0x02, 0x7f}}, {'N', {0x7f, 0x04, 0x08, 0x10, 0x7f}},
|
|
+ {'O', {0x3e, 0x41, 0x41, 0x41, 0x3e}}, {'P', {0x7f, 0x09, 0x09, 0x09, 0x06}},
|
|
+ {'Q', {0x3e, 0x41, 0x51, 0x21, 0x5e}}, {'R', {0x7f, 0x09, 0x19, 0x29, 0x46}},
|
|
+ {'S', {0x46, 0x49, 0x49, 0x49, 0x31}}, {'T', {0x01, 0x01, 0x7f, 0x01, 0x01}},
|
|
+ {'U', {0x3f, 0x40, 0x40, 0x40, 0x3f}}, {'V', {0x1f, 0x20, 0x40, 0x20, 0x1f}},
|
|
+ {'W', {0x3f, 0x40, 0x38, 0x40, 0x3f}}, {'X', {0x63, 0x14, 0x08, 0x14, 0x63}},
|
|
+ {'Y', {0x07, 0x08, 0x70, 0x08, 0x07}}, {'Z', {0x61, 0x51, 0x49, 0x45, 0x43}},
|
|
+ {'0', {0x3e, 0x51, 0x49, 0x45, 0x3e}}, {'1', {0x00, 0x42, 0x7f, 0x40, 0x00}},
|
|
+ {'2', {0x42, 0x61, 0x51, 0x49, 0x46}}, {'3', {0x21, 0x41, 0x45, 0x4b, 0x31}},
|
|
+ {'4', {0x18, 0x14, 0x12, 0x7f, 0x10}}, {'5', {0x27, 0x45, 0x45, 0x45, 0x39}},
|
|
+ {'6', {0x3c, 0x4a, 0x49, 0x49, 0x30}}, {'7', {0x01, 0x71, 0x09, 0x05, 0x03}},
|
|
+ {'8', {0x36, 0x49, 0x49, 0x49, 0x36}}, {'9', {0x06, 0x49, 0x49, 0x29, 0x1e}},
|
|
+ {'.', {0x00, 0x60, 0x60, 0x00, 0x00}}, {'-', {0x08, 0x08, 0x08, 0x08, 0x08}},
|
|
+ {'!', {0x00, 0x00, 0x5f, 0x00, 0x00}}, {' ', {0x00, 0x00, 0x00, 0x00, 0x00}},
|
|
+};
|
|
+
|
|
+static const unsigned char *splash_glyph(char ch)
|
|
+{
|
|
+ unsigned i;
|
|
+
|
|
+ for (i = 0; i < (sizeof(splash_font) / sizeof(splash_font[0])); i++)
|
|
+ if (splash_font[i].ch == ch)
|
|
+ return splash_font[i].col;
|
|
+ return splash_font[(sizeof(splash_font) / sizeof(splash_font[0])) - 1].col;
|
|
+}
|
|
+
|
|
+static void splash_pixel(struct fbcon_config *fb, int x, int y, uint16_t color)
|
|
+{
|
|
+ uint16_t *pixels = fb->base;
|
|
+
|
|
+ if (x < 0 || y < 0 || (unsigned)x >= fb->width || (unsigned)y >= fb->height)
|
|
+ return;
|
|
+ pixels[y * fb->stride + x] = color;
|
|
+}
|
|
+
|
|
+static void splash_rect(struct fbcon_config *fb, int x0, int y0,
|
|
+ int x1, int y1, uint16_t color)
|
|
+{
|
|
+ int x, y;
|
|
+
|
|
+ for (y = y0; y < y1; y++)
|
|
+ for (x = x0; x < x1; x++)
|
|
+ splash_pixel(fb, x, y, color);
|
|
}
|
|
|
|
+static void splash_disc(struct fbcon_config *fb, int cx, int cy,
|
|
+ int r, uint16_t color)
|
|
+{
|
|
+ int dx, dy;
|
|
+
|
|
+ for (dy = -r; dy <= r; dy++)
|
|
+ for (dx = -r; dx <= r; dx++)
|
|
+ if (dx * dx + dy * dy <= r * r)
|
|
+ splash_pixel(fb, cx + dx, cy + dy, color);
|
|
+}
|
|
+
|
|
+static void splash_text(struct fbcon_config *fb, const char *str, int x, int y,
|
|
+ int scale, uint16_t color)
|
|
+{
|
|
+ const unsigned char *cols;
|
|
+ int cy, i;
|
|
+
|
|
+ while (*str) {
|
|
+ cols = splash_glyph(*str++);
|
|
+ for (i = 0; i < 5; i++)
|
|
+ for (cy = 0; cy < 7; cy++)
|
|
+ if (cols[i] & (1u << cy))
|
|
+ splash_rect(fb, x + i * scale, y + cy * scale,
|
|
+ x + (i + 1) * scale, y + (cy + 1) * scale, color);
|
|
+ x += 6 * scale;
|
|
+ }
|
|
+}
|
|
+
|
|
+static void paint_boot_banner(struct fbcon_config *fb)
|
|
+{
|
|
+ unsigned x, y;
|
|
+
|
|
+ for (y = 0; y < fb->height; y++)
|
|
+ for (x = 0; x < fb->width; x++)
|
|
+ splash_pixel(fb, x, y, y < 26 ? SPLASH_BG2 : SPLASH_BG);
|
|
+
|
|
+ /* Banana crescent: a filled disc with an offset cut-out. */
|
|
+ splash_disc(fb, 120, 112, 54, SPLASH_YELLOW);
|
|
+ splash_disc(fb, 140, 90, 44, SPLASH_BG);
|
|
+ splash_disc(fb, 73, 157, 7, SPLASH_BROWN);
|
|
+ splash_disc(fb, 168, 150, 6, SPLASH_BROWN);
|
|
+
|
|
+ splash_text(fb, "BANANARCHY", 30, 206, 3, SPLASH_WHITE);
|
|
+ splash_text(fb, "LINUX", 90, 244, 2, SPLASH_BLUE);
|
|
+
|
|
+ /* Boot progress indicator (lk2nd is only the first stage). */
|
|
+ splash_rect(fb, 28, 280, 212, 293, SPLASH_BG2);
|
|
+ splash_rect(fb, 30, 282, 210, 291, SPLASH_GREY);
|
|
+ splash_rect(fb, 31, 283, 31 + (178 * 28) / 100, 290, SPLASH_YELLOW);
|
|
+ splash_text(fb, "BOOTING...", 90, 300, 1, SPLASH_GREY);
|
|
+}
|
|
+
|
|
+/**
|
|
+ * spi_display_setup() - Bring up the QUP SPI bus and the GC9305 main panel.
|
|
+ *
|
|
+ * Returns 0 on success. Every QUP wait is bounded (see spi_qup.c), so a
|
|
+ * missing clock or a dead panel can no longer wedge lk2nd before USB init.
|
|
+ */
|
|
+static int spi_display_setup(void)
|
|
+{
|
|
+ const unsigned char *init;
|
|
+ const char *panel_name = lk2nd_dev.panel.name;
|
|
+ const char *found_name = NULL;
|
|
+ int init_len = 0, ret;
|
|
+ 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. */
|
|
+ if(lk2nd_dev.compatible &&
|
|
+ !strcmp(lk2nd_dev.compatible, "nokia,beatles") &&
|
|
+ (!lk2nd_dev.panel.intf || strcmp(lk2nd_dev.panel.intf, "spi")))
|
|
+ lk2nd_dev.panel.intf = "spi";
|
|
+
|
|
+ if(!lk2nd_dev.panel.intf || strcmp(lk2nd_dev.panel.intf, "spi"))
|
|
+ return -1;
|
|
+
|
|
+ init = find_panel_init(lk2nd_dev.dtb, panel_name, &found_name, &init_len);
|
|
+ if(!panel_name && found_name) {
|
|
+ lk2nd_dev.panel.name = found_name;
|
|
+ fastboot_publish("lk2nd:panel", found_name);
|
|
+ panel_name = found_name;
|
|
+ dprintf(INFO, "SPI panel fallback from QCDT: %s\n", found_name);
|
|
+ }
|
|
+ have_init = init != NULL;
|
|
+
|
|
+ if(spi_ready) {
|
|
+ if(init && have_init) {
|
|
+ ret = mdss_spi_panel_init_commands(init, init_len);
|
|
+ if(ret)
|
|
+ dprintf(CRITICAL, "Failed to reinitialize SPI panel: %d\n", ret);
|
|
+ }
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ spi_fb.base = (void*)MIPI_FB_ADDR;
|
|
+ spi_fb.width = 240;
|
|
+ spi_fb.height = 320;
|
|
+ spi_fb.stride = spi_fb.width;
|
|
+ spi_fb.bpp = 16;
|
|
+ spi_fb.format = FB_FORMAT_RGB565;
|
|
+ spi_fb.update_start = NULL;
|
|
+
|
|
+ ret = mdss_spi_init();
|
|
+ if(ret) {
|
|
+ dprintf(CRITICAL, "Failed to initialize SPI bus: %d\n", ret);
|
|
+ /* Still register a RAM-only framebuffer so cont-splash does not try
|
|
+ * to read MDP registers, and so "oem screenshot" works. */
|
|
+ fbcon_setup(&spi_fb);
|
|
+ paint_boot_banner(&spi_fb);
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ if(have_init) {
|
|
+ ret = mdss_spi_panel_init_commands(init, init_len);
|
|
+ if(ret)
|
|
+ dprintf(CRITICAL, "Failed to initialize SPI panel: %d\n", ret);
|
|
+ else
|
|
+ dprintf(INFO, "Initialized SPI panel %s (%d bytes)\n",
|
|
+ lk2nd_dev.panel.name, init_len);
|
|
+ } else {
|
|
+ dprintf(INFO, "SPI panel %s: keeping aboot continuous splash\n",
|
|
+ lk2nd_dev.panel.name ? lk2nd_dev.panel.name : "unknown");
|
|
+ }
|
|
+
|
|
+ spi_fb.update_start = mdss_spi_flush;
|
|
+ fbcon_setup(&spi_fb);
|
|
+ paint_boot_banner(&spi_fb);
|
|
+ spi_ready = true;
|
|
+ dprintf(INFO, "SPI display ready\n");
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static void cmd_oem_display_init(const char *arg, void *data, unsigned sz)
|
|
+{
|
|
+ int ret = spi_display_setup();
|
|
+ if(ret) {
|
|
+ fastboot_fail("SPI display init failed (see oem log)");
|
|
+ return;
|
|
+ }
|
|
+ fbcon_flush();
|
|
+ fastboot_okay("");
|
|
+}
|
|
+FASTBOOT_REGISTER("oem display-init", cmd_oem_display_init);
|
|
+
|
|
+static void cmd_oem_display_test(const char *arg, void *data, unsigned sz)
|
|
+{
|
|
+ if(!spi_ready) {
|
|
+ int ret = spi_display_setup();
|
|
+ if(ret) {
|
|
+ fastboot_fail("SPI display init failed (see oem log)");
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ paint_boot_banner(&spi_fb);
|
|
+ fbcon_flush();
|
|
+ fastboot_okay("");
|
|
+}
|
|
+FASTBOOT_REGISTER("oem display-test", cmd_oem_display_test);
|
|
+
|
|
static void lk2nd_device2nd_init_spi_display(void)
|
|
{
|
|
- static struct fbcon_config fb;
|
|
- int ret;
|
|
-
|
|
- if (strcmp(lk2nd_dev.panel.intf, "spi"))
|
|
- return;
|
|
-
|
|
- if (!lk2nd_dev.panel.initialized) {
|
|
- dprintf(CRITICAL, "SPI display not initialized by previous bootloader\n");
|
|
- return;
|
|
- }
|
|
-
|
|
- /*
|
|
- * FIXME: For now we assume that all devices with SPI display use the
|
|
- * same configuration, since this is mainly used by feature phones with
|
|
- * similar display panel configurations. This might need additional
|
|
- * configuration (e.g. via the device tree) in the future.
|
|
- */
|
|
- fb.base = (void*)MIPI_FB_ADDR;
|
|
- fb.width = 240;
|
|
- fb.height = 320;
|
|
- fb.stride = fb.width;
|
|
- fb.bpp = 16;
|
|
- fb.format = FB_FORMAT_RGB565;
|
|
- fb.update_start = mdss_spi_flush;
|
|
-
|
|
- ret = mdss_spi_init();
|
|
- if (ret) {
|
|
- dprintf(CRITICAL, "Failed to initialize SPI bus: %d\n", ret);
|
|
- return;
|
|
- }
|
|
-
|
|
- fbcon_setup(&fb);
|
|
+ if(cmdline_flag("lk2nd.no-display")) {
|
|
+ /* Proven-safe default: RAM-only framebuffer, never touch QUP SPI before
|
|
+ * USB/fastboot is up. "fastboot oem display-init" enables the panel at
|
|
+ * runtime. Pass lk2nd.display=on to enable it during boot instead. */
|
|
+ if(!lk2nd_dev.panel.intf || strcmp(lk2nd_dev.panel.intf, "spi"))
|
|
+ return;
|
|
+ spi_fb.base = (void*)MIPI_FB_ADDR;
|
|
+ spi_fb.width = 240;
|
|
+ spi_fb.height = 320;
|
|
+ spi_fb.stride = spi_fb.width;
|
|
+ spi_fb.bpp = 16;
|
|
+ spi_fb.format = FB_FORMAT_RGB565;
|
|
+ spi_fb.update_start = NULL;
|
|
+ fbcon_setup(&spi_fb);
|
|
+ dprintf(INFO, "SPI display disabled by lk2nd.no-display (RAM-only fbcon)\n");
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ if(cmdline_flag("lk2nd.display=on")) {
|
|
+ int ret = spi_display_setup();
|
|
+ if(ret)
|
|
+ dprintf(CRITICAL, "SPI display unavailable: %d\n", ret);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ /* Default: RAM-only framebuffer so the bootloader is never wedged by SPI. */
|
|
+ if(!lk2nd_dev.panel.intf || strcmp(lk2nd_dev.panel.intf, "spi"))
|
|
+ return;
|
|
+ spi_fb.base = (void*)MIPI_FB_ADDR;
|
|
+ spi_fb.width = 240;
|
|
+ spi_fb.height = 320;
|
|
+ spi_fb.stride = spi_fb.width;
|
|
+ spi_fb.bpp = 16;
|
|
+ spi_fb.format = FB_FORMAT_RGB565;
|
|
+ spi_fb.update_start = NULL;
|
|
+ fbcon_setup(&spi_fb);
|
|
+ dprintf(INFO, "SPI display in probe mode (use oem display-init)\n");
|
|
}
|
|
LK2ND_INIT(lk2nd_device2nd_init_spi_display);
|
|
diff --git a/lk2nd/device/dts/lk2nd.dtsi b/lk2nd/device/dts/lk2nd.dtsi
|
|
index 7b81484..84b2d81 100644
|
|
--- a/lk2nd/device/dts/lk2nd.dtsi
|
|
+++ b/lk2nd/device/dts/lk2nd.dtsi
|
|
@@ -15,6 +15,46 @@
|
|
|
|
lk2nd: lk2nd { };
|
|
|
|
+ /*
|
|
+ * The 2720's MSM8905 is a partial-goods (2-core) part. Its stock aboot
|
|
+ * calls update_partial_goods_dtb_nodes() on the QCDT-selected DTB and
|
|
+ * ASSERTs if /cpus, /cpus/cpu@2 or /cpus/cpu@3 (with device_type) is
|
|
+ * missing: "Failed to get parent node: /cpus" then
|
|
+ * "panic: ASSERT FAILED at (platform/msm_shared/partial_goods.c:80): 0".
|
|
+ * Upstream lk2nd DTBs have no /cpus, so every lk2nd image crashed into
|
|
+ * Sahara memory-debug EDL before lk2nd ever ran. device_type must be
|
|
+ * exactly 4 bytes ("cpu\0") because aboot overwrites it with "nak\0".
|
|
+ * Keep this in the common dtsi so aboot cannot pick a DTB without it.
|
|
+ */
|
|
+ cpus {
|
|
+ #address-cells = <1>;
|
|
+ #size-cells = <0>;
|
|
+
|
|
+ cpu@0 {
|
|
+ device_type = "cpu";
|
|
+ compatible = "arm,cortex-a7";
|
|
+ reg = <0>;
|
|
+ };
|
|
+
|
|
+ cpu@1 {
|
|
+ device_type = "cpu";
|
|
+ compatible = "arm,cortex-a7";
|
|
+ reg = <1>;
|
|
+ };
|
|
+
|
|
+ cpu@2 {
|
|
+ device_type = "cpu";
|
|
+ compatible = "arm,cortex-a7";
|
|
+ reg = <2>;
|
|
+ };
|
|
+
|
|
+ cpu@3 {
|
|
+ device_type = "cpu";
|
|
+ compatible = "arm,cortex-a7";
|
|
+ reg = <3>;
|
|
+ };
|
|
+ };
|
|
+
|
|
lk2nd-hw {
|
|
/omit-if-no-ref/ tlmm: gpio-tlmm {
|
|
compatible = "lk2nd,gpio";
|
|
diff --git a/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts b/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts
|
|
index 40fa170..0bd2846 100644
|
|
--- a/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts
|
|
+++ b/lk2nd/device/dts/msm8909/msm8905-qrd-skub.dts
|
|
@@ -5,8 +5,11 @@
|
|
|
|
/ {
|
|
qcom,msm-id = <QCOM_ID_MSM8905 0>;
|
|
- qcom,board-id = <QCOM_BOARD_ID_QRD 0x100>,
|
|
- <QCOM_BOARD_ID(QRD, 1, 0) 0x100>;
|
|
+ /* Keep BOTH stock pairs in upstream order. aboot re-validates the first
|
|
+ qcom,board-id pair of the selected DTB; changing this crashed it. */
|
|
+ qcom,board-id = <QCOM_BOARD_ID_QRD 0x100>,
|
|
+ <QCOM_BOARD_ID(QRD, 1, 0) 0x100>;
|
|
+
|
|
};
|
|
|
|
&lk2nd {
|
|
@@ -63,3 +66,5 @@
|
|
};
|
|
};
|
|
};
|
|
+
|
|
+#include "nokia-beatles.dtsi"
|
|
diff --git a/lk2nd/device/dts/msm8909/nokia-beatles.dtsi b/lk2nd/device/dts/msm8909/nokia-beatles.dtsi
|
|
new file mode 100644
|
|
index 0000000..dab182c
|
|
--- /dev/null
|
|
+++ b/lk2nd/device/dts/msm8909/nokia-beatles.dtsi
|
|
@@ -0,0 +1,55 @@
|
|
+// SPDX-License-Identifier: BSD-3-Clause
|
|
+/*
|
|
+ * Nokia 2720 Flip (nokia-beatles) lk2nd device node.
|
|
+ *
|
|
+ * The 2720 shares the MSM8905 QRD SKUB board with the CAT B35 and the
|
|
+ * Nokia 8110 4G, so the same QCDT image is used for all three. The stock
|
|
+ * aboot reports one of three GC9305-family SPI main panels in
|
|
+ * mdss_mdp3.panel=; all of them are 240x320 RGB565 command-mode panels on
|
|
+ * BLSP1 QUP5 with DC on GPIO 110.
|
|
+ *
|
|
+ * lk2nd,panel-init holds the downstream KaiOS 3.10 qcom,mdss-spi-on-command
|
|
+ * byte stream in its native [wait dlen payload...] format. lk2nd replays it
|
|
+ * after taking over the SPI bus so the address window and pixel format are
|
|
+ * correct even when aboot left the bus pointed at the 240x240 cover panel.
|
|
+ */
|
|
+
|
|
+&lk2nd {
|
|
+ nokia-beatles {
|
|
+ model = "Nokia 2720 Flip";
|
|
+ compatible = "nokia,beatles";
|
|
+ lk2nd,match-panel;
|
|
+ lk2nd,dtb-files = "msm8905-nokia-beatles";
|
|
+
|
|
+ panel {
|
|
+ compatible = "nokia,beatles-panel";
|
|
+
|
|
+ /* "first" source: aboot owns its init, lk2nd only matches the name */
|
|
+ qcom,mdss_spi_gc9305_qvga_cmd {
|
|
+ compatible = "nokia,beatles-gc9305-panel";
|
|
+ };
|
|
+
|
|
+ /* GC9305 v2 main panel (qcom,spi-pref-prim-pan) */
|
|
+ qcom,mdss_spi_gc9305_v2_qvga_cmd {
|
|
+ compatible = "nokia,beatles-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
|
|
+ ];
|
|
+ };
|
|
+
|
|
+ /* 3rd source: aboot owns its init, lk2nd only matches the name */
|
|
+ qcom,mdss_spi_gc9305_3rd_qvga_cmd {
|
|
+ compatible = "nokia,beatles-gc9305-3rd-panel";
|
|
+ };
|
|
+ };
|
|
+ };
|
|
+};
|
|
diff --git a/lk2nd/device/menu/menu.c b/lk2nd/device/menu/menu.c
|
|
index 28ab377..ac8b641 100644
|
|
--- a/lk2nd/device/menu/menu.c
|
|
+++ b/lk2nd/device/menu/menu.c
|
|
@@ -14,7 +14,6 @@
|
|
|
|
#include <lk2nd/device/keys.h>
|
|
#include <lk2nd/util/minmax.h>
|
|
-#include <lk2nd/version.h>
|
|
|
|
#include "../device.h"
|
|
|
|
@@ -191,7 +190,6 @@ void display_fastboot_menu(void)
|
|
scale_factor = old_scale;
|
|
incr = FONT_HEIGHT * scale_factor;
|
|
|
|
- fbcon_puts_ln(SILVER, y, incr, true, LK2ND_VERSION);
|
|
if (lk2nd_dev.model)
|
|
fbcon_puts_ln(SILVER, y, incr, true, lk2nd_dev.model);
|
|
else
|
|
@@ -287,19 +285,10 @@ void display_fastboot_menu(void)
|
|
void display_default_image_on_screen(void);
|
|
void display_default_image_on_screen(void)
|
|
{
|
|
- struct fbcon_config *fb = fbcon_display();
|
|
- int y, incr;
|
|
-
|
|
- /*
|
|
- * Make sure the specified line lenght fits on the screen.
|
|
- */
|
|
- scale_factor = max(1U, min(fb->width, fb->height) / (FONT_WIDTH * MIN_LINE));
|
|
- incr = FONT_HEIGHT * scale_factor;
|
|
- y = fb->height - 3 * incr;
|
|
-
|
|
- fbcon_clear_msg(y / FONT_HEIGHT, y / FONT_HEIGHT + 3 * scale_factor);
|
|
+ if (!fbcon_display())
|
|
+ return;
|
|
|
|
- fbcon_puts_ln(WHITE, y, incr, true, xstr(BOARD));
|
|
- fbcon_puts_ln(SILVER, y, incr, true, LK2ND_VERSION);
|
|
+ /* Flush the branded Bananarchy splash painted by spi_display_setup()
|
|
+ * intact without overwriting its bottom strip with BOARD/version. */
|
|
fbcon_flush();
|
|
}
|
|
diff --git a/lk2nd/fastboot/fetch.c b/lk2nd/fastboot/fetch.c
|
|
index a60173f..b961995 100644
|
|
--- a/lk2nd/fastboot/fetch.c
|
|
+++ b/lk2nd/fastboot/fetch.c
|
|
@@ -7,6 +7,7 @@
|
|
#include <dev/flash.h>
|
|
#include <fastboot.h>
|
|
#include <lib/ptable.h>
|
|
+#include <mmc_wrapper.h>
|
|
#include <partition_parser.h>
|
|
#include <target.h>
|
|
|
|
@@ -51,22 +52,43 @@ static bool cmd_fetch_parse_args(uint64_t *offset, uint64_t *size, char **sp)
|
|
|
|
static unsigned cmd_fetch_read_mmc(const char *pname, void *data, char **sp)
|
|
{
|
|
- struct partition_info part = partition_get_info(pname);
|
|
-
|
|
- if (!part.offset) {
|
|
- fastboot_fail("partition not found");
|
|
- return 0;
|
|
- }
|
|
-
|
|
- if (!cmd_fetch_parse_args(&part.offset, &part.size, sp))
|
|
- return 0;
|
|
-
|
|
- if (mmc_read(part.offset, data, part.size)) {
|
|
- fastboot_fail("failed to read partition");
|
|
- return 0;
|
|
- }
|
|
-
|
|
- return part.size;
|
|
+ struct partition_info part = partition_get_info(pname);
|
|
+ uint64_t base_offset, total_size;
|
|
+ uint32_t block_size, read_size;
|
|
+
|
|
+ if(!part.offset) {
|
|
+ fastboot_fail("partition not found");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ base_offset = part.offset;
|
|
+ total_size = part.size;
|
|
+ if(!cmd_fetch_parse_args(&part.offset, &part.size, sp))
|
|
+ return 0;
|
|
+
|
|
+ block_size = mmc_get_device_blocksize();
|
|
+ if(!block_size || (block_size & (block_size - 1))) {
|
|
+ fastboot_fail("invalid MMC block size");
|
|
+ return 0;
|
|
+ }
|
|
+ if(part.offset % block_size) {
|
|
+ fastboot_fail("offset is not block-aligned");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ read_size = (uint32_t)ROUNDUP(part.size, block_size);
|
|
+ if(read_size > target_get_max_flash_size() ||
|
|
+ (uint64_t)part.offset + read_size > base_offset + total_size) {
|
|
+ fastboot_fail("aligned read exceeds partition");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ if(mmc_read(part.offset, data, read_size)) {
|
|
+ fastboot_fail("failed to read partition");
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ return part.size;
|
|
}
|
|
|
|
static unsigned cmd_fetch_read_flash(const char *pname, void *data, char **sp)
|
|
diff --git a/lk2nd/include/lk2nd/spi-panel-init.h b/lk2nd/include/lk2nd/spi-panel-init.h
|
|
new file mode 100644
|
|
index 0000000..440f0ed
|
|
--- /dev/null
|
|
+++ b/lk2nd/include/lk2nd/spi-panel-init.h
|
|
@@ -0,0 +1,53 @@
|
|
+// SPDX-License-Identifier: BSD-3-Clause
|
|
+#ifndef LK2ND_SPI_PANEL_INIT_H
|
|
+#define LK2ND_SPI_PANEL_INIT_H
|
|
+
|
|
+/*
|
|
+ * Walk a downstream qcom,mdss-spi-on-command byte stream.
|
|
+ *
|
|
+ * Every command is [wait_ms, dlen, payload[dlen]]. The first payload byte is
|
|
+ * the command (DC low), the rest are parameters (DC high), and wait_ms is
|
|
+ * applied after the command. This matches the KaiOS 3.10 mdss_spi_panel_on()
|
|
+ * implementation (struct spi_ctrl_hdr { char wait; char dlen; }).
|
|
+ *
|
|
+ * Returns 0 on success, a negative value on a malformed stream or a write
|
|
+ * error. The callbacks make this usable by both the target SPI driver and a
|
|
+ * host unit test.
|
|
+ */
|
|
+struct lk2nd_spi_panel_init_ops {
|
|
+ int (*write_cmd)(const unsigned char *cmd);
|
|
+ int (*write_data)(const unsigned char *data, unsigned int len);
|
|
+ void (*delay)(unsigned int ms);
|
|
+};
|
|
+
|
|
+static inline int lk2nd_spi_panel_init_run(const unsigned char *cmds,
|
|
+ unsigned int len, const struct lk2nd_spi_panel_init_ops *ops)
|
|
+{
|
|
+ unsigned int off = 0, size;
|
|
+ unsigned char wait;
|
|
+ int ret;
|
|
+
|
|
+ while(off + 2 <= len) {
|
|
+ wait = cmds[off++];
|
|
+ size = cmds[off++];
|
|
+ if(!size || off + size > len)
|
|
+ return -1;
|
|
+
|
|
+ ret = ops->write_cmd(cmds + off);
|
|
+ if(ret)
|
|
+ return ret;
|
|
+ if(size > 1) {
|
|
+ ret = ops->write_data(cmds + off + 1, size - 1);
|
|
+ if(ret)
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ off += size;
|
|
+ if(wait)
|
|
+ ops->delay(wait);
|
|
+ }
|
|
+
|
|
+ return off == len ? 0 : -1;
|
|
+}
|
|
+
|
|
+#endif /* LK2ND_SPI_PANEL_INIT_H */
|
|
diff --git a/lk2nd/ramoops/ramoops.c b/lk2nd/ramoops/ramoops.c
|
|
index 39cee71..fdaac26 100644
|
|
--- a/lk2nd/ramoops/ramoops.c
|
|
+++ b/lk2nd/ramoops/ramoops.c
|
|
@@ -6,6 +6,7 @@
|
|
#include <debug.h>
|
|
#include <fastboot.h>
|
|
#include <libfdt.h>
|
|
+#include <stdlib.h>
|
|
#include <target.h>
|
|
#include <zlib.h>
|
|
|
|
@@ -57,13 +58,19 @@ static int lk2nd_ramoops_dt_update(void *dtb, const char *cmdline, enum boot_typ
|
|
{
|
|
int ret, rmem_offset, offset;
|
|
struct ramoops_region region;
|
|
- char tmp[32], args[16];
|
|
+ char tmp[32], args[16] = "";
|
|
|
|
if (boot_type & (BOOT_DOWNSTREAM | BOOT_LK2ND))
|
|
return 0;
|
|
|
|
- if (!lk2nd_cmdline_scan_arg(cmdline, "lk2nd.pass-ramoops", args, sizeof(args)))
|
|
- return 0;
|
|
+ /*
|
|
+ * Bananarchy: always pass ramoops on Linux boots. A kernel that hangs
|
|
+ * before userspace (no usb0 RNDIS) is otherwise completely silent;
|
|
+ * with this node its console survives a warm reset and can be read
|
|
+ * with "fastboot oem ramoops console". lk2nd.pass-ramoops=zap still
|
|
+ * clears the region.
|
|
+ */
|
|
+ lk2nd_cmdline_scan_arg(cmdline, "lk2nd.pass-ramoops", args, sizeof(args));
|
|
|
|
get_ramoops_region(®ion);
|
|
|
|
@@ -187,45 +194,90 @@ static void cmd_oem_ramoops_regions(const char *arg, void *data, unsigned sz)
|
|
}
|
|
FASTBOOT_REGISTER("oem ramoops regions", cmd_oem_ramoops_regions);
|
|
|
|
-static void cmd_oem_ramoops_console(const char *arg, void *data, unsigned sz)
|
|
+static int ramoops_console_record_valid(const struct ramoops_region *region,
|
|
+ const struct pram_buf *record)
|
|
{
|
|
- struct ramoops_region region;
|
|
- struct pram_buf *record;
|
|
- uint8_t *record_base;
|
|
+ size_t data_size = region->console_size - sizeof(*record);
|
|
|
|
- get_ramoops_region(®ion);
|
|
-
|
|
- record_base = region.base + region.dump_size;
|
|
- record = (struct pram_buf*)record_base;
|
|
+ return region->console_size > sizeof(*record) &&
|
|
+ record->sig == PERSISTENT_RAM_SIG &&
|
|
+ record->size <= data_size &&
|
|
+ record->offt <= data_size;
|
|
+}
|
|
|
|
- fastboot_stage(record->data, record->size);
|
|
+static void cmd_oem_ramoops_console(const char *arg, void *data, unsigned sz)
|
|
+{
|
|
+ struct ramoops_region region;
|
|
+ struct pram_buf *record;
|
|
+ size_t data_size, size, start, tail;
|
|
+ uint8_t *record_base, *buf;
|
|
+
|
|
+ get_ramoops_region(®ion);
|
|
+
|
|
+ record_base = region.base + region.dump_size;
|
|
+ record = (struct pram_buf*)record_base;
|
|
+ data_size = region.console_size - sizeof(*record);
|
|
+
|
|
+ if(!ramoops_console_record_valid(®ion, record) || !record->size) {
|
|
+ fastboot_fail("No valid pstore console");
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ size = record->size;
|
|
+ buf = malloc(size);
|
|
+ if(!buf) {
|
|
+ fastboot_fail("Cannot allocate console buffer");
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ start = record->offt % data_size;
|
|
+ if(size == data_size && start) {
|
|
+ tail = data_size - start;
|
|
+ memcpy(buf, record->data + start, tail);
|
|
+ memcpy(buf + tail, record->data, size - tail);
|
|
+ } else {
|
|
+ memcpy(buf, record->data, size);
|
|
+ }
|
|
+
|
|
+ fastboot_stage(buf, size);
|
|
+ free(buf);
|
|
}
|
|
FASTBOOT_REGISTER("oem ramoops console", cmd_oem_ramoops_console);
|
|
|
|
static void cmd_oem_ramoops_dump(const char *arg, void *data, unsigned sz)
|
|
{
|
|
- unsigned long size = target_get_max_flash_size();
|
|
- void *scratch = target_get_scratch_address();
|
|
- struct ramoops_region region;
|
|
- char response[MAX_RSP_SIZE];
|
|
- struct pram_buf *record;
|
|
- struct kmsg_hdr *header;
|
|
- uint8_t *record_base;
|
|
- int ret;
|
|
-
|
|
- get_ramoops_region(®ion);
|
|
-
|
|
- record_base = region.base;
|
|
- record = (struct pram_buf*)record_base;
|
|
- header = (struct kmsg_hdr*)record->data;
|
|
-
|
|
- /*
|
|
- * FIXME: this is pretty much useless right now.
|
|
- * 1) This only checks the first record, not all of them.
|
|
- * 2) This can't really work without ECC...
|
|
- */
|
|
-
|
|
- memset(scratch, 0, record->size);
|
|
+ unsigned long size = target_get_max_flash_size();
|
|
+ void *scratch = target_get_scratch_address();
|
|
+ struct ramoops_region region;
|
|
+ char response[MAX_RSP_SIZE];
|
|
+ struct pram_buf *record;
|
|
+ struct kmsg_hdr *header;
|
|
+ uint8_t *record_base;
|
|
+ size_t data_size;
|
|
+ int ret;
|
|
+
|
|
+ get_ramoops_region(®ion);
|
|
+
|
|
+ record_base = region.base;
|
|
+ record = (struct pram_buf*)record_base;
|
|
+ data_size = region.record_size - sizeof(*record);
|
|
+
|
|
+ if(record->sig != PERSISTENT_RAM_SIG ||
|
|
+ record->size <= sizeof(struct kmsg_hdr) ||
|
|
+ record->size > data_size) {
|
|
+ fastboot_fail("No valid pstore dump");
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ header = (struct kmsg_hdr*)record->data;
|
|
+
|
|
+ /*
|
|
+ * FIXME: this is pretty much useless right now.
|
|
+ * 1) This only checks the first record, not all of them.
|
|
+ * 2) This can't really work without ECC...
|
|
+ */
|
|
+
|
|
+ memset(scratch, 0, record->size);
|
|
|
|
if (header->magic != RAMOOPS_KERNMSG_HDR)
|
|
fastboot_fail("Dump corrupted.");
|
|
diff --git a/platform/msm_shared/clock_lib2.c b/platform/msm_shared/clock_lib2.c
|
|
index 50042f2..2e76d17 100644
|
|
--- a/platform/msm_shared/clock_lib2.c
|
|
+++ b/platform/msm_shared/clock_lib2.c
|
|
@@ -34,6 +34,9 @@
|
|
#include <clock_lib2.h>
|
|
#include <platform/timer.h>
|
|
|
|
+/* Bounded register polls: a stuck clock must never wedge the bootloader. */
|
|
+#define CLK_POLL_TIMEOUT 0x40000
|
|
+
|
|
/*=============== CXO clock ops =============*/
|
|
int cxo_clk_enable(struct clk *clk)
|
|
{
|
|
@@ -89,6 +92,7 @@ int clock_lib2_branch_clk_enable(struct clk *clk)
|
|
void clock_lib2_branch_clk_disable(struct clk *clk)
|
|
{
|
|
uint32_t cbcr_val;
|
|
+ unsigned int retry = CLK_POLL_TIMEOUT;
|
|
struct branch_clk *bclk = to_branch_clk(clk);
|
|
|
|
cbcr_val = readl(bclk->cbcr_reg);
|
|
@@ -97,7 +101,7 @@ void clock_lib2_branch_clk_disable(struct clk *clk)
|
|
|
|
if (!bclk->no_halt_check_on_disable)
|
|
/* wait until status shows it is disabled */
|
|
- while(!(readl(bclk->cbcr_reg) & CBCR_BRANCH_OFF_BIT));
|
|
+ while(!(readl(bclk->cbcr_reg) & CBCR_BRANCH_OFF_BIT) && --retry);
|
|
}
|
|
|
|
/* Branch clock set rate */
|
|
@@ -171,7 +175,8 @@ static void clock_lib2_rcg_update_config(struct rcg_clk *rclk)
|
|
writel(cmd, rclk->cmd_reg);
|
|
|
|
/* Wait for frequency to be updated. */
|
|
- while(readl(rclk->cmd_reg) & CMD_UPDATE_MASK);
|
|
+ unsigned int retry = CLK_POLL_TIMEOUT;
|
|
+ while((readl(rclk->cmd_reg) & CMD_UPDATE_MASK) && --retry);
|
|
}
|
|
|
|
/* root set rate for clocks with half integer and MND divider */
|
|
@@ -219,6 +224,7 @@ int clock_lib2_vote_clk_enable(struct clk *c)
|
|
{
|
|
uint32_t vote_regval;
|
|
uint32_t val;
|
|
+ unsigned int retry = CLK_POLL_TIMEOUT;
|
|
struct vote_clk *vclk = to_local_vote_clk(c);
|
|
|
|
vote_regval = readl(vclk->vote_reg);
|
|
@@ -227,9 +233,8 @@ int clock_lib2_vote_clk_enable(struct clk *c)
|
|
do {
|
|
val = readl(vclk->cbcr_reg);
|
|
val &= BRANCH_CHECK_MASK;
|
|
- }
|
|
- /* wait until status shows it is enabled */
|
|
- while((val != BRANCH_ON_VAL) && (val != BRANCH_NOC_FSM_ON_VAL));
|
|
+ } while ((val != BRANCH_ON_VAL) &&
|
|
+ (val != BRANCH_NOC_FSM_ON_VAL) && --retry);
|
|
|
|
return 0;
|
|
}
|
|
diff --git a/platform/msm_shared/include/mdss_spi.h b/platform/msm_shared/include/mdss_spi.h
|
|
index 87f062b..5c39c7b 100644
|
|
--- a/platform/msm_shared/include/mdss_spi.h
|
|
+++ b/platform/msm_shared/include/mdss_spi.h
|
|
@@ -31,6 +31,7 @@
|
|
|
|
#ifdef DISPLAY_TYPE_SPI_SUPPORT
|
|
int spi_check_panel_id(struct msm_panel_info *pinfo);
|
|
+int mdss_spi_panel_init_commands(const unsigned char *cmds, unsigned int len);
|
|
#else
|
|
static inline int spi_check_panel_id(struct msm_panel_info *pinfo)
|
|
{
|
|
diff --git a/platform/msm_shared/mdss_spi.c b/platform/msm_shared/mdss_spi.c
|
|
index 4c5fd98..649fa77 100644
|
|
--- a/platform/msm_shared/mdss_spi.c
|
|
+++ b/platform/msm_shared/mdss_spi.c
|
|
@@ -27,7 +27,9 @@
|
|
*
|
|
*/
|
|
|
|
+#include <err.h>
|
|
#include <spi_qup.h>
|
|
+#include <lk2nd/spi-panel-init.h>
|
|
#include <msm_panel.h>
|
|
#include <target/display.h>
|
|
#include <platform/gpio.h>
|
|
@@ -201,6 +203,40 @@ int mdss_spi_panel_init(struct msm_panel_info *pinfo)
|
|
return SUCCESS;
|
|
}
|
|
|
|
+/**
|
|
+ * mdss_spi_panel_init_commands() - Replay a downstream SPI panel init stream.
|
|
+ */
|
|
+static int panel_init_write_cmd(const unsigned char *cmd)
|
|
+{
|
|
+ return mdss_spi_write_cmd(cmd);
|
|
+}
|
|
+
|
|
+static int panel_init_write_data(const unsigned char *data, unsigned int len)
|
|
+{
|
|
+ return mdss_spi_write_data(data, len);
|
|
+}
|
|
+
|
|
+static void panel_init_delay(unsigned int ms)
|
|
+{
|
|
+ mdelay(ms);
|
|
+}
|
|
+
|
|
+int mdss_spi_panel_init_commands(const unsigned char *cmds, unsigned int len)
|
|
+{
|
|
+ static const struct lk2nd_spi_panel_init_ops ops = {
|
|
+ .write_cmd = panel_init_write_cmd,
|
|
+ .write_data = panel_init_write_data,
|
|
+ .delay = panel_init_delay,
|
|
+ };
|
|
+
|
|
+ if(!dev) {
|
|
+ dprintf(CRITICAL, "SPI has not been initialized\n");
|
|
+ return -ENODEV;
|
|
+ }
|
|
+
|
|
+ return lk2nd_spi_panel_init_run(cmds, len, &ops);
|
|
+}
|
|
+
|
|
int mdss_spi_on(struct msm_panel_info *pinfo, struct fbcon_config *fb)
|
|
{
|
|
int buf_size = 0;
|
|
diff --git a/platform/msm_shared/reboot.c b/platform/msm_shared/reboot.c
|
|
index 171eef8..1c939a7 100644
|
|
--- a/platform/msm_shared/reboot.c
|
|
+++ b/platform/msm_shared/reboot.c
|
|
@@ -83,16 +83,21 @@ unsigned check_reboot_mode(void)
|
|
|
|
unsigned check_hard_reboot_mode(void)
|
|
{
|
|
- uint8_t hard_restart_reason = 0;
|
|
-
|
|
- /* Read reboot reason and scrub it
|
|
- * Bit-2 to bit-7 of SOFT_RB_SPARE for hard reset reason
|
|
- */
|
|
- hard_restart_reason = REG_READ(PON_SOFT_RB_SPARE);
|
|
- REG_WRITE(PON_SOFT_RB_SPARE, hard_restart_reason & 0x03);
|
|
-
|
|
- /* Extract the bits 2 to 7 and return */
|
|
- return (hard_restart_reason & 0xFC) >> 2;
|
|
+ uint8_t hard_restart_reason = 0;
|
|
+ unsigned int high_bits;
|
|
+ unsigned int low_bits;
|
|
+
|
|
+ /*
|
|
+ * The stock beatles boot chain scrubs PON_SOFT_RB_SPARE[7:2] and
|
|
+ * passes bits [1:0] through to the chain-loaded lk2nd image. Prefer
|
|
+ * those low bits but still accept the upstream high-bit cookie from
|
|
+ * "fastboot reboot-bootloader".
|
|
+ */
|
|
+ hard_restart_reason = REG_READ(PON_SOFT_RB_SPARE);
|
|
+ low_bits = hard_restart_reason & 0x03;
|
|
+ high_bits = (hard_restart_reason & 0xFC) >> 2;
|
|
+ REG_WRITE(PON_SOFT_RB_SPARE, low_bits);
|
|
+ return low_bits ? low_bits : high_bits;
|
|
}
|
|
|
|
/* Return true if it is triggered by alarm. */
|
|
@@ -126,9 +131,14 @@ void reboot_device(unsigned reboot_reason)
|
|
|
|
if (reboot_reason != NORMAL_DLOAD && reboot_reason != EMERGENCY_DLOAD) {
|
|
#if USE_PON_REBOOT_REG
|
|
- value = REG_READ(PON_SOFT_RB_SPARE);
|
|
- value |= (reboot_reason << 2);
|
|
- REG_WRITE(PON_SOFT_RB_SPARE, value);
|
|
+ value = REG_READ(PON_SOFT_RB_SPARE);
|
|
+ if(reboot_reason <= 0x03) {
|
|
+ dprintf(INFO, "beatles low-bit reboot cookie: 0x%02x\n", reboot_reason);
|
|
+ value = (uint8_t)reboot_reason;
|
|
+ } else {
|
|
+ value |= (reboot_reason << 2);
|
|
+ }
|
|
+ REG_WRITE(PON_SOFT_RB_SPARE, value);
|
|
#else
|
|
writel(reboot_reason, RESTART_REASON_ADDR);
|
|
#endif
|
|
diff --git a/platform/msm_shared/spi_qup.c b/platform/msm_shared/spi_qup.c
|
|
index d7bab01..eb958f0 100644
|
|
--- a/platform/msm_shared/spi_qup.c
|
|
+++ b/platform/msm_shared/spi_qup.c
|
|
@@ -46,6 +46,9 @@
|
|
#include <platform/timer.h>
|
|
#include <platform/interrupts.h>
|
|
|
|
+/* Bounded wait: a QUP with no clock must never wedge the bootloader. */
|
|
+#define QUP_FIFO_TIMEOUT 0x40000
|
|
+
|
|
//#define DEBUGLEVEL 3
|
|
|
|
static unsigned int spi_get_qup_hw_ver(struct qup_spi_dev *dev)
|
|
@@ -273,13 +276,13 @@ static void spi_qup_fifo_write(struct qup_spi_dev *dev, struct spi_transfer *xfe
|
|
while (dev->tx_bytes < xfer->len) {
|
|
|
|
state = readl_relaxed(dev->qup_base + QUP_OPERATIONAL);
|
|
- if (state & QUP_OP_OUT_FIFO_FULL)
|
|
- {
|
|
- dprintf(SPEW, "%s: oper QUP_OP_OUT_FIFO_FULL: 0x%x"
|
|
- "dev->tx_bytes:0x%x, xfer->len:0x%x\n",
|
|
- __func__, state, dev->tx_bytes, xfer->len);
|
|
- break;
|
|
- }
|
|
+ if(state & QUP_OP_OUT_FIFO_FULL)
|
|
+ {
|
|
+ /* Upstream's per-word SPEW log saturates the 32 KiB log and makes a
|
|
+ * full frame take about 40 s on DEBUG=2 builds. The bounded timeout
|
|
+ * in _spi_qup_transfer() is the only diagnostic needed here. */
|
|
+ break;
|
|
+ }
|
|
|
|
word = 0;
|
|
for (idx = 0; idx < dev->bytes_per_word; idx++, dev->tx_bytes++) {
|
|
@@ -344,6 +347,7 @@ static int _spi_qup_transfer(struct qup_spi_dev *dev, struct spi_transfer *xfer)
|
|
{
|
|
int ret = -EIO;
|
|
int retries = 0xFF;
|
|
+ unsigned int fifo_retries;
|
|
unsigned val;
|
|
unsigned int register_cnt;
|
|
unsigned int register_cnt_cur;
|
|
@@ -371,7 +375,13 @@ static int _spi_qup_transfer(struct qup_spi_dev *dev, struct spi_transfer *xfer)
|
|
|
|
while((readl(register_cnt) != readl(register_cnt_cur)) && retries--);
|
|
if (xfer->tx_buf) {
|
|
+ fifo_retries = QUP_FIFO_TIMEOUT;
|
|
while(readl(register_cnt_cur)) {
|
|
+ if (!--fifo_retries) {
|
|
+ dprintf(CRITICAL, "%s: QUP output FIFO timeout\n", __func__);
|
|
+ ret = -ETIMEDOUT;
|
|
+ goto exit;
|
|
+ }
|
|
val = readl(dev->qup_base + QUP_OPERATIONAL);
|
|
val &= ~QUP_OP_OUT_SERVICE_FLAG;
|
|
writel(val, dev->qup_base + QUP_OPERATIONAL);
|