static int tegra_cpuidle_state_enter()

in cpuidle-tegra.c [163:205]


static int tegra_cpuidle_state_enter(struct cpuidle_device *dev,
				     int index, unsigned int cpu)
{
	int err;

	/*
	 * CC6 state is the "CPU cluster power-off" state.  In order to
	 * enter this state, at first the secondary CPU cores need to be
	 * parked into offline mode, then the last CPU should clean out
	 * remaining dirty cache lines into DRAM and trigger Flow Controller
	 * logic that turns off the cluster's power domain (which includes
	 * CPU cores, GIC and L2 cache).
	 */
	if (index == TEGRA_CC6) {
		err = tegra_cpuidle_coupled_barrier(dev);
		if (err)
			return err;
	}

	local_fiq_disable();
	RCU_NONIDLE(tegra_pm_set_cpu_in_lp2());
	cpu_pm_enter();

	switch (index) {
	case TEGRA_C7:
		err = tegra_cpuidle_c7_enter();
		break;

	case TEGRA_CC6:
		err = tegra_cpuidle_cc6_enter(cpu);
		break;

	default:
		err = -EINVAL;
		break;
	}

	cpu_pm_exit();
	RCU_NONIDLE(tegra_pm_clear_cpu_in_lp2());
	local_fiq_enable();

	return err ?: index;
}