Beispiel #1
0
/**
 * mips_cdmm_init() - Initialise CDMM bus.
 *
 * Initialise CDMM bus, discover CDMM devices for online CPUs, and arrange for
 * hotplug notifications so the CDMM drivers can be kept up to date.
 */
static int __init mips_cdmm_init(void)
{
	unsigned int cpu;
	int ret;

	/* Register the bus */
	ret = bus_register(&mips_cdmm_bustype);
	if (ret)
		return ret;

	/* We want to be notified about new CPUs */
	ret = register_cpu_notifier(&mips_cdmm_cpu_nb);
	if (ret) {
		pr_warn("cdmm: Failed to register CPU notifier\n");
		goto out;
	}

	/* Discover devices on CDMM of online CPUs */
	for_each_online_cpu(cpu)
		work_on_cpu(cpu, mips_cdmm_bus_up, &cpu);

	return 0;
out:
	bus_unregister(&mips_cdmm_bustype);
	return ret;
}
Beispiel #2
0
static int __init tegra_cpuidle_init(void)
{
	unsigned int cpu;
	int ret;

#ifdef CONFIG_PM_SLEEP
	tegra_pd_min_residency = tegra_cpu_lp2_min_residency();
	tegra_pg_exit_latency = tegra_cpu_power_good_time();
	tegra_pd_power_off_time = tegra_cpu_power_off_time();

	tegra_cpuidle_init_soc(&tegra_idle_ops);
#endif
	for_each_possible_cpu(cpu) {
		ret = tegra_cpuidle_register(cpu);
		if (ret) {
			pr_err("CPU%u: CPUidle registration failed\n",
				cpu);
			return ret;
		}
	}

#ifdef CONFIG_TEGRA_MC_DOMAINS
	work_on_cpu(0, pm_attach_cpuidle_work, NULL);
#endif
	register_pm_notifier(&tegra_cpuidle_pm_notifier);
	return 0;
}
Beispiel #3
0
/**
 * mips_cdmm_cpu_notify() - Take action when a CPU is going online or offline.
 * @nb:		CPU notifier block .
 * @action:	Event that has taken place (CPU_*).
 * @data:	CPU number.
 *
 * This notifier is used to keep the CDMM buses updated as CPUs are offlined and
 * onlined. When CPUs go offline or come back online, so does their CDMM bus, so
 * devices must be informed. Also when CPUs come online for the first time the
 * devices on the CDMM bus need discovering.
 *
 * Returns:	NOTIFY_OK if event was used.
 *		NOTIFY_DONE if we didn't care.
 */
static int mips_cdmm_cpu_notify(struct notifier_block *nb,
				unsigned long action, void *data)
{
	unsigned int cpu = (unsigned int)data;

	switch (action & ~CPU_TASKS_FROZEN) {
	case CPU_ONLINE:
	case CPU_DOWN_FAILED:
		work_on_cpu(cpu, mips_cdmm_bus_up, &cpu);
		break;
	case CPU_DOWN_PREPARE:
		work_on_cpu(cpu, mips_cdmm_bus_down, &cpu);
		break;
	default:
		return NOTIFY_DONE;
	}

	return NOTIFY_OK;
}
Beispiel #4
0
static int
acpi_cpufreq_target (
	struct cpufreq_policy   *policy,
	unsigned int index)
{
	struct cpufreq_acpi_req req;

	req.cpu = policy->cpu;
	req.state = index;

	return work_on_cpu(req.cpu, processor_set_freq, &req);
}
Beispiel #5
0
static unsigned int
acpi_cpufreq_get (
	unsigned int		cpu)
{
	struct cpufreq_acpi_req req;
	long ret;

	req.cpu = cpu;
	ret = work_on_cpu(cpu, processor_get_freq, &req);

	return ret > 0 ? (unsigned int) ret : 0;
}
Beispiel #6
0
static int pwm_ir_tx_transmit_with_delay(struct pwm_ir_packet *pkt)
{
    int cpu, rc = -ENODEV;

    for_each_online_cpu(cpu) {
        /* select one auxilliary cpu to run */
        if (cpu != 0) {
            rc = work_on_cpu(cpu, pwm_ir_tx_work, pkt);
            break;
        }
    }

    if (rc == -ENODEV) {
        pr_warn("pwm-ir: can't run on the auxilliary cpu\n");
        rc = pwm_ir_tx_work(pkt);
    }

    return rc;
}
Beispiel #7
0
/* Run __apm_bios_call or __apm_bios_call_simple on CPU 0 */
static int on_cpu0(long (*fn)(void *), struct apm_bios_call *call)
{
	int ret;

	/* Don't bother with work_on_cpu in the common case, so we don't
	 * have to worry about OOM or overhead. */
	if (get_cpu() == 0) {
		ret = fn(call);
		put_cpu();
	} else {
		put_cpu();
		ret = work_on_cpu(0, fn, call);
	}

	/* work_on_cpu can fail with -ENOMEM */
	if (ret < 0)
		call->err = ret;
	else
		call->err = (call->eax >> 8) & 0xff;

	return ret;
}