diff options
author | Nitin Kumbhar <nkumbhar@nvidia.com> | 2017-07-25 10:50:28 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-08-17 02:47:43 -0400 |
commit | 046024e1888ed10719d9cdb318446c2872e1bb93 (patch) | |
tree | 0a1dbd0585a45316b07f155dbcdbf15b9c5a4b62 /drivers | |
parent | 32b71a7cd9c852dec5054f07bdfece7bcf569a20 (diff) |
platform: nvadsp: dfs: update freq table
Update adsp cpu frequency table to be specific to
a chip to reflect supported frequencies.
Bug 200295526
Bug 200322504
Change-Id: I538cbe5280212cc6cd54198d2f3d8e4f78664045
Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1526341
(cherry picked from commit ae50e01f2e14c9b9280c4d8d9ef712ef6f38add4)
Reviewed-on: https://git-master.nvidia.com/r/1527566
Reviewed-on: https://git-master.nvidia.com/r/1537338
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/platform/tegra/nvadsp/adsp_dfs.c | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/drivers/platform/tegra/nvadsp/adsp_dfs.c b/drivers/platform/tegra/nvadsp/adsp_dfs.c index 9e3974ce4..9ce0cdd44 100644 --- a/drivers/platform/tegra/nvadsp/adsp_dfs.c +++ b/drivers/platform/tegra/nvadsp/adsp_dfs.c | |||
@@ -47,7 +47,7 @@ enum adsp_dfs_reply { | |||
47 | * Freqency in Hz.The frequency always needs to be a multiple of 12.8 Mhz and | 47 | * Freqency in Hz.The frequency always needs to be a multiple of 12.8 Mhz and |
48 | * should be extended with a slab 38.4 Mhz. | 48 | * should be extended with a slab 38.4 Mhz. |
49 | */ | 49 | */ |
50 | static unsigned long adsp_cpu_freq_table[] = { | 50 | static unsigned long adsp_cpu_freq_table_t21x[] = { |
51 | MIN_ADSP_FREQ, | 51 | MIN_ADSP_FREQ, |
52 | MIN_ADSP_FREQ * 2, | 52 | MIN_ADSP_FREQ * 2, |
53 | MIN_ADSP_FREQ * 3, | 53 | MIN_ADSP_FREQ * 3, |
@@ -71,6 +71,18 @@ static unsigned long adsp_cpu_freq_table[] = { | |||
71 | MIN_ADSP_FREQ * 21, | 71 | MIN_ADSP_FREQ * 21, |
72 | }; | 72 | }; |
73 | 73 | ||
74 | /* | ||
75 | * Frequency in Hz. | ||
76 | */ | ||
77 | static unsigned long adsp_cpu_freq_table_t18x[] = { | ||
78 | 150000000lu, | ||
79 | 300000000lu, | ||
80 | 600000000lu, | ||
81 | }; | ||
82 | |||
83 | static unsigned long *adsp_cpu_freq_table; | ||
84 | static int adsp_cpu_freq_table_size; | ||
85 | |||
74 | struct adsp_dfs_policy { | 86 | struct adsp_dfs_policy { |
75 | bool enable; | 87 | bool enable; |
76 | /* update_freq_flag = TRUE, ADSP ACKed the new freq | 88 | /* update_freq_flag = TRUE, ADSP ACKed the new freq |
@@ -96,12 +108,17 @@ struct adsp_dfs_policy { | |||
96 | unsigned long ovr_freq; | 108 | unsigned long ovr_freq; |
97 | }; | 109 | }; |
98 | 110 | ||
111 | |||
112 | |||
113 | #define MAX_SIZE(x, y) (x > y ? x : y) | ||
114 | #define TIME_IN_STATE_SIZE MAX_SIZE(ARRAY_SIZE(adsp_cpu_freq_table_t21x), \ | ||
115 | ARRAY_SIZE(adsp_cpu_freq_table_t18x)) | ||
99 | struct adsp_freq_stats { | 116 | struct adsp_freq_stats { |
100 | struct device *dev; | 117 | struct device *dev; |
101 | unsigned long long last_time; | 118 | unsigned long long last_time; |
102 | int last_index; | 119 | int last_index; |
103 | u64 time_in_state[sizeof(adsp_cpu_freq_table) \ | 120 | u64 time_in_state[TIME_IN_STATE_SIZE]; |
104 | / sizeof(adsp_cpu_freq_table[0])]; | 121 | |
105 | int state_num; | 122 | int state_num; |
106 | }; | 123 | }; |
107 | 124 | ||
@@ -190,11 +207,28 @@ static unsigned long adsp_clk_get_rate(struct adsp_dfs_policy *policy) | |||
190 | return clk_get_rate(policy->adsp_clk); | 207 | return clk_get_rate(policy->adsp_clk); |
191 | } | 208 | } |
192 | 209 | ||
210 | static void adsp_cpu_freq_table_setup(struct platform_device *pdev) | ||
211 | { | ||
212 | struct device *dev = &pdev->dev; | ||
213 | struct device_node *node = dev->of_node; | ||
214 | |||
215 | if (adsp_cpu_freq_table) | ||
216 | return; | ||
217 | |||
218 | if (of_device_is_compatible(node, "nvidia,tegra210-adsp")) { | ||
219 | adsp_cpu_freq_table = adsp_cpu_freq_table_t21x; | ||
220 | adsp_cpu_freq_table_size = ARRAY_SIZE(adsp_cpu_freq_table_t21x); | ||
221 | } else { | ||
222 | adsp_cpu_freq_table = adsp_cpu_freq_table_t18x; | ||
223 | adsp_cpu_freq_table_size = ARRAY_SIZE(adsp_cpu_freq_table_t18x); | ||
224 | } | ||
225 | } | ||
226 | |||
193 | /* Expects and returns freq in Hz as table is formmed in terms of Hz */ | 227 | /* Expects and returns freq in Hz as table is formmed in terms of Hz */ |
194 | static unsigned long adsp_get_target_freq(unsigned long tfreq, int *index) | 228 | static unsigned long adsp_get_target_freq(unsigned long tfreq, int *index) |
195 | { | 229 | { |
196 | int i; | 230 | int i; |
197 | int size = sizeof(adsp_cpu_freq_table) / sizeof(adsp_cpu_freq_table[0]); | 231 | int size = adsp_cpu_freq_table_size; |
198 | 232 | ||
199 | if (tfreq <= adsp_cpu_freq_table[0]) { | 233 | if (tfreq <= adsp_cpu_freq_table[0]) { |
200 | *index = 0; | 234 | *index = 0; |
@@ -795,7 +829,7 @@ void adsp_update_dfs(bool val) | |||
795 | /* Should be called after ADSP os is loaded */ | 829 | /* Should be called after ADSP os is loaded */ |
796 | int adsp_dfs_core_init(struct platform_device *pdev) | 830 | int adsp_dfs_core_init(struct platform_device *pdev) |
797 | { | 831 | { |
798 | int size = sizeof(adsp_cpu_freq_table) / sizeof(adsp_cpu_freq_table[0]); | 832 | int size = adsp_cpu_freq_table_size; |
799 | struct nvadsp_drv_data *drv = platform_get_drvdata(pdev); | 833 | struct nvadsp_drv_data *drv = platform_get_drvdata(pdev); |
800 | uint16_t mid = HOST_ADSP_DFS_MBOX_ID; | 834 | uint16_t mid = HOST_ADSP_DFS_MBOX_ID; |
801 | int ret = 0; | 835 | int ret = 0; |
@@ -807,6 +841,10 @@ int adsp_dfs_core_init(struct platform_device *pdev) | |||
807 | device = &pdev->dev; | 841 | device = &pdev->dev; |
808 | policy = &dfs_policy; | 842 | policy = &dfs_policy; |
809 | 843 | ||
844 | /* Set up adsp cpu freq table as per chip */ | ||
845 | if (!adsp_cpu_freq_table) | ||
846 | adsp_cpu_freq_table_setup(pdev); | ||
847 | |||
810 | ret = adsp_clk_get(policy); | 848 | ret = adsp_clk_get(policy); |
811 | if (ret) | 849 | if (ret) |
812 | goto end; | 850 | goto end; |