static int omap_cpu_init(struct cpufreq_policy *policy) { int result; policy->clk = clk_get(NULL, "cpufreq_ck"); if (IS_ERR(policy->clk)) return PTR_ERR(policy->clk); if (!freq_table) { result = dev_pm_opp_init_cpufreq_table(mpu_dev, &freq_table); if (result) { dev_err(mpu_dev, "%s: cpu%d: failed creating freq table[%d]\n", __func__, policy->cpu, result); goto fail; } } atomic_inc_return(&freq_table_users); /* FIXME: what's the actual transition time? */ result = cpufreq_generic_init(policy, freq_table, 300 * 1000); if (!result) return 0; freq_table_free(); fail: clk_put(policy->clk); return result; }
static int davinci_cpu_init(struct cpufreq_policy *policy) { int result = 0; struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; struct cpufreq_frequency_table *freq_table = pdata->freq_table; if (policy->cpu != 0) return -EINVAL; /* Finish platform specific initialization */ if (pdata->init) { result = pdata->init(); if (result) return result; } policy->clk = cpufreq.armclk; /* * Time measurement across the target() function yields ~1500-1800us * time taken with no drivers on notification list. * Setting the latency to 2000 us to accommodate addition of drivers * to pre/post change notification list. */ return cpufreq_generic_init(policy, freq_table, 2000 * 1000); }
static int loongson2_cpufreq_cpu_init(struct cpufreq_policy *policy) { struct clk *cpuclk; int i; unsigned long rate; int ret; cpuclk = clk_get(NULL, "cpu_clk"); if (IS_ERR(cpuclk)) { pr_err("couldn't get CPU clk\n"); return PTR_ERR(cpuclk); } rate = cpu_clock_freq / 1000; if (!rate) { clk_put(cpuclk); return -EINVAL; } /* clock table init */ for (i = 2; (loongson2_clockmod_table[i].frequency != CPUFREQ_TABLE_END); i++) loongson2_clockmod_table[i].frequency = (rate * i) / 8; ret = clk_set_rate(cpuclk, rate * 1000); if (ret) { clk_put(cpuclk); return ret; } policy->clk = cpuclk; return cpufreq_generic_init(policy, &loongson2_clockmod_table[0], 0); }
static int ls1x_cpufreq_init(struct cpufreq_policy *policy) { struct device *cpu_dev = get_cpu_device(policy->cpu); struct cpufreq_frequency_table *freq_tbl; unsigned int pll_freq, freq; int steps, i, ret; pll_freq = clk_get_rate(cpufreq->pll_clk) / 1000; steps = 1 << DIV_CPU_WIDTH; freq_tbl = kcalloc(steps, sizeof(*freq_tbl), GFP_KERNEL); if (!freq_tbl) return -ENOMEM; for (i = 0; i < (steps - 1); i++) { freq = pll_freq / (i + 1); if ((freq < cpufreq->min_freq) || (freq > cpufreq->max_freq)) freq_tbl[i].frequency = CPUFREQ_ENTRY_INVALID; else freq_tbl[i].frequency = freq; dev_dbg(cpu_dev, "cpufreq table: index %d: frequency %d\n", i, freq_tbl[i].frequency); } freq_tbl[i].frequency = CPUFREQ_TABLE_END; policy->clk = cpufreq->clk; ret = cpufreq_generic_init(policy, freq_tbl, 0); if (ret) kfree(freq_tbl); return ret; }
static int imx7d_cpufreq_init(struct cpufreq_policy *policy) { int ret; policy->clk = arm_clk; policy->cur = clk_get_rate(arm_clk) / 1000; ret = cpufreq_generic_init(policy, freq_table, transition_latency); if (ret) { dev_err(cpu_dev, "imx7d cpufreq init failed!\n"); return ret; } return 0; }
static int imx6q_cpufreq_init(struct cpufreq_policy *policy) { int ret; policy->clk = arm_clk; policy->cur = clk_get_rate(arm_clk) / 1000; ret = cpufreq_generic_init(policy, freq_table, transition_latency); if (ret) { dev_err(cpu_dev, "imx6 cpufreq init failed!\n"); return ret; } if (policy->cur > FREQ_396_MHZ) request_bus_freq(BUS_FREQ_HIGH); return 0; }
/* ============================================================== Initialisation function sets up the CPU policy for first use ============================================================== */ static int bcm2835_cpufreq_driver_init(struct cpufreq_policy *policy) { /* measured value of how long it takes to change frequency */ const unsigned int transition_latency = 355000; /* ns */ if (!rpi_firmware_get(NULL)) { print_err("Firmware is not available\n"); return -ENODEV; } /* now find out what the maximum and minimum frequencies are */ bcm2835_freq_table[0].frequency = bcm2835_cpufreq_get_clock(RPI_FIRMWARE_GET_MIN_CLOCK_RATE); bcm2835_freq_table[1].frequency = bcm2835_cpufreq_get_clock(RPI_FIRMWARE_GET_MAX_CLOCK_RATE); print_info("min=%d max=%d\n", bcm2835_freq_table[0].frequency, bcm2835_freq_table[1].frequency); return cpufreq_generic_init(policy, bcm2835_freq_table, transition_latency); }
static int tegra_cpu_init(struct cpufreq_policy *policy) { int ret; if (policy->cpu >= NUM_CPUS) return -EINVAL; clk_prepare_enable(emc_clk); clk_prepare_enable(cpu_clk); /* FIXME: what's the actual transition time? */ ret = cpufreq_generic_init(policy, freq_table, 300 * 1000); if (ret) { clk_disable_unprepare(cpu_clk); clk_disable_unprepare(emc_clk); return ret; } policy->clk = cpu_clk; policy->suspend_freq = freq_table[0].frequency; return 0; }
static int ls1x_cpufreq_init(struct cpufreq_policy *policy) { struct cpufreq_frequency_table *freq_tbl; unsigned int pll_freq, freq; int steps, i, ret; pll_freq = clk_get_rate(ls1x_cpufreq.pll_clk) / 1000; steps = 1 << DIV_CPU_WIDTH; freq_tbl = kzalloc(sizeof(*freq_tbl) * steps, GFP_KERNEL); if (!freq_tbl) { dev_err(ls1x_cpufreq.dev, "failed to alloc cpufreq_frequency_table\n"); ret = -ENOMEM; goto out; } for (i = 0; i < (steps - 1); i++) { freq = pll_freq / (i + 1); if ((freq < ls1x_cpufreq.min_freq) || (freq > ls1x_cpufreq.max_freq)) freq_tbl[i].frequency = CPUFREQ_ENTRY_INVALID; else freq_tbl[i].frequency = freq; dev_dbg(ls1x_cpufreq.dev, "cpufreq table: index %d: frequency %d\n", i, freq_tbl[i].frequency); } freq_tbl[i].frequency = CPUFREQ_TABLE_END; policy->clk = ls1x_cpufreq.clk; ret = cpufreq_generic_init(policy, freq_tbl, 0); if (ret) kfree(freq_tbl); out: return ret; }
static int imx6q_cpufreq_init(struct cpufreq_policy *policy) { policy->clk = arm_clk; return cpufreq_generic_init(policy, freq_table, transition_latency); }
/* Module init and exit code */ static int kirkwood_cpufreq_cpu_init(struct cpufreq_policy *policy) { return cpufreq_generic_init(policy, kirkwood_freq_table, 5000); }
static int exynos_cpufreq_cpu_init(struct cpufreq_policy *policy) { policy->clk = exynos_info->cpu_clk; policy->suspend_freq = locking_frequency; return cpufreq_generic_init(policy, exynos_info->freq_table, 100000); }
static int dbx500_cpufreq_init(struct cpufreq_policy *policy) { return cpufreq_generic_init(policy, freq_table, 20 * 1000); }
static int spear_cpufreq_init(struct cpufreq_policy *policy) { return cpufreq_generic_init(policy, spear_cpufreq.freq_tbl, spear_cpufreq.transition_latency); }