From 4d9be0bc55695cd06f8d6150d2c2fc0fa19e5fd0 Mon Sep 17 00:00:00 2001 From: Igor Belwon Date: Sat, 23 Aug 2025 19:23:23 +0200 Subject: [PATCH] board: Add support for the CMF Phone (1) This device has a broken framebuffer. As such, logs are passed via UART. Signed-off-by: Igor Belwon --- board/Kconfig | 19 +++++++++ board/Makefile | 1 + board/nothing/board-tetris.c | 80 ++++++++++++++++++++++++++++++++++++ configs/tetris_defconfig | 11 +++++ 4 files changed, 111 insertions(+) create mode 100644 board/nothing/board-tetris.c create mode 100644 configs/tetris_defconfig diff --git a/board/Kconfig b/board/Kconfig index 8c5a31c..fdb958f 100644 --- a/board/Kconfig +++ b/board/Kconfig @@ -21,6 +21,23 @@ menu "Device Support" help Say Y if you want to include support for Pixel 2 XL + config NOTHING_TETRIS + bool "Support for CMF Phone 1" + default n + depends on MT6878 + help + Say Y if you want to include support for CMF Phone 1 + + config NOTHING_TETRIS_DISABLE_WDT + bool "Disable the watchdog timer on startup" + default y + depends on NOTHING_TETRIS + help + Say Y if you want to disable the watchdog timer on startup + on this board. While this is obviously useful for end-users, + developers may want to leave this on to avoid holding down + the power button every time. + config QEMU_BOARD_VIRT bool "Support for QEMU virt platform (aarch64)" default n @@ -157,6 +174,7 @@ menu "Device Specific Addresses" config PAYLOAD_ENTRY hex "Payload Entry Address" + default 0x50000000 if NOTHING_TETRIS default 0x050000000 if SAMSUNG_J4LTE default 0x090000000 if SAMSUNG_J5LTE default 0x090000000 if SAMSUNG_GTA4XL @@ -164,6 +182,7 @@ menu "Device Specific Addresses" config RAMDISK_ENTRY hex "Ramdisk Entry Address" + default 0x40000000 if NOTHING_TETRIS default 0x084000000 if SAMSUNG_GTA4XL default 0x51100000 if VOLLA_ALGIZ diff --git a/board/Makefile b/board/Makefile index 403eed0..3a3284c 100644 --- a/board/Makefile +++ b/board/Makefile @@ -1,6 +1,7 @@ lib-$(CONFIG_APPLE_N61AP) += apple/board-n61ap.o lib-$(CONFIG_AMAZON_PW3) += amazon/board-pw3.o lib-$(CONFIG_GOOGLE_TAIMEN) += google/board-taimen.o +lib-$(CONFIG_NOTHING_TETRIS) += nothing/board-tetris.o lib-$(CONFIG_QEMU_BOARD_VIRT) += qemu/board-virt.o lib-$(CONFIG_SAMSUNG_A105F) += samsung/board-a105f.o lib-$(CONFIG_SAMSUNG_A127F) += samsung/board-a127f.o diff --git a/board/nothing/board-tetris.c b/board/nothing/board-tetris.c new file mode 100644 index 0000000..18fab58 --- /dev/null +++ b/board/nothing/board-tetris.c @@ -0,0 +1,80 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (c) 2025, Igor Belwon + */ +#include +#include +#include + +#define UART_BASE 0x11001000 + +#define UART_LSR_BASE 0x14 +#define UART_LSR_DR 0x01 /* Data ready */ +#define UART_LSR_THRE 0x20 /* TX holding register empty */ + +#define WDT_BASE 0x1c00a000 +#define WDT_MODE_KEY 0x22000000 +#define WDT_MODE_EN (1 << 0) + +void uart_putc(char ch) +{ + /* wait until TX is ready */ + while (!(readl((void *)(UART_BASE + UART_LSR_BASE)) & UART_LSR_THRE)) + ; + + writel(ch, (void *)UART_BASE); // thr is at offset 0x0, which is just uart_base +} + +void uart_puts(const char *s) +{ + while (*s != '\0') { + uart_putc(*s); + s++; + } +} + +void tetris_disable_wdt(void) +{ + uint32_t reg; + + reg = readl((void*)WDT_BASE); + if (reg & WDT_MODE_EN) + { + reg &= ~WDT_MODE_EN; + reg |= WDT_MODE_KEY; + writel(reg, (void*)WDT_BASE); + printk(KERN_INFO, "%s: disabled watchdog timer.\n", __func__); + } + else + printk(KERN_ERR, "%s: watchdog is already disabled.\n", __func__); + + return; +} + +int tetris_init(void) +{ + return 0; +} + +int tetris_drv(void) +{ + return 0; +} + +int tetris_late_init(void) +{ +#ifdef CONFIG_NOTHING_TETRIS_DISABLE_WDT + tetris_disable_wdt(); +#endif + return 0; +} + +struct board_data board_ops = { + .name = "cmf-phone-1", + .ops = { + .early_init = tetris_init, + .drivers_init = tetris_drv, + .late_init = tetris_late_init, + }, + .quirks = 0 +}; diff --git a/configs/tetris_defconfig b/configs/tetris_defconfig new file mode 100644 index 0000000..a62e11f --- /dev/null +++ b/configs/tetris_defconfig @@ -0,0 +1,11 @@ +CONFIG_POSITION_INDEPENDENT=y +# CONFIG_COMPRESS_GZIP is not set +CONFIG_COMPRESS_LZ4=y +# CONFIG_SIMPLE_FB is not set +CONFIG_UART_DEBUG=y +CONFIG_MT6878=y +CONFIG_NOTHING_TETRIS=y +CONFIG_NOTHING_TETRIS_DISABLE_WDT=y +CONFIG_TEXT_BASE=0x40000000 +CONFIG_PAYLOAD_ENTRY=0x60000000 +CONFIG_RAMDISK_ENTRY=0x51100000