mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-14 07:44:21 +08:00
cb6fe2ceb6
- First part of DT header detangling dropping cpu.h from of_device.h and replacing some includes with forward declarations. A handful of drivers needed some adjustment to their includes as a result. - Refactor of_device.h to be used by bus drivers rather than various device drivers. This moves non-bus related functions out of of_device.h. The end goal is for of_platform.h and of_device.h to stop including each other. - Refactor open coded parsing of "ranges" in some bus drivers to use DT address parsing functions - Add some new address parsing functions of_property_read_reg(), of_range_count(), and of_range_to_resource() in preparation to convert more open coded parsing of DT addresses to use them. - Treewide clean-ups to use of_property_read_bool() and of_property_present() as appropriate. The ones here are the ones that didn't get picked up elsewhere. -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEktVUI4SxYhzZyEuo+vtdtY28YcMFAmRIOrkACgkQ+vtdtY28 YcN9WA//R+QrmSPExhfgio5y+aOJDWucqnAcyAusPctLcF7h7j0CdzpwaSRkdaH4 KiLjeyt6tKn8wt8w7m/+SmCsSYXPn81GH/Y5I2F40x6QMrY3cVOXUsulKQA+6ZjZ PmW3bMcz0Dw9IhUK3R/WX96+9UdoytKg5qoTzNzPTKpvKA1yHa/ogl2FnHJS5W+8 Rxz+1oJ70VMIWGpBOc0acHuB2S0RHZ46kPKkPTBgFYEwtmJ8qobvV3r3uQapNaIP 2jnamPu0tAaQoSaJKKSulToziT+sd1sNB+9oyu/kP+t3PXzq4qwp2Gr4jzUYKs4A ZF3DPhMR3YLLN41g/L3rtB0T/YIS287sZRuaLhCqldNpRerSDk4b0HRAksGk1XrI HqYXjWPbRxqYiIUWkInfregSTYJfGPxeLfLKrawNO34/eEV4JrkSKy8d0AJn04EK jTRqI3L7o23ZPxs29uH/3+KK90J3emPZkF7GWVJTEAMsM8jYZduGh7EpsttJLaz/ QnxbTBm9295ahIdCfo/OQhqjWnaNhpbTzf31pyrBZ/itXV7gQ0xjwqPwiyFwI+o/ F/r81xqdwQ3Ni8MKt2c7zLyVA95JHPe95KQ3GrDXR68aByJr4RuhKG8Y2Pj1VOb3 V+Hsu5uhwKrK7Yqe+rHDnJBO00OCO8nwbWhMy2xVxoTkSFCjDmo= =89Zj -----END PGP SIGNATURE----- Merge tag 'devicetree-for-6.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull more devicetree updates from Rob Herring: - First part of DT header detangling dropping cpu.h from of_device.h and replacing some includes with forward declarations. A handful of drivers needed some adjustment to their includes as a result. - Refactor of_device.h to be used by bus drivers rather than various device drivers. This moves non-bus related functions out of of_device.h. The end goal is for of_platform.h and of_device.h to stop including each other. - Refactor open coded parsing of "ranges" in some bus drivers to use DT address parsing functions - Add some new address parsing functions of_property_read_reg(), of_range_count(), and of_range_to_resource() in preparation to convert more open coded parsing of DT addresses to use them. - Treewide clean-ups to use of_property_read_bool() and of_property_present() as appropriate. The ones here are the ones that didn't get picked up elsewhere. * tag 'devicetree-for-6.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (34 commits) bus: tegra-gmi: Replace of_platform.h with explicit includes hte: Use of_property_present() for testing DT property presence w1: w1-gpio: Use of_property_read_bool() for boolean properties virt: fsl: Use of_property_present() for testing DT property presence soc: fsl: Use of_property_present() for testing DT property presence sbus: display7seg: Use of_property_read_bool() for boolean properties sparc: Use of_property_read_bool() for boolean properties sparc: Use of_property_present() for testing DT property presence bus: mvebu-mbus: Remove open coded "ranges" parsing of/address: Add of_property_read_reg() helper of/address: Add of_range_count() helper of/address: Add support for 3 address cell bus of/address: Add of_range_to_resource() helper of: unittest: Add bus address range parsing tests of: Drop cpu.h include from of_device.h OPP: Adjust includes to remove of_device.h irqchip: loongson-eiointc: Add explicit include for cpuhotplug.h cpuidle: Adjust includes to remove of_device.h cpufreq: sun50i: Add explicit include for cpu.h cpufreq: Adjust includes to remove of_device.h ...
114 lines
2.7 KiB
C
114 lines
2.7 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2010 Google, Inc.
|
|
*
|
|
* Author:
|
|
* Colin Cross <ccross@google.com>
|
|
* Based on arch/arm/plat-omap/cpu-omap.c, (C) 2005 Nokia Corporation
|
|
*/
|
|
|
|
#include <linux/bits.h>
|
|
#include <linux/cpu.h>
|
|
#include <linux/err.h>
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/pm_opp.h>
|
|
#include <linux/types.h>
|
|
|
|
#include <soc/tegra/common.h>
|
|
#include <soc/tegra/fuse.h>
|
|
|
|
static bool cpu0_node_has_opp_v2_prop(void)
|
|
{
|
|
struct device_node *np = of_cpu_device_node_get(0);
|
|
bool ret = false;
|
|
|
|
if (of_property_present(np, "operating-points-v2"))
|
|
ret = true;
|
|
|
|
of_node_put(np);
|
|
return ret;
|
|
}
|
|
|
|
static void tegra20_cpufreq_put_supported_hw(void *opp_token)
|
|
{
|
|
dev_pm_opp_put_supported_hw((unsigned long) opp_token);
|
|
}
|
|
|
|
static void tegra20_cpufreq_dt_unregister(void *cpufreq_dt)
|
|
{
|
|
platform_device_unregister(cpufreq_dt);
|
|
}
|
|
|
|
static int tegra20_cpufreq_probe(struct platform_device *pdev)
|
|
{
|
|
struct platform_device *cpufreq_dt;
|
|
struct device *cpu_dev;
|
|
u32 versions[2];
|
|
int err;
|
|
|
|
if (!cpu0_node_has_opp_v2_prop()) {
|
|
dev_err(&pdev->dev, "operating points not found\n");
|
|
dev_err(&pdev->dev, "please update your device tree\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
if (of_machine_is_compatible("nvidia,tegra20")) {
|
|
versions[0] = BIT(tegra_sku_info.cpu_process_id);
|
|
versions[1] = BIT(tegra_sku_info.soc_speedo_id);
|
|
} else {
|
|
versions[0] = BIT(tegra_sku_info.cpu_process_id);
|
|
versions[1] = BIT(tegra_sku_info.cpu_speedo_id);
|
|
}
|
|
|
|
dev_info(&pdev->dev, "hardware version 0x%x 0x%x\n",
|
|
versions[0], versions[1]);
|
|
|
|
cpu_dev = get_cpu_device(0);
|
|
if (WARN_ON(!cpu_dev))
|
|
return -ENODEV;
|
|
|
|
err = dev_pm_opp_set_supported_hw(cpu_dev, versions, 2);
|
|
if (err < 0) {
|
|
dev_err(&pdev->dev, "failed to set supported hw: %d\n", err);
|
|
return err;
|
|
}
|
|
|
|
err = devm_add_action_or_reset(&pdev->dev,
|
|
tegra20_cpufreq_put_supported_hw,
|
|
(void *)((unsigned long) err));
|
|
if (err)
|
|
return err;
|
|
|
|
cpufreq_dt = platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
|
|
err = PTR_ERR_OR_ZERO(cpufreq_dt);
|
|
if (err) {
|
|
dev_err(&pdev->dev,
|
|
"failed to create cpufreq-dt device: %d\n", err);
|
|
return err;
|
|
}
|
|
|
|
err = devm_add_action_or_reset(&pdev->dev,
|
|
tegra20_cpufreq_dt_unregister,
|
|
cpufreq_dt);
|
|
if (err)
|
|
return err;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct platform_driver tegra20_cpufreq_driver = {
|
|
.probe = tegra20_cpufreq_probe,
|
|
.driver = {
|
|
.name = "tegra20-cpufreq",
|
|
},
|
|
};
|
|
module_platform_driver(tegra20_cpufreq_driver);
|
|
|
|
MODULE_ALIAS("platform:tegra20-cpufreq");
|
|
MODULE_AUTHOR("Colin Cross <ccross@android.com>");
|
|
MODULE_DESCRIPTION("NVIDIA Tegra20 cpufreq driver");
|
|
MODULE_LICENSE("GPL");
|