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


#include <common.h>
#include <command.h>
#include <debug_impl.h>
#include <mtk_standby.h>

int do_standby_mode_power_control(void)
{
    int ret = -1;
    UBOOT_TRACE("start\n");
#if defined(CONFIG_REMOTEPROC_MTK_PMU_CORTEX_M4)
    run_command("voc notify", 0);
    run_command("voc standby", 0);
#endif

#if defined(CONFIG_MTK_PMU)
    run_command("consult_pmu", 0);
#endif

#if defined(CONFIG_MTK_BT_USB)
    run_command("setMtkBT", 0);
#endif
    run_command("usb stop", 0);

#if defined(CONFIG_MEDIATEK_DTV_GMAC)
#if defined(CONFIG_MEDIATEK_DTV_GMAC_WOL_2ND)
    run_command("phy_wol_enable", 0);
#else
    run_command("phy_power_down", 0);
#endif /* CONFIG_MEDIATEK_DTV_GMAC_WOL_2ND */
#endif

#if defined(CONFIG_MTK_PANEL)
    run_command("panel_enable_vcc 0", 0);
#endif

    ret = mtk_main_chip_power_standby();
    if(ret != 0)
        UBOOT_ERROR("main chip power down framework execuate failure\n");

    UBOOT_TRACE("end\n");
    return ret;
}
