// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
/*
 * Copyright (c) 2023 MediaTek Inc.
 */
/*
 * Copyright 2023-2025 Sony Corporation
 */

#include <common.h>
#include <mtk_cmdtable.h>
#include <bootflow.h>
#include <time.h>
#include <utility.h>

int do_customized_command_register(void)
{
#if defined(CONFIG_ANDROID_CN_PLATFORM) || defined(CONFIG_LINUX_REF_PLATFORM)
	mtk_add_command_table("mmc cap", 0, BEFORE_CONSOLE_INPUT);
#endif
#ifdef CONFIG_CONSOLE_LOCK
#ifdef CONFIG_CONSOLE_UNLOCK_USB
	mtk_add_command_table("cetest cu_clear", 0, BEFORE_CONSOLE_INPUT);
	mtk_add_command_table("ce_usb", 0, BEFORE_CONSOLE_INPUT);
#endif
	mtk_add_command_table("check_ce", 0, BEFORE_BOOT_KERNEL);
#endif

#ifdef CONFIG_SONY_EMMC_INIT
	mtk_add_command_table("sony_emmc_init", 0, BEFORE_CONSOLE_INPUT);
#endif

#ifdef CONFIG_POWERKEY_FDR
	mtk_add_command_table("check_pkey_fdr", 0, BEFORE_BOOT_KERNEL);
#endif

	mtk_add_command_table("backlight_power_flush", 0, BEFORE_CONSOLE_INPUT);

	mtk_add_command_table("disable_panel_test_pattern", 0, BEFORE_CONSOLE_INPUT);

	mtk_add_command_table("adddid", 0, BEFORE_CONSOLE_INPUT);

	mtk_add_command_table("addpci", 0, BEFORE_CONSOLE_INPUT);

	mtk_add_command_table("panel_enable 1", 0, AFTER_CONSOLE_INPUT);

#ifdef CONFIG_MTK_PANEL
	mtk_add_command_table("panel_mute 0", 0, AFTER_CONSOLE_INPUT);
#endif
	mtk_add_command_table("panel_post_init", 0, AFTER_CONSOLE_INPUT);

	mtk_add_command_table("damp_selector_init", 0, AFTER_CONSOLE_INPUT);

	mtk_add_command_table("panel_device_update_status", 0, AFTER_CONSOLE_INPUT);

	mtk_add_command_table("be_boot", 0, AFTER_CONSOLE_INPUT);

	mtk_add_command_table("oled_panel_control", 0, AFTER_CONSOLE_INPUT);

	mtk_add_command_table("oled_logo_brightness_control", 0, AFTER_CONSOLE_INPUT);

	mtk_add_command_table("logo_backlight_control", 0, AFTER_CONSOLE_INPUT);

#ifdef CONFIG_MTK_PANEL
	/* Workaround mute to conceal DM22TVSW-31440 symptom. the final solution is discussed in MTKTECIT-3249 */
	mtk_add_command_table("panel_mute 1", 0, AFTER_CONSOLE_INPUT);
#endif

	mtk_add_command_table("showlogo", 0, AFTER_CONSOLE_INPUT);

#ifdef CONFIG_MTK_PANEL
	/* Workaround mute to conceal DM22TVSW-31440 symptom. the final solution is discussed in MTKTECIT-3249 */
	mtk_add_command_table("panel_mute 0", 0, AFTER_CONSOLE_INPUT);
#endif

#ifdef CONFIG_SONY_FULL_PARTITIONS
	mtk_add_command_table("sony_part_init full mmc 0", 0, AFTER_UBOOT_INIT);
#ifdef CONFIG_SONY_CREATE_PARTITIONS_ON_INIT_BOOT
	mtk_add_command_table("sony_gpt create_on_init_boot mmc 0", 0, AFTER_UBOOT_INIT);
#endif
#else
	mtk_add_command_table("sony_part_init default mmc 0", 0, AFTER_UBOOT_INIT);
#endif
	/* AC power setting for B2B */
	mtk_add_command_table("check_boot_reason_and_set_qhb_mode", 0, AFTER_UBOOT_INIT);

	mtk_add_command_table("wait_pmu_ready", 0, AFTER_UBOOT_INIT);
	mtk_add_command_table("be_power_set", 0, AFTER_UBOOT_INIT);
	mtk_add_command_table("paneldet_callback", 0, AFTER_UBOOT_INIT);

	mtk_add_command_table("rbiread", 0, BEFORE_BOOT_KERNEL);
	mtk_add_command_table("first_api_level", 0, BEFORE_BOOT_KERNEL);
	mtk_add_command_table("prodconfig_task", 0, BEFORE_BOOT_KERNEL);

	mtk_add_command_table("usbboot_check", 0, BEFORE_BOOT_KERNEL);
	mtk_add_command_table("update_standby_mode", 0, BEFORE_BOOT_KERNEL);

	mtk_add_command_table("sony_fstab_init", 0, BEFORE_BOOT_KERNEL);
	mtk_add_command_table("sony_frp_init", 0, BEFORE_BOOT_KERNEL);

	run_command("sony_gpio_init", 0);
	run_command("serialno", 0);
	run_command("wv_version", 0);

	return 0;
}

