···573573 .probe = mt8173_cpufreq_probe,574574};575575576576-static int mt8173_cpufreq_driver_init(void)576576+/* List of machines supported by this driver */577577+static const struct of_device_id mt8173_cpufreq_machines[] __initconst = {578578+ { .compatible = "mediatek,mt817x", },579579+ { .compatible = "mediatek,mt8173", },580580+ { .compatible = "mediatek,mt8176", },581581+582582+ { }583583+};584584+585585+static int __init mt8173_cpufreq_driver_init(void)577586{587587+ struct device_node *np;588588+ const struct of_device_id *match;578589 struct platform_device *pdev;579590 int err;580591581581- if (!of_machine_is_compatible("mediatek,mt8173"))592592+ np = of_find_node_by_path("/");593593+ if (!np)582594 return -ENODEV;595595+596596+ match = of_match_node(mt8173_cpufreq_machines, np);597597+ of_node_put(np);598598+ if (!match) {599599+ pr_warn("Machine is not compatible with mt8173-cpufreq\n");600600+ return -ENODEV;601601+ }583602584603 err = platform_driver_register(&mt8173_cpufreq_platdrv);585604 if (err)
+17-7
drivers/cpufreq/qoriq-cpufreq.c
···5252{5353 struct device_node *soc;5454 u32 sysfreq;5555+ struct clk *pltclk;5656+ int ret;55575858+ /* get platform freq by searching bus-frequency property */5659 soc = of_find_node_by_type(NULL, "soc");5757- if (!soc)5858- return 0;6060+ if (soc) {6161+ ret = of_property_read_u32(soc, "bus-frequency", &sysfreq);6262+ of_node_put(soc);6363+ if (!ret)6464+ return sysfreq;6565+ }59666060- if (of_property_read_u32(soc, "bus-frequency", &sysfreq))6161- sysfreq = 0;6767+ /* get platform freq by its clock name */6868+ pltclk = clk_get(NULL, "cg-pll0-div1");6969+ if (IS_ERR(pltclk)) {7070+ pr_err("%s: can't get bus frequency %ld\n",7171+ __func__, PTR_ERR(pltclk));7272+ return PTR_ERR(pltclk);7373+ }62746363- of_node_put(soc);6464-6565- return sysfreq;7575+ return clk_get_rate(pltclk);6676}67776878static struct clk *cpu_to_clk(int cpu)
-12
drivers/thermal/Kconfig
···291291 Enable this option if you want to have support for thermal management292292 controller present in Armada 370 and Armada XP SoC.293293294294-config DB8500_CPUFREQ_COOLING295295- tristate "DB8500 cpufreq cooling"296296- depends on ARCH_U8500 || COMPILE_TEST297297- depends on HAS_IOMEM298298- depends on CPU_THERMAL299299- default y300300- help301301- Adds DB8500 cpufreq cooling devices, and these cooling devices can be302302- bound to thermal zone trip points. When a trip point reached, the303303- bound cpufreq cooling device turns active to set CPU frequency low to304304- cool down the CPU.305305-306294config INTEL_POWERCLAMP307295 tristate "Intel PowerClamp idle injection driver"308296 depends on THERMAL
···11-/*22- * db8500_cpufreq_cooling.c - DB8500 cpufreq works as cooling device.33- *44- * Copyright (C) 2012 ST-Ericsson55- * Copyright (C) 2012 Linaro Ltd.66- *77- * Author: Hongbo Zhang <hongbo.zhang@linaro.com>88- *99- * This program is free software; you can redistribute it and/or modify1010- * it under the terms of the GNU General Public License as published by1111- * the Free Software Foundation; either version 2 of the License, or1212- * (at your option) any later version.1313- *1414- * This program is distributed in the hope that it will be useful,1515- * but WITHOUT ANY WARRANTY; without even the implied warranty of1616- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1717- * GNU General Public License for more details.1818- */1919-2020-#include <linux/cpu_cooling.h>2121-#include <linux/err.h>2222-#include <linux/module.h>2323-#include <linux/of.h>2424-#include <linux/platform_device.h>2525-#include <linux/slab.h>2626-2727-static int db8500_cpufreq_cooling_probe(struct platform_device *pdev)2828-{2929- struct thermal_cooling_device *cdev;3030-3131- cdev = cpufreq_cooling_register(cpu_present_mask);3232- if (IS_ERR(cdev)) {3333- int ret = PTR_ERR(cdev);3434-3535- if (ret != -EPROBE_DEFER)3636- dev_err(&pdev->dev,3737- "Failed to register cooling device %d\n",3838- ret);3939-4040- return ret;4141- }4242-4343- platform_set_drvdata(pdev, cdev);4444-4545- dev_info(&pdev->dev, "Cooling device registered: %s\n", cdev->type);4646-4747- return 0;4848-}4949-5050-static int db8500_cpufreq_cooling_remove(struct platform_device *pdev)5151-{5252- struct thermal_cooling_device *cdev = platform_get_drvdata(pdev);5353-5454- cpufreq_cooling_unregister(cdev);5555-5656- return 0;5757-}5858-5959-static int db8500_cpufreq_cooling_suspend(struct platform_device *pdev,6060- pm_message_t state)6161-{6262- return -ENOSYS;6363-}6464-6565-static int db8500_cpufreq_cooling_resume(struct platform_device *pdev)6666-{6767- return -ENOSYS;6868-}6969-7070-#ifdef CONFIG_OF7171-static const struct of_device_id db8500_cpufreq_cooling_match[] = {7272- { .compatible = "stericsson,db8500-cpufreq-cooling" },7373- {},7474-};7575-MODULE_DEVICE_TABLE(of, db8500_cpufreq_cooling_match);7676-#endif7777-7878-static struct platform_driver db8500_cpufreq_cooling_driver = {7979- .driver = {8080- .name = "db8500-cpufreq-cooling",8181- .of_match_table = of_match_ptr(db8500_cpufreq_cooling_match),8282- },8383- .probe = db8500_cpufreq_cooling_probe,8484- .suspend = db8500_cpufreq_cooling_suspend,8585- .resume = db8500_cpufreq_cooling_resume,8686- .remove = db8500_cpufreq_cooling_remove,8787-};8888-8989-static int __init db8500_cpufreq_cooling_init(void)9090-{9191- return platform_driver_register(&db8500_cpufreq_cooling_driver);9292-}9393-9494-static void __exit db8500_cpufreq_cooling_exit(void)9595-{9696- platform_driver_unregister(&db8500_cpufreq_cooling_driver);9797-}9898-9999-/* Should be later than db8500_cpufreq_register */100100-late_initcall(db8500_cpufreq_cooling_init);101101-module_exit(db8500_cpufreq_cooling_exit);102102-103103-MODULE_AUTHOR("Hongbo Zhang <hongbo.zhang@stericsson.com>");104104-MODULE_DESCRIPTION("DB8500 cpufreq cooling driver");105105-MODULE_LICENSE("GPL");