linux/drivers/cpufreq/apple-soc-cpufreq.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Apple SoC CPU cluster performance state driver
 *
 * Copyright The Asahi Linux Contributors
 *
 * Based on scpi-cpufreq.c
 */

#include <linux/bitfield.h>
#include <linux/bitops.h>
#include <linux/cpu.h>
#include <linux/cpufreq.h>
#include <linux/cpumask.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/pm_opp.h>
#include <linux/slab.h>

#define APPLE_DVFS_CMD
#define APPLE_DVFS_CMD_BUSY
#define APPLE_DVFS_CMD_SET
#define APPLE_DVFS_CMD_PS2
#define APPLE_DVFS_CMD_PS1

/* Same timebase as CPU counter (24MHz) */
#define APPLE_DVFS_LAST_CHG_TIME

/*
 * Apple ran out of bits and had to shift this in T8112...
 */
#define APPLE_DVFS_STATUS
#define APPLE_DVFS_STATUS_CUR_PS_T8103
#define APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8103
#define APPLE_DVFS_STATUS_TGT_PS_T8103
#define APPLE_DVFS_STATUS_CUR_PS_T8112
#define APPLE_DVFS_STATUS_CUR_PS_SHIFT_T8112
#define APPLE_DVFS_STATUS_TGT_PS_T8112

/*
 * Div is +1, base clock is 12MHz on existing SoCs.
 * For documentation purposes. We use the OPP table to
 * get the frequency.
 */
#define APPLE_DVFS_PLL_STATUS
#define APPLE_DVFS_PLL_FACTOR
#define APPLE_DVFS_PLL_FACTOR_MULT
#define APPLE_DVFS_PLL_FACTOR_DIV

#define APPLE_DVFS_TRANSITION_TIMEOUT

struct apple_soc_cpufreq_info {};

struct apple_cpu_priv {};

static struct cpufreq_driver apple_soc_cpufreq_driver;

static const struct apple_soc_cpufreq_info soc_t8103_info =;

static const struct apple_soc_cpufreq_info soc_t8112_info =;

static const struct apple_soc_cpufreq_info soc_default_info =;

static const struct of_device_id apple_soc_cpufreq_of_match[] __maybe_unused =;

static unsigned int apple_soc_cpufreq_get_rate(unsigned int cpu)
{}

static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy,
					unsigned int index)
{}

static unsigned int apple_soc_cpufreq_fast_switch(struct cpufreq_policy *policy,
						  unsigned int target_freq)
{}

static int apple_soc_cpufreq_find_cluster(struct cpufreq_policy *policy,
					  void __iomem **reg_base,
					  const struct apple_soc_cpufreq_info **info)
{}

static struct freq_attr *apple_soc_cpufreq_hw_attr[] =;

static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)
{}

static void apple_soc_cpufreq_exit(struct cpufreq_policy *policy)
{}

static struct cpufreq_driver apple_soc_cpufreq_driver =;

static int __init apple_soc_cpufreq_module_init(void)
{}
module_init();

static void __exit apple_soc_cpufreq_module_exit(void)
{}
module_exit(apple_soc_cpufreq_module_exit);

MODULE_DEVICE_TABLE(of, apple_soc_cpufreq_of_match);
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();