linux/drivers/bus/mhi/host/pm.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 *
 */

#include <linux/delay.h>
#include <linux/device.h>
#include <linux/dma-direction.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/mhi.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/wait.h>
#include "internal.h"
#include "trace.h"

/*
 * Not all MHI state transitions are synchronous. Transitions like Linkdown,
 * SYS_ERR, and shutdown can happen anytime asynchronously. This function will
 * transition to a new state only if we're allowed to.
 *
 * Priority increases as we go down. For instance, from any state in L0, the
 * transition can be made to states in L1, L2 and L3. A notable exception to
 * this rule is state DISABLE.  From DISABLE state we can only transition to
 * POR state. Also, while in L2 state, user cannot jump back to previous
 * L1 or L0 states.
 *
 * Valid transitions:
 * L0: DISABLE <--> POR
 *     POR <--> POR
 *     POR -> M0 -> M2 --> M0
 *     POR -> FW_DL_ERR
 *     FW_DL_ERR <--> FW_DL_ERR
 *     M0 <--> M0
 *     M0 -> FW_DL_ERR
 *     M0 -> M3_ENTER -> M3 -> M3_EXIT --> M0
 * L1: SYS_ERR_DETECT -> SYS_ERR_PROCESS
 *     SYS_ERR_PROCESS -> SYS_ERR_FAIL
 *     SYS_ERR_FAIL -> SYS_ERR_DETECT
 *     SYS_ERR_PROCESS --> POR
 * L2: SHUTDOWN_PROCESS -> LD_ERR_FATAL_DETECT
 *     SHUTDOWN_PROCESS -> DISABLE
 * L3: LD_ERR_FATAL_DETECT <--> LD_ERR_FATAL_DETECT
 *     LD_ERR_FATAL_DETECT -> DISABLE
 */
static const struct mhi_pm_transitions dev_state_transitions[] =;

enum mhi_pm_state __must_check mhi_tryset_pm_state(struct mhi_controller *mhi_cntrl,
						   enum mhi_pm_state state)
{}

void mhi_set_mhi_state(struct mhi_controller *mhi_cntrl, enum mhi_state state)
{}

/* NOP for backward compatibility, host allowed to ring DB in M2 state */
static void mhi_toggle_dev_wake_nop(struct mhi_controller *mhi_cntrl)
{}

static void mhi_toggle_dev_wake(struct mhi_controller *mhi_cntrl)
{}

/* Handle device ready state transition */
int mhi_ready_state_transition(struct mhi_controller *mhi_cntrl)
{}

int mhi_pm_m0_transition(struct mhi_controller *mhi_cntrl)
{}

/*
 * After receiving the MHI state change event from the device indicating the
 * transition to M1 state, the host can transition the device to M2 state
 * for keeping it in low power state.
 */
void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl)
{}

/* MHI M3 completion handler */
int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl)
{}

/* Handle device Mission Mode transition */
static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
{}

/* Handle shutdown transitions */
static void mhi_pm_disable_transition(struct mhi_controller *mhi_cntrl,
				      bool destroy_device)
{}

/* Handle system error transitions */
static void mhi_pm_sys_error_transition(struct mhi_controller *mhi_cntrl)
{}

/* Queue a new work item and schedule work */
int mhi_queue_state_transition(struct mhi_controller *mhi_cntrl,
			       enum dev_st_transition state)
{}

/* SYS_ERR worker */
void mhi_pm_sys_err_handler(struct mhi_controller *mhi_cntrl)
{}

/* Device State Transition worker */
void mhi_pm_st_worker(struct work_struct *work)
{}

int mhi_pm_suspend(struct mhi_controller *mhi_cntrl)
{}
EXPORT_SYMBOL_GPL();

static int __mhi_pm_resume(struct mhi_controller *mhi_cntrl, bool force)
{}

int mhi_pm_resume(struct mhi_controller *mhi_cntrl)
{}
EXPORT_SYMBOL_GPL();

int mhi_pm_resume_force(struct mhi_controller *mhi_cntrl)
{}
EXPORT_SYMBOL_GPL();

int __mhi_device_get_sync(struct mhi_controller *mhi_cntrl)
{}

/* Assert device wake db */
static void mhi_assert_dev_wake(struct mhi_controller *mhi_cntrl, bool force)
{}

/* De-assert device wake db */
static void mhi_deassert_dev_wake(struct mhi_controller *mhi_cntrl,
				  bool override)
{}

int mhi_async_power_up(struct mhi_controller *mhi_cntrl)
{}
EXPORT_SYMBOL_GPL();

static void __mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful,
			     bool destroy_device)
{}

void mhi_power_down(struct mhi_controller *mhi_cntrl, bool graceful)
{}
EXPORT_SYMBOL_GPL();

void mhi_power_down_keep_dev(struct mhi_controller *mhi_cntrl,
			       bool graceful)
{}
EXPORT_SYMBOL_GPL();

int mhi_sync_power_up(struct mhi_controller *mhi_cntrl)
{}
EXPORT_SYMBOL();

int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl)
{}
EXPORT_SYMBOL_GPL();

void mhi_device_get(struct mhi_device *mhi_dev)
{}
EXPORT_SYMBOL_GPL();

int mhi_device_get_sync(struct mhi_device *mhi_dev)
{}
EXPORT_SYMBOL_GPL();

void mhi_device_put(struct mhi_device *mhi_dev)
{}
EXPORT_SYMBOL_GPL();