Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (c) 2018, The Linux Foundation. All rights reserved. |
| 4 | */ |
| 5 | |
| 6 | #include <linux/bitfield.h> |
| 7 | #include <linux/cpufreq.h> |
| 8 | #include <linux/init.h> |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 9 | #include <linux/interconnect.h> |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 10 | #include <linux/kernel.h> |
| 11 | #include <linux/module.h> |
| 12 | #include <linux/of_address.h> |
| 13 | #include <linux/of_platform.h> |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 14 | #include <linux/pm_opp.h> |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 15 | #include <linux/slab.h> |
| 16 | |
| 17 | #define LUT_MAX_ENTRIES 40U |
| 18 | #define LUT_SRC GENMASK(31, 30) |
| 19 | #define LUT_L_VAL GENMASK(7, 0) |
| 20 | #define LUT_CORE_COUNT GENMASK(18, 16) |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 21 | #define LUT_VOLT GENMASK(11, 0) |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 22 | #define LUT_ROW_SIZE 32 |
| 23 | #define CLK_HW_DIV 2 |
Sibi Sankar | 0eae1e3 | 2019-08-07 17:15:43 +0530 | [diff] [blame] | 24 | #define LUT_TURBO_IND 1 |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 25 | |
| 26 | /* Register offsets */ |
| 27 | #define REG_ENABLE 0x0 |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 28 | #define REG_FREQ_LUT 0x110 |
| 29 | #define REG_VOLT_LUT 0x114 |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 30 | #define REG_PERF_STATE 0x920 |
| 31 | |
| 32 | static unsigned long cpu_hw_rate, xo_rate; |
| 33 | static struct platform_device *global_pdev; |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 34 | static bool icc_scaling_enabled; |
| 35 | |
| 36 | static int qcom_cpufreq_set_bw(struct cpufreq_policy *policy, |
| 37 | unsigned long freq_khz) |
| 38 | { |
| 39 | unsigned long freq_hz = freq_khz * 1000; |
| 40 | struct dev_pm_opp *opp; |
| 41 | struct device *dev; |
| 42 | int ret; |
| 43 | |
| 44 | dev = get_cpu_device(policy->cpu); |
| 45 | if (!dev) |
| 46 | return -ENODEV; |
| 47 | |
| 48 | opp = dev_pm_opp_find_freq_exact(dev, freq_hz, true); |
| 49 | if (IS_ERR(opp)) |
| 50 | return PTR_ERR(opp); |
| 51 | |
| 52 | ret = dev_pm_opp_set_bw(dev, opp); |
| 53 | dev_pm_opp_put(opp); |
| 54 | return ret; |
| 55 | } |
| 56 | |
| 57 | static int qcom_cpufreq_update_opp(struct device *cpu_dev, |
| 58 | unsigned long freq_khz, |
| 59 | unsigned long volt) |
| 60 | { |
| 61 | unsigned long freq_hz = freq_khz * 1000; |
| 62 | int ret; |
| 63 | |
| 64 | /* Skip voltage update if the opp table is not available */ |
| 65 | if (!icc_scaling_enabled) |
| 66 | return dev_pm_opp_add(cpu_dev, freq_hz, volt); |
| 67 | |
| 68 | ret = dev_pm_opp_adjust_voltage(cpu_dev, freq_hz, volt, volt, volt); |
| 69 | if (ret) { |
| 70 | dev_err(cpu_dev, "Voltage update failed freq=%ld\n", freq_khz); |
| 71 | return ret; |
| 72 | } |
| 73 | |
| 74 | return dev_pm_opp_enable(cpu_dev, freq_hz); |
| 75 | } |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 76 | |
| 77 | static int qcom_cpufreq_hw_target_index(struct cpufreq_policy *policy, |
| 78 | unsigned int index) |
| 79 | { |
| 80 | void __iomem *perf_state_reg = policy->driver_data; |
Douglas RAILLARD | ada54f3 | 2019-08-08 14:18:57 +0100 | [diff] [blame] | 81 | unsigned long freq = policy->freq_table[index].frequency; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 82 | |
| 83 | writel_relaxed(index, perf_state_reg); |
| 84 | |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 85 | if (icc_scaling_enabled) |
| 86 | qcom_cpufreq_set_bw(policy, freq); |
| 87 | |
Douglas RAILLARD | ada54f3 | 2019-08-08 14:18:57 +0100 | [diff] [blame] | 88 | arch_set_freq_scale(policy->related_cpus, freq, |
| 89 | policy->cpuinfo.max_freq); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | static unsigned int qcom_cpufreq_hw_get(unsigned int cpu) |
| 94 | { |
| 95 | void __iomem *perf_state_reg; |
| 96 | struct cpufreq_policy *policy; |
| 97 | unsigned int index; |
| 98 | |
| 99 | policy = cpufreq_cpu_get_raw(cpu); |
| 100 | if (!policy) |
| 101 | return 0; |
| 102 | |
| 103 | perf_state_reg = policy->driver_data; |
| 104 | |
| 105 | index = readl_relaxed(perf_state_reg); |
| 106 | index = min(index, LUT_MAX_ENTRIES - 1); |
| 107 | |
| 108 | return policy->freq_table[index].frequency; |
| 109 | } |
| 110 | |
| 111 | static unsigned int qcom_cpufreq_hw_fast_switch(struct cpufreq_policy *policy, |
| 112 | unsigned int target_freq) |
| 113 | { |
| 114 | void __iomem *perf_state_reg = policy->driver_data; |
Viresh Kumar | 292072c | 2020-07-30 08:59:40 +0530 | [diff] [blame^] | 115 | unsigned int index; |
Douglas RAILLARD | ada54f3 | 2019-08-08 14:18:57 +0100 | [diff] [blame] | 116 | unsigned long freq; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 117 | |
| 118 | index = policy->cached_resolved_idx; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 119 | writel_relaxed(index, perf_state_reg); |
| 120 | |
Douglas RAILLARD | ada54f3 | 2019-08-08 14:18:57 +0100 | [diff] [blame] | 121 | freq = policy->freq_table[index].frequency; |
| 122 | arch_set_freq_scale(policy->related_cpus, freq, |
| 123 | policy->cpuinfo.max_freq); |
| 124 | |
| 125 | return freq; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 126 | } |
| 127 | |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 128 | static int qcom_cpufreq_hw_read_lut(struct device *cpu_dev, |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 129 | struct cpufreq_policy *policy, |
| 130 | void __iomem *base) |
| 131 | { |
Sibi Sankar | 0eae1e3 | 2019-08-07 17:15:43 +0530 | [diff] [blame] | 132 | u32 data, src, lval, i, core_count, prev_freq = 0, freq; |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 133 | u32 volt; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 134 | struct cpufreq_frequency_table *table; |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 135 | struct dev_pm_opp *opp; |
| 136 | unsigned long rate; |
| 137 | int ret; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 138 | |
| 139 | table = kcalloc(LUT_MAX_ENTRIES + 1, sizeof(*table), GFP_KERNEL); |
| 140 | if (!table) |
| 141 | return -ENOMEM; |
| 142 | |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 143 | ret = dev_pm_opp_of_add_table(cpu_dev); |
| 144 | if (!ret) { |
| 145 | /* Disable all opps and cross-validate against LUT later */ |
| 146 | icc_scaling_enabled = true; |
| 147 | for (rate = 0; ; rate++) { |
| 148 | opp = dev_pm_opp_find_freq_ceil(cpu_dev, &rate); |
| 149 | if (IS_ERR(opp)) |
| 150 | break; |
| 151 | |
| 152 | dev_pm_opp_put(opp); |
| 153 | dev_pm_opp_disable(cpu_dev, rate); |
| 154 | } |
| 155 | } else if (ret != -ENODEV) { |
| 156 | dev_err(cpu_dev, "Invalid opp table in device tree\n"); |
| 157 | return ret; |
| 158 | } else { |
Sibi Sankar | afdb219 | 2020-06-22 13:46:49 +0530 | [diff] [blame] | 159 | policy->fast_switch_possible = true; |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 160 | icc_scaling_enabled = false; |
| 161 | } |
| 162 | |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 163 | for (i = 0; i < LUT_MAX_ENTRIES; i++) { |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 164 | data = readl_relaxed(base + REG_FREQ_LUT + |
| 165 | i * LUT_ROW_SIZE); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 166 | src = FIELD_GET(LUT_SRC, data); |
| 167 | lval = FIELD_GET(LUT_L_VAL, data); |
| 168 | core_count = FIELD_GET(LUT_CORE_COUNT, data); |
| 169 | |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 170 | data = readl_relaxed(base + REG_VOLT_LUT + |
| 171 | i * LUT_ROW_SIZE); |
| 172 | volt = FIELD_GET(LUT_VOLT, data) * 1000; |
| 173 | |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 174 | if (src) |
| 175 | freq = xo_rate * lval / 1000; |
| 176 | else |
| 177 | freq = cpu_hw_rate / 1000; |
| 178 | |
Sibi Sankar | 0eae1e3 | 2019-08-07 17:15:43 +0530 | [diff] [blame] | 179 | if (freq != prev_freq && core_count != LUT_TURBO_IND) { |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 180 | table[i].frequency = freq; |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 181 | qcom_cpufreq_update_opp(cpu_dev, freq, volt); |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 182 | dev_dbg(cpu_dev, "index=%d freq=%d, core_count %d\n", i, |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 183 | freq, core_count); |
Sibi Sankar | 0eae1e3 | 2019-08-07 17:15:43 +0530 | [diff] [blame] | 184 | } else if (core_count == LUT_TURBO_IND) { |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 185 | table[i].frequency = CPUFREQ_ENTRY_INVALID; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | /* |
| 189 | * Two of the same frequencies with the same core counts means |
| 190 | * end of table |
| 191 | */ |
Sibi Sankar | 0eae1e3 | 2019-08-07 17:15:43 +0530 | [diff] [blame] | 192 | if (i > 0 && prev_freq == freq) { |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 193 | struct cpufreq_frequency_table *prev = &table[i - 1]; |
| 194 | |
| 195 | /* |
| 196 | * Only treat the last frequency that might be a boost |
| 197 | * as the boost frequency |
| 198 | */ |
Sibi Sankar | 0eae1e3 | 2019-08-07 17:15:43 +0530 | [diff] [blame] | 199 | if (prev->frequency == CPUFREQ_ENTRY_INVALID) { |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 200 | prev->frequency = prev_freq; |
| 201 | prev->flags = CPUFREQ_BOOST_FREQ; |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 202 | qcom_cpufreq_update_opp(cpu_dev, prev_freq, volt); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | break; |
| 206 | } |
| 207 | |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 208 | prev_freq = freq; |
| 209 | } |
| 210 | |
| 211 | table[i].frequency = CPUFREQ_TABLE_END; |
| 212 | policy->freq_table = table; |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 213 | dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 214 | |
| 215 | return 0; |
| 216 | } |
| 217 | |
| 218 | static void qcom_get_related_cpus(int index, struct cpumask *m) |
| 219 | { |
| 220 | struct device_node *cpu_np; |
| 221 | struct of_phandle_args args; |
| 222 | int cpu, ret; |
| 223 | |
| 224 | for_each_possible_cpu(cpu) { |
| 225 | cpu_np = of_cpu_device_node_get(cpu); |
| 226 | if (!cpu_np) |
| 227 | continue; |
| 228 | |
| 229 | ret = of_parse_phandle_with_args(cpu_np, "qcom,freq-domain", |
| 230 | "#freq-domain-cells", 0, |
| 231 | &args); |
| 232 | of_node_put(cpu_np); |
| 233 | if (ret < 0) |
| 234 | continue; |
| 235 | |
| 236 | if (index == args.args[0]) |
| 237 | cpumask_set_cpu(cpu, m); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy) |
| 242 | { |
| 243 | struct device *dev = &global_pdev->dev; |
| 244 | struct of_phandle_args args; |
| 245 | struct device_node *cpu_np; |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 246 | struct device *cpu_dev; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 247 | struct resource *res; |
| 248 | void __iomem *base; |
| 249 | int ret, index; |
| 250 | |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 251 | cpu_dev = get_cpu_device(policy->cpu); |
| 252 | if (!cpu_dev) { |
| 253 | pr_err("%s: failed to get cpu%d device\n", __func__, |
| 254 | policy->cpu); |
| 255 | return -ENODEV; |
| 256 | } |
| 257 | |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 258 | cpu_np = of_cpu_device_node_get(policy->cpu); |
| 259 | if (!cpu_np) |
| 260 | return -EINVAL; |
| 261 | |
| 262 | ret = of_parse_phandle_with_args(cpu_np, "qcom,freq-domain", |
| 263 | "#freq-domain-cells", 0, &args); |
| 264 | of_node_put(cpu_np); |
| 265 | if (ret) |
| 266 | return ret; |
| 267 | |
| 268 | index = args.args[0]; |
| 269 | |
| 270 | res = platform_get_resource(global_pdev, IORESOURCE_MEM, index); |
| 271 | if (!res) |
| 272 | return -ENODEV; |
| 273 | |
| 274 | base = devm_ioremap(dev, res->start, resource_size(res)); |
| 275 | if (!base) |
| 276 | return -ENOMEM; |
| 277 | |
| 278 | /* HW should be in enabled state to proceed */ |
| 279 | if (!(readl_relaxed(base + REG_ENABLE) & 0x1)) { |
| 280 | dev_err(dev, "Domain-%d cpufreq hardware not enabled\n", index); |
| 281 | ret = -ENODEV; |
| 282 | goto error; |
| 283 | } |
| 284 | |
| 285 | qcom_get_related_cpus(index, policy->cpus); |
| 286 | if (!cpumask_weight(policy->cpus)) { |
| 287 | dev_err(dev, "Domain-%d failed to get related CPUs\n", index); |
| 288 | ret = -ENOENT; |
| 289 | goto error; |
| 290 | } |
| 291 | |
| 292 | policy->driver_data = base + REG_PERF_STATE; |
| 293 | |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 294 | ret = qcom_cpufreq_hw_read_lut(cpu_dev, policy, base); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 295 | if (ret) { |
| 296 | dev_err(dev, "Domain-%d failed to read LUT\n", index); |
| 297 | goto error; |
| 298 | } |
| 299 | |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 300 | ret = dev_pm_opp_get_opp_count(cpu_dev); |
| 301 | if (ret <= 0) { |
| 302 | dev_err(cpu_dev, "Failed to add OPPs\n"); |
| 303 | ret = -ENODEV; |
| 304 | goto error; |
| 305 | } |
| 306 | |
Matthias Kaehlcke | dab5350 | 2019-02-05 09:52:24 -0800 | [diff] [blame] | 307 | dev_pm_opp_of_register_em(policy->cpus); |
| 308 | |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 309 | return 0; |
| 310 | error: |
| 311 | devm_iounmap(dev, base); |
| 312 | return ret; |
| 313 | } |
| 314 | |
| 315 | static int qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy) |
| 316 | { |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 317 | struct device *cpu_dev = get_cpu_device(policy->cpu); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 318 | void __iomem *base = policy->driver_data - REG_PERF_STATE; |
| 319 | |
Taniya Das | 55538fb | 2019-01-31 23:02:50 +0530 | [diff] [blame] | 320 | dev_pm_opp_remove_all_dynamic(cpu_dev); |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 321 | dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 322 | kfree(policy->freq_table); |
| 323 | devm_iounmap(&global_pdev->dev, base); |
| 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | |
| 328 | static struct freq_attr *qcom_cpufreq_hw_attr[] = { |
| 329 | &cpufreq_freq_attr_scaling_available_freqs, |
| 330 | &cpufreq_freq_attr_scaling_boost_freqs, |
| 331 | NULL |
| 332 | }; |
| 333 | |
| 334 | static struct cpufreq_driver cpufreq_qcom_hw_driver = { |
| 335 | .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK | |
Amit Kucheria | 4c5ff1c | 2019-01-29 10:25:09 +0530 | [diff] [blame] | 336 | CPUFREQ_HAVE_GOVERNOR_PER_POLICY | |
| 337 | CPUFREQ_IS_COOLING_DEV, |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 338 | .verify = cpufreq_generic_frequency_table_verify, |
| 339 | .target_index = qcom_cpufreq_hw_target_index, |
| 340 | .get = qcom_cpufreq_hw_get, |
| 341 | .init = qcom_cpufreq_hw_cpu_init, |
| 342 | .exit = qcom_cpufreq_hw_cpu_exit, |
| 343 | .fast_switch = qcom_cpufreq_hw_fast_switch, |
| 344 | .name = "qcom-cpufreq-hw", |
| 345 | .attr = qcom_cpufreq_hw_attr, |
| 346 | }; |
| 347 | |
| 348 | static int qcom_cpufreq_hw_driver_probe(struct platform_device *pdev) |
| 349 | { |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 350 | struct device *cpu_dev; |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 351 | struct clk *clk; |
| 352 | int ret; |
| 353 | |
| 354 | clk = clk_get(&pdev->dev, "xo"); |
| 355 | if (IS_ERR(clk)) |
| 356 | return PTR_ERR(clk); |
| 357 | |
| 358 | xo_rate = clk_get_rate(clk); |
| 359 | clk_put(clk); |
| 360 | |
| 361 | clk = clk_get(&pdev->dev, "alternate"); |
| 362 | if (IS_ERR(clk)) |
| 363 | return PTR_ERR(clk); |
| 364 | |
| 365 | cpu_hw_rate = clk_get_rate(clk) / CLK_HW_DIV; |
| 366 | clk_put(clk); |
| 367 | |
| 368 | global_pdev = pdev; |
| 369 | |
Sibi Sankar | 51c843c | 2020-06-22 13:46:48 +0530 | [diff] [blame] | 370 | /* Check for optional interconnect paths on CPU0 */ |
| 371 | cpu_dev = get_cpu_device(0); |
| 372 | if (!cpu_dev) |
| 373 | return -EPROBE_DEFER; |
| 374 | |
| 375 | ret = dev_pm_opp_of_find_icc_paths(cpu_dev, NULL); |
| 376 | if (ret) |
| 377 | return ret; |
| 378 | |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 379 | ret = cpufreq_register_driver(&cpufreq_qcom_hw_driver); |
| 380 | if (ret) |
| 381 | dev_err(&pdev->dev, "CPUFreq HW driver failed to register\n"); |
| 382 | else |
| 383 | dev_dbg(&pdev->dev, "QCOM CPUFreq HW driver initialized\n"); |
| 384 | |
| 385 | return ret; |
| 386 | } |
| 387 | |
| 388 | static int qcom_cpufreq_hw_driver_remove(struct platform_device *pdev) |
| 389 | { |
| 390 | return cpufreq_unregister_driver(&cpufreq_qcom_hw_driver); |
| 391 | } |
| 392 | |
| 393 | static const struct of_device_id qcom_cpufreq_hw_match[] = { |
| 394 | { .compatible = "qcom,cpufreq-hw" }, |
| 395 | {} |
| 396 | }; |
| 397 | MODULE_DEVICE_TABLE(of, qcom_cpufreq_hw_match); |
| 398 | |
| 399 | static struct platform_driver qcom_cpufreq_hw_driver = { |
| 400 | .probe = qcom_cpufreq_hw_driver_probe, |
| 401 | .remove = qcom_cpufreq_hw_driver_remove, |
| 402 | .driver = { |
| 403 | .name = "qcom-cpufreq-hw", |
| 404 | .of_match_table = qcom_cpufreq_hw_match, |
| 405 | }, |
| 406 | }; |
| 407 | |
| 408 | static int __init qcom_cpufreq_hw_init(void) |
| 409 | { |
| 410 | return platform_driver_register(&qcom_cpufreq_hw_driver); |
| 411 | } |
Amit Kucheria | 11ff4bd | 2019-10-21 17:45:15 +0530 | [diff] [blame] | 412 | postcore_initcall(qcom_cpufreq_hw_init); |
Taniya Das | 2849dd8 | 2018-12-14 09:40:24 +0530 | [diff] [blame] | 413 | |
| 414 | static void __exit qcom_cpufreq_hw_exit(void) |
| 415 | { |
| 416 | platform_driver_unregister(&qcom_cpufreq_hw_driver); |
| 417 | } |
| 418 | module_exit(qcom_cpufreq_hw_exit); |
| 419 | |
| 420 | MODULE_DESCRIPTION("QCOM CPUFREQ HW Driver"); |
| 421 | MODULE_LICENSE("GPL v2"); |