b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * linux/drivers/devfreq/freq_table.c |
| 3 | * |
| 4 | * Copyright (C) 2014 Marvell International Ltd. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * 2012-01-13 Qiming Wu<wuqm@marvell.com> |
| 8 | * |
| 9 | * This file is subject to the terms and conditions of the GNU General Public |
| 10 | * License. See the file COPYING in the main directory of this archive for |
| 11 | * more details. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/devfreq.h> |
| 15 | |
| 16 | static struct devfreq_dev_freq_info devices_freq_info[DEVFREQ_MAX_ID]; |
| 17 | |
| 18 | void devfreq_frequency_table_register(struct devfreq_frequency_table *table, |
| 19 | unsigned int dev_id) |
| 20 | { |
| 21 | if (dev_id > DEVFREQ_MAX_ID) { |
| 22 | pr_err("Invalid dev_id %d for devfreq! The max id = %d\n", |
| 23 | dev_id, DEVFREQ_MAX_ID); |
| 24 | BUG_ON(1); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | if (devices_freq_info[dev_id].tbl != NULL) |
| 29 | pr_warn("devfreq freq table %d will be overridden!\n", |
| 30 | dev_id); |
| 31 | |
| 32 | devices_freq_info[dev_id].tbl = table; |
| 33 | } |
| 34 | |
| 35 | struct devfreq_frequency_table *devfreq_frequency_get_table(unsigned int dev_id) |
| 36 | { |
| 37 | if (dev_id > DEVFREQ_MAX_ID) { |
| 38 | pr_err("Invalid dev_id for devfreq! The max id = %d\n", |
| 39 | DEVFREQ_MAX_ID); |
| 40 | BUG_ON(1); |
| 41 | return NULL; |
| 42 | } |
| 43 | |
| 44 | return devices_freq_info[dev_id].tbl; |
| 45 | } |