MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1 | /* drivers/devfreq/exynos4210_memorybus.c |
| 2 | * |
| 3 | * Copyright (c) 2011 Samsung Electronics Co., Ltd. |
| 4 | * http://www.samsung.com/ |
| 5 | * MyungJoo Ham <myungjoo.ham@samsung.com> |
| 6 | * |
| 7 | * EXYNOS4 - Memory/Bus clock frequency scaling support in DEVFREQ framework |
| 8 | * This version supports EXYNOS4210 only. This changes bus frequencies |
| 9 | * and vddint voltages. Exynos4412/4212 should be able to be supported |
| 10 | * with minor modifications. |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License version 2 as |
| 14 | * published by the Free Software Foundation. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | #include <linux/io.h> |
| 19 | #include <linux/slab.h> |
| 20 | #include <linux/mutex.h> |
| 21 | #include <linux/suspend.h> |
Nishanth Menon | e4db1c7 | 2013-09-19 16:03:52 -0500 | [diff] [blame] | 22 | #include <linux/pm_opp.h> |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 23 | #include <linux/devfreq.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/regulator/consumer.h> |
| 26 | #include <linux/module.h> |
| 27 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 28 | #include <mach/map.h> |
| 29 | |
| 30 | #include "exynos_ppmu.h" |
| 31 | #include "exynos4_bus.h" |
| 32 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 33 | /* Exynos4 ASV has been in the mailing list, but not upstreamed, yet. */ |
| 34 | #ifdef CONFIG_EXYNOS_ASV |
| 35 | extern unsigned int exynos_result_of_asv; |
| 36 | #endif |
| 37 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 38 | #define MAX_SAFEVOLT 1200000 /* 1.2V */ |
| 39 | |
| 40 | enum exynos4_busf_type { |
| 41 | TYPE_BUSF_EXYNOS4210, |
| 42 | TYPE_BUSF_EXYNOS4x12, |
| 43 | }; |
| 44 | |
| 45 | /* Assume that the bus is saturated if the utilization is 40% */ |
| 46 | #define BUS_SATURATION_RATIO 40 |
| 47 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 48 | enum busclk_level_idx { |
| 49 | LV_0 = 0, |
| 50 | LV_1, |
| 51 | LV_2, |
| 52 | LV_3, |
| 53 | LV_4, |
| 54 | _LV_END |
| 55 | }; |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 56 | |
| 57 | enum exynos_ppmu_idx { |
| 58 | PPMU_DMC0, |
| 59 | PPMU_DMC1, |
| 60 | PPMU_END, |
| 61 | }; |
| 62 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 63 | #define EX4210_LV_MAX LV_2 |
| 64 | #define EX4x12_LV_MAX LV_4 |
| 65 | #define EX4210_LV_NUM (LV_2 + 1) |
| 66 | #define EX4x12_LV_NUM (LV_4 + 1) |
| 67 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 68 | /** |
| 69 | * struct busfreq_opp_info - opp information for bus |
| 70 | * @rate: Frequency in hertz |
| 71 | * @volt: Voltage in microvolts corresponding to this OPP |
| 72 | */ |
| 73 | struct busfreq_opp_info { |
| 74 | unsigned long rate; |
| 75 | unsigned long volt; |
| 76 | }; |
| 77 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 78 | struct busfreq_ppmu_data { |
| 79 | struct exynos_ppmu *ppmu; |
| 80 | int ppmu_end; |
| 81 | }; |
| 82 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 83 | struct busfreq_data { |
| 84 | enum exynos4_busf_type type; |
| 85 | struct device *dev; |
| 86 | struct devfreq *devfreq; |
| 87 | bool disabled; |
| 88 | struct regulator *vdd_int; |
| 89 | struct regulator *vdd_mif; /* Exynos4412/4212 only */ |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 90 | struct busfreq_opp_info curr_oppinfo; |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 91 | struct busfreq_ppmu_data ppmu_data; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 92 | |
| 93 | struct notifier_block pm_notifier; |
| 94 | struct mutex lock; |
| 95 | |
| 96 | /* Dividers calculated at boot/probe-time */ |
| 97 | unsigned int dmc_divtable[_LV_END]; /* DMC0 */ |
| 98 | unsigned int top_divtable[_LV_END]; |
| 99 | }; |
| 100 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 101 | /* 4210 controls clock of mif and voltage of int */ |
| 102 | static struct bus_opp_table exynos4210_busclk_table[] = { |
| 103 | {LV_0, 400000, 1150000}, |
| 104 | {LV_1, 267000, 1050000}, |
| 105 | {LV_2, 133000, 1025000}, |
| 106 | {0, 0, 0}, |
| 107 | }; |
| 108 | |
| 109 | /* |
Sachin Kamat | 1d6c2c0 | 2013-11-27 14:50:26 +0530 | [diff] [blame] | 110 | * MIF is the main control knob clock for Exynos4x12 MIF/INT |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 111 | * clock and voltage of both mif/int are controlled. |
| 112 | */ |
| 113 | static struct bus_opp_table exynos4x12_mifclk_table[] = { |
| 114 | {LV_0, 400000, 1100000}, |
| 115 | {LV_1, 267000, 1000000}, |
| 116 | {LV_2, 160000, 950000}, |
| 117 | {LV_3, 133000, 950000}, |
| 118 | {LV_4, 100000, 950000}, |
| 119 | {0, 0, 0}, |
| 120 | }; |
| 121 | |
| 122 | /* |
| 123 | * INT is not the control knob of 4x12. LV_x is not meant to represent |
| 124 | * the current performance. (MIF does) |
| 125 | */ |
| 126 | static struct bus_opp_table exynos4x12_intclk_table[] = { |
| 127 | {LV_0, 200000, 1000000}, |
| 128 | {LV_1, 160000, 950000}, |
| 129 | {LV_2, 133000, 925000}, |
| 130 | {LV_3, 100000, 900000}, |
| 131 | {0, 0, 0}, |
| 132 | }; |
| 133 | |
| 134 | /* TODO: asv volt definitions are "__initdata"? */ |
| 135 | /* Some chips have different operating voltages */ |
| 136 | static unsigned int exynos4210_asv_volt[][EX4210_LV_NUM] = { |
| 137 | {1150000, 1050000, 1050000}, |
| 138 | {1125000, 1025000, 1025000}, |
| 139 | {1100000, 1000000, 1000000}, |
| 140 | {1075000, 975000, 975000}, |
| 141 | {1050000, 950000, 950000}, |
| 142 | }; |
| 143 | |
| 144 | static unsigned int exynos4x12_mif_step_50[][EX4x12_LV_NUM] = { |
| 145 | /* 400 267 160 133 100 */ |
| 146 | {1050000, 950000, 900000, 900000, 900000}, /* ASV0 */ |
| 147 | {1050000, 950000, 900000, 900000, 900000}, /* ASV1 */ |
| 148 | {1050000, 950000, 900000, 900000, 900000}, /* ASV2 */ |
| 149 | {1050000, 900000, 900000, 900000, 900000}, /* ASV3 */ |
| 150 | {1050000, 900000, 900000, 900000, 850000}, /* ASV4 */ |
| 151 | {1050000, 900000, 900000, 850000, 850000}, /* ASV5 */ |
| 152 | {1050000, 900000, 850000, 850000, 850000}, /* ASV6 */ |
| 153 | {1050000, 900000, 850000, 850000, 850000}, /* ASV7 */ |
| 154 | {1050000, 900000, 850000, 850000, 850000}, /* ASV8 */ |
| 155 | }; |
| 156 | |
| 157 | static unsigned int exynos4x12_int_volt[][EX4x12_LV_NUM] = { |
| 158 | /* 200 160 133 100 */ |
| 159 | {1000000, 950000, 925000, 900000}, /* ASV0 */ |
| 160 | {975000, 925000, 925000, 900000}, /* ASV1 */ |
| 161 | {950000, 925000, 900000, 875000}, /* ASV2 */ |
| 162 | {950000, 900000, 900000, 875000}, /* ASV3 */ |
| 163 | {925000, 875000, 875000, 875000}, /* ASV4 */ |
| 164 | {900000, 850000, 850000, 850000}, /* ASV5 */ |
| 165 | {900000, 850000, 850000, 850000}, /* ASV6 */ |
| 166 | {900000, 850000, 850000, 850000}, /* ASV7 */ |
| 167 | {900000, 850000, 850000, 850000}, /* ASV8 */ |
| 168 | }; |
| 169 | |
| 170 | /*** Clock Divider Data for Exynos4210 ***/ |
| 171 | static unsigned int exynos4210_clkdiv_dmc0[][8] = { |
| 172 | /* |
| 173 | * Clock divider value for following |
| 174 | * { DIVACP, DIVACP_PCLK, DIVDPHY, DIVDMC, DIVDMCD |
| 175 | * DIVDMCP, DIVCOPY2, DIVCORE_TIMERS } |
| 176 | */ |
| 177 | |
| 178 | /* DMC L0: 400MHz */ |
| 179 | { 3, 1, 1, 1, 1, 1, 3, 1 }, |
| 180 | /* DMC L1: 266.7MHz */ |
| 181 | { 4, 1, 1, 2, 1, 1, 3, 1 }, |
| 182 | /* DMC L2: 133MHz */ |
| 183 | { 5, 1, 1, 5, 1, 1, 3, 1 }, |
| 184 | }; |
| 185 | static unsigned int exynos4210_clkdiv_top[][5] = { |
| 186 | /* |
| 187 | * Clock divider value for following |
| 188 | * { DIVACLK200, DIVACLK100, DIVACLK160, DIVACLK133, DIVONENAND } |
| 189 | */ |
| 190 | /* ACLK200 L0: 200MHz */ |
| 191 | { 3, 7, 4, 5, 1 }, |
| 192 | /* ACLK200 L1: 160MHz */ |
| 193 | { 4, 7, 5, 6, 1 }, |
| 194 | /* ACLK200 L2: 133MHz */ |
| 195 | { 5, 7, 7, 7, 1 }, |
| 196 | }; |
| 197 | static unsigned int exynos4210_clkdiv_lr_bus[][2] = { |
| 198 | /* |
| 199 | * Clock divider value for following |
| 200 | * { DIVGDL/R, DIVGPL/R } |
| 201 | */ |
| 202 | /* ACLK_GDL/R L1: 200MHz */ |
| 203 | { 3, 1 }, |
| 204 | /* ACLK_GDL/R L2: 160MHz */ |
| 205 | { 4, 1 }, |
| 206 | /* ACLK_GDL/R L3: 133MHz */ |
| 207 | { 5, 1 }, |
| 208 | }; |
| 209 | |
| 210 | /*** Clock Divider Data for Exynos4212/4412 ***/ |
| 211 | static unsigned int exynos4x12_clkdiv_dmc0[][6] = { |
| 212 | /* |
| 213 | * Clock divider value for following |
| 214 | * { DIVACP, DIVACP_PCLK, DIVDPHY, DIVDMC, DIVDMCD |
| 215 | * DIVDMCP} |
| 216 | */ |
| 217 | |
| 218 | /* DMC L0: 400MHz */ |
| 219 | {3, 1, 1, 1, 1, 1}, |
| 220 | /* DMC L1: 266.7MHz */ |
| 221 | {4, 1, 1, 2, 1, 1}, |
| 222 | /* DMC L2: 160MHz */ |
| 223 | {5, 1, 1, 4, 1, 1}, |
| 224 | /* DMC L3: 133MHz */ |
| 225 | {5, 1, 1, 5, 1, 1}, |
| 226 | /* DMC L4: 100MHz */ |
| 227 | {7, 1, 1, 7, 1, 1}, |
| 228 | }; |
| 229 | static unsigned int exynos4x12_clkdiv_dmc1[][6] = { |
| 230 | /* |
| 231 | * Clock divider value for following |
| 232 | * { G2DACP, DIVC2C, DIVC2C_ACLK } |
| 233 | */ |
| 234 | |
| 235 | /* DMC L0: 400MHz */ |
| 236 | {3, 1, 1}, |
| 237 | /* DMC L1: 266.7MHz */ |
| 238 | {4, 2, 1}, |
| 239 | /* DMC L2: 160MHz */ |
| 240 | {5, 4, 1}, |
| 241 | /* DMC L3: 133MHz */ |
| 242 | {5, 5, 1}, |
| 243 | /* DMC L4: 100MHz */ |
| 244 | {7, 7, 1}, |
| 245 | }; |
| 246 | static unsigned int exynos4x12_clkdiv_top[][5] = { |
| 247 | /* |
| 248 | * Clock divider value for following |
| 249 | * { DIVACLK266_GPS, DIVACLK100, DIVACLK160, |
| 250 | DIVACLK133, DIVONENAND } |
| 251 | */ |
| 252 | |
| 253 | /* ACLK_GDL/R L0: 200MHz */ |
| 254 | {2, 7, 4, 5, 1}, |
| 255 | /* ACLK_GDL/R L1: 200MHz */ |
| 256 | {2, 7, 4, 5, 1}, |
| 257 | /* ACLK_GDL/R L2: 160MHz */ |
| 258 | {4, 7, 5, 7, 1}, |
| 259 | /* ACLK_GDL/R L3: 133MHz */ |
| 260 | {4, 7, 5, 7, 1}, |
| 261 | /* ACLK_GDL/R L4: 100MHz */ |
| 262 | {7, 7, 7, 7, 1}, |
| 263 | }; |
| 264 | static unsigned int exynos4x12_clkdiv_lr_bus[][2] = { |
| 265 | /* |
| 266 | * Clock divider value for following |
| 267 | * { DIVGDL/R, DIVGPL/R } |
| 268 | */ |
| 269 | |
| 270 | /* ACLK_GDL/R L0: 200MHz */ |
| 271 | {3, 1}, |
| 272 | /* ACLK_GDL/R L1: 200MHz */ |
| 273 | {3, 1}, |
| 274 | /* ACLK_GDL/R L2: 160MHz */ |
| 275 | {4, 1}, |
| 276 | /* ACLK_GDL/R L3: 133MHz */ |
| 277 | {5, 1}, |
| 278 | /* ACLK_GDL/R L4: 100MHz */ |
| 279 | {7, 1}, |
| 280 | }; |
| 281 | static unsigned int exynos4x12_clkdiv_sclkip[][3] = { |
| 282 | /* |
| 283 | * Clock divider value for following |
| 284 | * { DIVMFC, DIVJPEG, DIVFIMC0~3} |
| 285 | */ |
| 286 | |
| 287 | /* SCLK_MFC: 200MHz */ |
| 288 | {3, 3, 4}, |
| 289 | /* SCLK_MFC: 200MHz */ |
| 290 | {3, 3, 4}, |
| 291 | /* SCLK_MFC: 160MHz */ |
| 292 | {4, 4, 5}, |
| 293 | /* SCLK_MFC: 133MHz */ |
| 294 | {5, 5, 5}, |
| 295 | /* SCLK_MFC: 100MHz */ |
| 296 | {7, 7, 7}, |
| 297 | }; |
| 298 | |
| 299 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 300 | static int exynos4210_set_busclk(struct busfreq_data *data, |
| 301 | struct busfreq_opp_info *oppi) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 302 | { |
| 303 | unsigned int index; |
| 304 | unsigned int tmp; |
| 305 | |
| 306 | for (index = LV_0; index < EX4210_LV_NUM; index++) |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 307 | if (oppi->rate == exynos4210_busclk_table[index].clk) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 308 | break; |
| 309 | |
| 310 | if (index == EX4210_LV_NUM) |
| 311 | return -EINVAL; |
| 312 | |
| 313 | /* Change Divider - DMC0 */ |
| 314 | tmp = data->dmc_divtable[index]; |
| 315 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 316 | __raw_writel(tmp, EXYNOS4_CLKDIV_DMC0); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 317 | |
| 318 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 319 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_DMC0); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 320 | } while (tmp & 0x11111111); |
| 321 | |
| 322 | /* Change Divider - TOP */ |
| 323 | tmp = data->top_divtable[index]; |
| 324 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 325 | __raw_writel(tmp, EXYNOS4_CLKDIV_TOP); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 326 | |
| 327 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 328 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_TOP); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 329 | } while (tmp & 0x11111); |
| 330 | |
| 331 | /* Change Divider - LEFTBUS */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 332 | tmp = __raw_readl(EXYNOS4_CLKDIV_LEFTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 333 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 334 | tmp &= ~(EXYNOS4_CLKDIV_BUS_GDLR_MASK | EXYNOS4_CLKDIV_BUS_GPLR_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 335 | |
| 336 | tmp |= ((exynos4210_clkdiv_lr_bus[index][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 337 | EXYNOS4_CLKDIV_BUS_GDLR_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 338 | (exynos4210_clkdiv_lr_bus[index][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 339 | EXYNOS4_CLKDIV_BUS_GPLR_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 340 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 341 | __raw_writel(tmp, EXYNOS4_CLKDIV_LEFTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 342 | |
| 343 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 344 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_LEFTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 345 | } while (tmp & 0x11); |
| 346 | |
| 347 | /* Change Divider - RIGHTBUS */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 348 | tmp = __raw_readl(EXYNOS4_CLKDIV_RIGHTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 349 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 350 | tmp &= ~(EXYNOS4_CLKDIV_BUS_GDLR_MASK | EXYNOS4_CLKDIV_BUS_GPLR_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 351 | |
| 352 | tmp |= ((exynos4210_clkdiv_lr_bus[index][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 353 | EXYNOS4_CLKDIV_BUS_GDLR_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 354 | (exynos4210_clkdiv_lr_bus[index][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 355 | EXYNOS4_CLKDIV_BUS_GPLR_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 356 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 357 | __raw_writel(tmp, EXYNOS4_CLKDIV_RIGHTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 358 | |
| 359 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 360 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_RIGHTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 361 | } while (tmp & 0x11); |
| 362 | |
| 363 | return 0; |
| 364 | } |
| 365 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 366 | static int exynos4x12_set_busclk(struct busfreq_data *data, |
| 367 | struct busfreq_opp_info *oppi) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 368 | { |
| 369 | unsigned int index; |
| 370 | unsigned int tmp; |
| 371 | |
| 372 | for (index = LV_0; index < EX4x12_LV_NUM; index++) |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 373 | if (oppi->rate == exynos4x12_mifclk_table[index].clk) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 374 | break; |
| 375 | |
| 376 | if (index == EX4x12_LV_NUM) |
| 377 | return -EINVAL; |
| 378 | |
| 379 | /* Change Divider - DMC0 */ |
| 380 | tmp = data->dmc_divtable[index]; |
| 381 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 382 | __raw_writel(tmp, EXYNOS4_CLKDIV_DMC0); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 383 | |
| 384 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 385 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_DMC0); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 386 | } while (tmp & 0x11111111); |
| 387 | |
| 388 | /* Change Divider - DMC1 */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 389 | tmp = __raw_readl(EXYNOS4_CLKDIV_DMC1); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 390 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 391 | tmp &= ~(EXYNOS4_CLKDIV_DMC1_G2D_ACP_MASK | |
| 392 | EXYNOS4_CLKDIV_DMC1_C2C_MASK | |
| 393 | EXYNOS4_CLKDIV_DMC1_C2CACLK_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 394 | |
| 395 | tmp |= ((exynos4x12_clkdiv_dmc1[index][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 396 | EXYNOS4_CLKDIV_DMC1_G2D_ACP_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 397 | (exynos4x12_clkdiv_dmc1[index][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 398 | EXYNOS4_CLKDIV_DMC1_C2C_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 399 | (exynos4x12_clkdiv_dmc1[index][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 400 | EXYNOS4_CLKDIV_DMC1_C2CACLK_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 401 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 402 | __raw_writel(tmp, EXYNOS4_CLKDIV_DMC1); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 403 | |
| 404 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 405 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_DMC1); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 406 | } while (tmp & 0x111111); |
| 407 | |
| 408 | /* Change Divider - TOP */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 409 | tmp = __raw_readl(EXYNOS4_CLKDIV_TOP); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 410 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 411 | tmp &= ~(EXYNOS4_CLKDIV_TOP_ACLK266_GPS_MASK | |
| 412 | EXYNOS4_CLKDIV_TOP_ACLK100_MASK | |
| 413 | EXYNOS4_CLKDIV_TOP_ACLK160_MASK | |
| 414 | EXYNOS4_CLKDIV_TOP_ACLK133_MASK | |
| 415 | EXYNOS4_CLKDIV_TOP_ONENAND_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 416 | |
| 417 | tmp |= ((exynos4x12_clkdiv_top[index][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 418 | EXYNOS4_CLKDIV_TOP_ACLK266_GPS_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 419 | (exynos4x12_clkdiv_top[index][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 420 | EXYNOS4_CLKDIV_TOP_ACLK100_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 421 | (exynos4x12_clkdiv_top[index][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 422 | EXYNOS4_CLKDIV_TOP_ACLK160_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 423 | (exynos4x12_clkdiv_top[index][3] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 424 | EXYNOS4_CLKDIV_TOP_ACLK133_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 425 | (exynos4x12_clkdiv_top[index][4] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 426 | EXYNOS4_CLKDIV_TOP_ONENAND_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 427 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 428 | __raw_writel(tmp, EXYNOS4_CLKDIV_TOP); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 429 | |
| 430 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 431 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_TOP); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 432 | } while (tmp & 0x11111); |
| 433 | |
| 434 | /* Change Divider - LEFTBUS */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 435 | tmp = __raw_readl(EXYNOS4_CLKDIV_LEFTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 436 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 437 | tmp &= ~(EXYNOS4_CLKDIV_BUS_GDLR_MASK | EXYNOS4_CLKDIV_BUS_GPLR_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 438 | |
| 439 | tmp |= ((exynos4x12_clkdiv_lr_bus[index][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 440 | EXYNOS4_CLKDIV_BUS_GDLR_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 441 | (exynos4x12_clkdiv_lr_bus[index][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 442 | EXYNOS4_CLKDIV_BUS_GPLR_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 443 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 444 | __raw_writel(tmp, EXYNOS4_CLKDIV_LEFTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 445 | |
| 446 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 447 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_LEFTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 448 | } while (tmp & 0x11); |
| 449 | |
| 450 | /* Change Divider - RIGHTBUS */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 451 | tmp = __raw_readl(EXYNOS4_CLKDIV_RIGHTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 452 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 453 | tmp &= ~(EXYNOS4_CLKDIV_BUS_GDLR_MASK | EXYNOS4_CLKDIV_BUS_GPLR_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 454 | |
| 455 | tmp |= ((exynos4x12_clkdiv_lr_bus[index][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 456 | EXYNOS4_CLKDIV_BUS_GDLR_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 457 | (exynos4x12_clkdiv_lr_bus[index][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 458 | EXYNOS4_CLKDIV_BUS_GPLR_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 459 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 460 | __raw_writel(tmp, EXYNOS4_CLKDIV_RIGHTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 461 | |
| 462 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 463 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_RIGHTBUS); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 464 | } while (tmp & 0x11); |
| 465 | |
| 466 | /* Change Divider - MFC */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 467 | tmp = __raw_readl(EXYNOS4_CLKDIV_MFC); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 468 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 469 | tmp &= ~(EXYNOS4_CLKDIV_MFC_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 470 | |
| 471 | tmp |= ((exynos4x12_clkdiv_sclkip[index][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 472 | EXYNOS4_CLKDIV_MFC_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 473 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 474 | __raw_writel(tmp, EXYNOS4_CLKDIV_MFC); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 475 | |
| 476 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 477 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_MFC); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 478 | } while (tmp & 0x1); |
| 479 | |
| 480 | /* Change Divider - JPEG */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 481 | tmp = __raw_readl(EXYNOS4_CLKDIV_CAM1); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 482 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 483 | tmp &= ~(EXYNOS4_CLKDIV_CAM1_JPEG_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 484 | |
| 485 | tmp |= ((exynos4x12_clkdiv_sclkip[index][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 486 | EXYNOS4_CLKDIV_CAM1_JPEG_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 487 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 488 | __raw_writel(tmp, EXYNOS4_CLKDIV_CAM1); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 489 | |
| 490 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 491 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_CAM1); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 492 | } while (tmp & 0x1); |
| 493 | |
| 494 | /* Change Divider - FIMC0~3 */ |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 495 | tmp = __raw_readl(EXYNOS4_CLKDIV_CAM); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 496 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 497 | tmp &= ~(EXYNOS4_CLKDIV_CAM_FIMC0_MASK | EXYNOS4_CLKDIV_CAM_FIMC1_MASK | |
| 498 | EXYNOS4_CLKDIV_CAM_FIMC2_MASK | EXYNOS4_CLKDIV_CAM_FIMC3_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 499 | |
| 500 | tmp |= ((exynos4x12_clkdiv_sclkip[index][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 501 | EXYNOS4_CLKDIV_CAM_FIMC0_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 502 | (exynos4x12_clkdiv_sclkip[index][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 503 | EXYNOS4_CLKDIV_CAM_FIMC1_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 504 | (exynos4x12_clkdiv_sclkip[index][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 505 | EXYNOS4_CLKDIV_CAM_FIMC2_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 506 | (exynos4x12_clkdiv_sclkip[index][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 507 | EXYNOS4_CLKDIV_CAM_FIMC3_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 508 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 509 | __raw_writel(tmp, EXYNOS4_CLKDIV_CAM); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 510 | |
| 511 | do { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 512 | tmp = __raw_readl(EXYNOS4_CLKDIV_STAT_CAM1); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 513 | } while (tmp & 0x1111); |
| 514 | |
| 515 | return 0; |
| 516 | } |
| 517 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 518 | static void busfreq_mon_reset(struct busfreq_ppmu_data *ppmu_data) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 519 | { |
| 520 | unsigned int i; |
| 521 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 522 | for (i = 0; i < ppmu_data->ppmu_end; i++) { |
| 523 | void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 524 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 525 | /* Reset the performance and cycle counters */ |
| 526 | exynos_ppmu_reset(ppmu_base); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 527 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 528 | /* Setup count registers to monitor read/write transactions */ |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 529 | ppmu_data->ppmu[i].event[PPMU_PMNCNT3] = RDWR_DATA_COUNT; |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 530 | exynos_ppmu_setevent(ppmu_base, PPMU_PMNCNT3, |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 531 | ppmu_data->ppmu[i].event[PPMU_PMNCNT3]); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 532 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 533 | exynos_ppmu_start(ppmu_base); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 534 | } |
| 535 | } |
| 536 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 537 | static void exynos4_read_ppmu(struct busfreq_ppmu_data *ppmu_data) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 538 | { |
| 539 | int i, j; |
| 540 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 541 | for (i = 0; i < ppmu_data->ppmu_end; i++) { |
| 542 | void __iomem *ppmu_base = ppmu_data->ppmu[i].hw_base; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 543 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 544 | exynos_ppmu_stop(ppmu_base); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 545 | |
| 546 | /* Update local data from PPMU */ |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 547 | ppmu_data->ppmu[i].ccnt = __raw_readl(ppmu_base + PPMU_CCNT); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 548 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 549 | for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) { |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 550 | if (ppmu_data->ppmu[i].event[j] == 0) |
| 551 | ppmu_data->ppmu[i].count[j] = 0; |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 552 | else |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 553 | ppmu_data->ppmu[i].count[j] = |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 554 | exynos_ppmu_read(ppmu_base, j); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 555 | } |
| 556 | } |
| 557 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 558 | busfreq_mon_reset(ppmu_data); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | static int exynos4x12_get_intspec(unsigned long mifclk) |
| 562 | { |
| 563 | int i = 0; |
| 564 | |
| 565 | while (exynos4x12_intclk_table[i].clk) { |
| 566 | if (exynos4x12_intclk_table[i].clk <= mifclk) |
| 567 | return i; |
| 568 | i++; |
| 569 | } |
| 570 | |
| 571 | return -EINVAL; |
| 572 | } |
| 573 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 574 | static int exynos4_bus_setvolt(struct busfreq_data *data, |
| 575 | struct busfreq_opp_info *oppi, |
| 576 | struct busfreq_opp_info *oldoppi) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 577 | { |
| 578 | int err = 0, tmp; |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 579 | unsigned long volt = oppi->volt; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 580 | |
| 581 | switch (data->type) { |
| 582 | case TYPE_BUSF_EXYNOS4210: |
| 583 | /* OPP represents DMC clock + INT voltage */ |
| 584 | err = regulator_set_voltage(data->vdd_int, volt, |
| 585 | MAX_SAFEVOLT); |
| 586 | break; |
| 587 | case TYPE_BUSF_EXYNOS4x12: |
| 588 | /* OPP represents MIF clock + MIF voltage */ |
| 589 | err = regulator_set_voltage(data->vdd_mif, volt, |
| 590 | MAX_SAFEVOLT); |
| 591 | if (err) |
| 592 | break; |
| 593 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 594 | tmp = exynos4x12_get_intspec(oppi->rate); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 595 | if (tmp < 0) { |
| 596 | err = tmp; |
| 597 | regulator_set_voltage(data->vdd_mif, |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 598 | oldoppi->volt, |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 599 | MAX_SAFEVOLT); |
| 600 | break; |
| 601 | } |
| 602 | err = regulator_set_voltage(data->vdd_int, |
| 603 | exynos4x12_intclk_table[tmp].volt, |
| 604 | MAX_SAFEVOLT); |
| 605 | /* Try to recover */ |
| 606 | if (err) |
| 607 | regulator_set_voltage(data->vdd_mif, |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 608 | oldoppi->volt, |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 609 | MAX_SAFEVOLT); |
| 610 | break; |
| 611 | default: |
| 612 | err = -EINVAL; |
| 613 | } |
| 614 | |
| 615 | return err; |
| 616 | } |
| 617 | |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 618 | static int exynos4_bus_target(struct device *dev, unsigned long *_freq, |
| 619 | u32 flags) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 620 | { |
| 621 | int err = 0; |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 622 | struct platform_device *pdev = container_of(dev, struct platform_device, |
| 623 | dev); |
| 624 | struct busfreq_data *data = platform_get_drvdata(pdev); |
Nishanth Menon | 47d43ba | 2013-09-19 16:03:51 -0500 | [diff] [blame] | 625 | struct dev_pm_opp *opp; |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 626 | unsigned long freq; |
| 627 | unsigned long old_freq = data->curr_oppinfo.rate; |
| 628 | struct busfreq_opp_info new_oppinfo; |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 629 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 630 | rcu_read_lock(); |
| 631 | opp = devfreq_recommended_opp(dev, _freq, flags); |
| 632 | if (IS_ERR(opp)) { |
| 633 | rcu_read_unlock(); |
MyungJoo Ham | ab5f299 | 2012-03-16 21:54:53 +0100 | [diff] [blame] | 634 | return PTR_ERR(opp); |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 635 | } |
Nishanth Menon | 5d4879c | 2013-09-19 16:03:50 -0500 | [diff] [blame] | 636 | new_oppinfo.rate = dev_pm_opp_get_freq(opp); |
| 637 | new_oppinfo.volt = dev_pm_opp_get_voltage(opp); |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 638 | rcu_read_unlock(); |
| 639 | freq = new_oppinfo.rate; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 640 | |
| 641 | if (old_freq == freq) |
| 642 | return 0; |
| 643 | |
Jiri Kosina | 6176772 | 2013-01-29 10:48:30 +0100 | [diff] [blame] | 644 | dev_dbg(dev, "targeting %lukHz %luuV\n", freq, new_oppinfo.volt); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 645 | |
| 646 | mutex_lock(&data->lock); |
| 647 | |
| 648 | if (data->disabled) |
| 649 | goto out; |
| 650 | |
| 651 | if (old_freq < freq) |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 652 | err = exynos4_bus_setvolt(data, &new_oppinfo, |
| 653 | &data->curr_oppinfo); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 654 | if (err) |
| 655 | goto out; |
| 656 | |
| 657 | if (old_freq != freq) { |
| 658 | switch (data->type) { |
| 659 | case TYPE_BUSF_EXYNOS4210: |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 660 | err = exynos4210_set_busclk(data, &new_oppinfo); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 661 | break; |
| 662 | case TYPE_BUSF_EXYNOS4x12: |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 663 | err = exynos4x12_set_busclk(data, &new_oppinfo); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 664 | break; |
| 665 | default: |
| 666 | err = -EINVAL; |
| 667 | } |
| 668 | } |
| 669 | if (err) |
| 670 | goto out; |
| 671 | |
| 672 | if (old_freq > freq) |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 673 | err = exynos4_bus_setvolt(data, &new_oppinfo, |
| 674 | &data->curr_oppinfo); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 675 | if (err) |
| 676 | goto out; |
| 677 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 678 | data->curr_oppinfo = new_oppinfo; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 679 | out: |
| 680 | mutex_unlock(&data->lock); |
| 681 | return err; |
| 682 | } |
| 683 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 684 | static int exynos4_get_busier_ppmu(struct busfreq_ppmu_data *ppmu_data) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 685 | { |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 686 | int i, j; |
| 687 | int busy = 0; |
| 688 | unsigned int temp = 0; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 689 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 690 | for (i = 0; i < ppmu_data->ppmu_end; i++) { |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 691 | for (j = PPMU_PMNCNT0; j < PPMU_PMNCNT_MAX; j++) { |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 692 | if (ppmu_data->ppmu[i].count[j] > temp) { |
| 693 | temp = ppmu_data->ppmu[i].count[j]; |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 694 | busy = i; |
| 695 | } |
| 696 | } |
| 697 | } |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 698 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 699 | return busy; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | static int exynos4_bus_get_dev_status(struct device *dev, |
| 703 | struct devfreq_dev_status *stat) |
| 704 | { |
Axel Lin | f0c28b0 | 2012-01-14 16:56:43 +0800 | [diff] [blame] | 705 | struct busfreq_data *data = dev_get_drvdata(dev); |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 706 | struct busfreq_ppmu_data *ppmu_data = &data->ppmu_data; |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 707 | int busier; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 708 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 709 | exynos4_read_ppmu(ppmu_data); |
| 710 | busier = exynos4_get_busier_ppmu(ppmu_data); |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 711 | stat->current_frequency = data->curr_oppinfo.rate; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 712 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 713 | /* Number of cycles spent on memory access */ |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 714 | stat->busy_time = ppmu_data->ppmu[busier].count[PPMU_PMNCNT3]; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 715 | stat->busy_time *= 100 / BUS_SATURATION_RATIO; |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 716 | stat->total_time = ppmu_data->ppmu[busier].ccnt; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 717 | |
| 718 | /* If the counters have overflown, retry */ |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 719 | if (ppmu_data->ppmu[busier].ccnt_overflow || |
| 720 | ppmu_data->ppmu[busier].count_overflow[0]) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 721 | return -EAGAIN; |
| 722 | |
| 723 | return 0; |
| 724 | } |
| 725 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 726 | static struct devfreq_dev_profile exynos4_devfreq_profile = { |
| 727 | .initial_freq = 400000, |
| 728 | .polling_ms = 50, |
| 729 | .target = exynos4_bus_target, |
| 730 | .get_dev_status = exynos4_bus_get_dev_status, |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 731 | }; |
| 732 | |
| 733 | static int exynos4210_init_tables(struct busfreq_data *data) |
| 734 | { |
| 735 | u32 tmp; |
| 736 | int mgrp; |
| 737 | int i, err = 0; |
| 738 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 739 | tmp = __raw_readl(EXYNOS4_CLKDIV_DMC0); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 740 | for (i = LV_0; i < EX4210_LV_NUM; i++) { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 741 | tmp &= ~(EXYNOS4_CLKDIV_DMC0_ACP_MASK | |
| 742 | EXYNOS4_CLKDIV_DMC0_ACPPCLK_MASK | |
| 743 | EXYNOS4_CLKDIV_DMC0_DPHY_MASK | |
| 744 | EXYNOS4_CLKDIV_DMC0_DMC_MASK | |
| 745 | EXYNOS4_CLKDIV_DMC0_DMCD_MASK | |
| 746 | EXYNOS4_CLKDIV_DMC0_DMCP_MASK | |
| 747 | EXYNOS4_CLKDIV_DMC0_COPY2_MASK | |
| 748 | EXYNOS4_CLKDIV_DMC0_CORETI_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 749 | |
| 750 | tmp |= ((exynos4210_clkdiv_dmc0[i][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 751 | EXYNOS4_CLKDIV_DMC0_ACP_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 752 | (exynos4210_clkdiv_dmc0[i][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 753 | EXYNOS4_CLKDIV_DMC0_ACPPCLK_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 754 | (exynos4210_clkdiv_dmc0[i][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 755 | EXYNOS4_CLKDIV_DMC0_DPHY_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 756 | (exynos4210_clkdiv_dmc0[i][3] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 757 | EXYNOS4_CLKDIV_DMC0_DMC_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 758 | (exynos4210_clkdiv_dmc0[i][4] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 759 | EXYNOS4_CLKDIV_DMC0_DMCD_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 760 | (exynos4210_clkdiv_dmc0[i][5] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 761 | EXYNOS4_CLKDIV_DMC0_DMCP_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 762 | (exynos4210_clkdiv_dmc0[i][6] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 763 | EXYNOS4_CLKDIV_DMC0_COPY2_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 764 | (exynos4210_clkdiv_dmc0[i][7] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 765 | EXYNOS4_CLKDIV_DMC0_CORETI_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 766 | |
| 767 | data->dmc_divtable[i] = tmp; |
| 768 | } |
| 769 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 770 | tmp = __raw_readl(EXYNOS4_CLKDIV_TOP); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 771 | for (i = LV_0; i < EX4210_LV_NUM; i++) { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 772 | tmp &= ~(EXYNOS4_CLKDIV_TOP_ACLK200_MASK | |
| 773 | EXYNOS4_CLKDIV_TOP_ACLK100_MASK | |
| 774 | EXYNOS4_CLKDIV_TOP_ACLK160_MASK | |
| 775 | EXYNOS4_CLKDIV_TOP_ACLK133_MASK | |
| 776 | EXYNOS4_CLKDIV_TOP_ONENAND_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 777 | |
| 778 | tmp |= ((exynos4210_clkdiv_top[i][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 779 | EXYNOS4_CLKDIV_TOP_ACLK200_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 780 | (exynos4210_clkdiv_top[i][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 781 | EXYNOS4_CLKDIV_TOP_ACLK100_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 782 | (exynos4210_clkdiv_top[i][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 783 | EXYNOS4_CLKDIV_TOP_ACLK160_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 784 | (exynos4210_clkdiv_top[i][3] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 785 | EXYNOS4_CLKDIV_TOP_ACLK133_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 786 | (exynos4210_clkdiv_top[i][4] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 787 | EXYNOS4_CLKDIV_TOP_ONENAND_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 788 | |
| 789 | data->top_divtable[i] = tmp; |
| 790 | } |
| 791 | |
| 792 | #ifdef CONFIG_EXYNOS_ASV |
| 793 | tmp = exynos4_result_of_asv; |
| 794 | #else |
| 795 | tmp = 0; /* Max voltages for the reliability of the unknown */ |
| 796 | #endif |
| 797 | |
| 798 | pr_debug("ASV Group of Exynos4 is %d\n", tmp); |
| 799 | /* Use merged grouping for voltage */ |
| 800 | switch (tmp) { |
| 801 | case 0: |
| 802 | mgrp = 0; |
| 803 | break; |
| 804 | case 1: |
| 805 | case 2: |
| 806 | mgrp = 1; |
| 807 | break; |
| 808 | case 3: |
| 809 | case 4: |
| 810 | mgrp = 2; |
| 811 | break; |
| 812 | case 5: |
| 813 | case 6: |
| 814 | mgrp = 3; |
| 815 | break; |
| 816 | case 7: |
| 817 | mgrp = 4; |
| 818 | break; |
| 819 | default: |
| 820 | pr_warn("Unknown ASV Group. Use max voltage.\n"); |
| 821 | mgrp = 0; |
| 822 | } |
| 823 | |
| 824 | for (i = LV_0; i < EX4210_LV_NUM; i++) |
| 825 | exynos4210_busclk_table[i].volt = exynos4210_asv_volt[mgrp][i]; |
| 826 | |
| 827 | for (i = LV_0; i < EX4210_LV_NUM; i++) { |
Nishanth Menon | 5d4879c | 2013-09-19 16:03:50 -0500 | [diff] [blame] | 828 | err = dev_pm_opp_add(data->dev, exynos4210_busclk_table[i].clk, |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 829 | exynos4210_busclk_table[i].volt); |
| 830 | if (err) { |
| 831 | dev_err(data->dev, "Cannot add opp entries.\n"); |
| 832 | return err; |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | |
| 837 | return 0; |
| 838 | } |
| 839 | |
| 840 | static int exynos4x12_init_tables(struct busfreq_data *data) |
| 841 | { |
| 842 | unsigned int i; |
| 843 | unsigned int tmp; |
| 844 | int ret; |
| 845 | |
| 846 | /* Enable pause function for DREX2 DVFS */ |
MyungJoo Ham | a2b9676 | 2012-03-09 15:53:00 +0900 | [diff] [blame] | 847 | tmp = __raw_readl(EXYNOS4_DMC_PAUSE_CTRL); |
| 848 | tmp |= EXYNOS4_DMC_PAUSE_ENABLE; |
| 849 | __raw_writel(tmp, EXYNOS4_DMC_PAUSE_CTRL); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 850 | |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 851 | tmp = __raw_readl(EXYNOS4_CLKDIV_DMC0); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 852 | |
| 853 | for (i = 0; i < EX4x12_LV_NUM; i++) { |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 854 | tmp &= ~(EXYNOS4_CLKDIV_DMC0_ACP_MASK | |
| 855 | EXYNOS4_CLKDIV_DMC0_ACPPCLK_MASK | |
| 856 | EXYNOS4_CLKDIV_DMC0_DPHY_MASK | |
| 857 | EXYNOS4_CLKDIV_DMC0_DMC_MASK | |
| 858 | EXYNOS4_CLKDIV_DMC0_DMCD_MASK | |
| 859 | EXYNOS4_CLKDIV_DMC0_DMCP_MASK); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 860 | |
| 861 | tmp |= ((exynos4x12_clkdiv_dmc0[i][0] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 862 | EXYNOS4_CLKDIV_DMC0_ACP_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 863 | (exynos4x12_clkdiv_dmc0[i][1] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 864 | EXYNOS4_CLKDIV_DMC0_ACPPCLK_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 865 | (exynos4x12_clkdiv_dmc0[i][2] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 866 | EXYNOS4_CLKDIV_DMC0_DPHY_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 867 | (exynos4x12_clkdiv_dmc0[i][3] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 868 | EXYNOS4_CLKDIV_DMC0_DMC_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 869 | (exynos4x12_clkdiv_dmc0[i][4] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 870 | EXYNOS4_CLKDIV_DMC0_DMCD_SHIFT) | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 871 | (exynos4x12_clkdiv_dmc0[i][5] << |
Kukjin Kim | 5fcc929 | 2012-01-22 20:46:49 +0900 | [diff] [blame] | 872 | EXYNOS4_CLKDIV_DMC0_DMCP_SHIFT)); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 873 | |
| 874 | data->dmc_divtable[i] = tmp; |
| 875 | } |
| 876 | |
| 877 | #ifdef CONFIG_EXYNOS_ASV |
| 878 | tmp = exynos4_result_of_asv; |
| 879 | #else |
| 880 | tmp = 0; /* Max voltages for the reliability of the unknown */ |
| 881 | #endif |
| 882 | |
| 883 | if (tmp > 8) |
| 884 | tmp = 0; |
| 885 | pr_debug("ASV Group of Exynos4x12 is %d\n", tmp); |
| 886 | |
| 887 | for (i = 0; i < EX4x12_LV_NUM; i++) { |
| 888 | exynos4x12_mifclk_table[i].volt = |
| 889 | exynos4x12_mif_step_50[tmp][i]; |
| 890 | exynos4x12_intclk_table[i].volt = |
| 891 | exynos4x12_int_volt[tmp][i]; |
| 892 | } |
| 893 | |
| 894 | for (i = 0; i < EX4x12_LV_NUM; i++) { |
Nishanth Menon | 5d4879c | 2013-09-19 16:03:50 -0500 | [diff] [blame] | 895 | ret = dev_pm_opp_add(data->dev, exynos4x12_mifclk_table[i].clk, |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 896 | exynos4x12_mifclk_table[i].volt); |
| 897 | if (ret) { |
| 898 | dev_err(data->dev, "Fail to add opp entries.\n"); |
| 899 | return ret; |
| 900 | } |
| 901 | } |
| 902 | |
| 903 | return 0; |
| 904 | } |
| 905 | |
| 906 | static int exynos4_busfreq_pm_notifier_event(struct notifier_block *this, |
| 907 | unsigned long event, void *ptr) |
| 908 | { |
| 909 | struct busfreq_data *data = container_of(this, struct busfreq_data, |
| 910 | pm_notifier); |
Nishanth Menon | 47d43ba | 2013-09-19 16:03:51 -0500 | [diff] [blame] | 911 | struct dev_pm_opp *opp; |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 912 | struct busfreq_opp_info new_oppinfo; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 913 | unsigned long maxfreq = ULONG_MAX; |
| 914 | int err = 0; |
| 915 | |
| 916 | switch (event) { |
| 917 | case PM_SUSPEND_PREPARE: |
| 918 | /* Set Fastest and Deactivate DVFS */ |
| 919 | mutex_lock(&data->lock); |
| 920 | |
| 921 | data->disabled = true; |
| 922 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 923 | rcu_read_lock(); |
Nishanth Menon | 5d4879c | 2013-09-19 16:03:50 -0500 | [diff] [blame] | 924 | opp = dev_pm_opp_find_freq_floor(data->dev, &maxfreq); |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 925 | if (IS_ERR(opp)) { |
| 926 | rcu_read_unlock(); |
| 927 | dev_err(data->dev, "%s: unable to find a min freq\n", |
| 928 | __func__); |
Wei Yongjun | 5751cdc | 2013-02-22 12:33:50 +0800 | [diff] [blame] | 929 | mutex_unlock(&data->lock); |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 930 | return PTR_ERR(opp); |
| 931 | } |
Nishanth Menon | 5d4879c | 2013-09-19 16:03:50 -0500 | [diff] [blame] | 932 | new_oppinfo.rate = dev_pm_opp_get_freq(opp); |
| 933 | new_oppinfo.volt = dev_pm_opp_get_voltage(opp); |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 934 | rcu_read_unlock(); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 935 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 936 | err = exynos4_bus_setvolt(data, &new_oppinfo, |
| 937 | &data->curr_oppinfo); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 938 | if (err) |
| 939 | goto unlock; |
| 940 | |
| 941 | switch (data->type) { |
| 942 | case TYPE_BUSF_EXYNOS4210: |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 943 | err = exynos4210_set_busclk(data, &new_oppinfo); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 944 | break; |
| 945 | case TYPE_BUSF_EXYNOS4x12: |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 946 | err = exynos4x12_set_busclk(data, &new_oppinfo); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 947 | break; |
| 948 | default: |
| 949 | err = -EINVAL; |
| 950 | } |
| 951 | if (err) |
| 952 | goto unlock; |
| 953 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 954 | data->curr_oppinfo = new_oppinfo; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 955 | unlock: |
| 956 | mutex_unlock(&data->lock); |
| 957 | if (err) |
| 958 | return err; |
| 959 | return NOTIFY_OK; |
| 960 | case PM_POST_RESTORE: |
| 961 | case PM_POST_SUSPEND: |
| 962 | /* Reactivate */ |
| 963 | mutex_lock(&data->lock); |
| 964 | data->disabled = false; |
| 965 | mutex_unlock(&data->lock); |
| 966 | return NOTIFY_OK; |
| 967 | } |
| 968 | |
| 969 | return NOTIFY_DONE; |
| 970 | } |
| 971 | |
Greg Kroah-Hartman | 0fe763c | 2012-12-21 15:14:44 -0800 | [diff] [blame] | 972 | static int exynos4_busfreq_probe(struct platform_device *pdev) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 973 | { |
| 974 | struct busfreq_data *data; |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 975 | struct busfreq_ppmu_data *ppmu_data; |
Nishanth Menon | 47d43ba | 2013-09-19 16:03:51 -0500 | [diff] [blame] | 976 | struct dev_pm_opp *opp; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 977 | struct device *dev = &pdev->dev; |
| 978 | int err = 0; |
| 979 | |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 980 | data = devm_kzalloc(&pdev->dev, sizeof(struct busfreq_data), GFP_KERNEL); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 981 | if (data == NULL) { |
| 982 | dev_err(dev, "Cannot allocate memory.\n"); |
| 983 | return -ENOMEM; |
| 984 | } |
| 985 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 986 | ppmu_data = &data->ppmu_data; |
| 987 | ppmu_data->ppmu_end = PPMU_END; |
| 988 | ppmu_data->ppmu = devm_kzalloc(dev, |
| 989 | sizeof(struct exynos_ppmu) * PPMU_END, |
| 990 | GFP_KERNEL); |
| 991 | if (!ppmu_data->ppmu) { |
| 992 | dev_err(dev, "Failed to allocate memory for exynos_ppmu\n"); |
| 993 | return -ENOMEM; |
| 994 | } |
| 995 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 996 | data->type = pdev->id_entry->driver_data; |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 997 | ppmu_data->ppmu[PPMU_DMC0].hw_base = S5P_VA_DMC0; |
| 998 | ppmu_data->ppmu[PPMU_DMC1].hw_base = S5P_VA_DMC1; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 999 | data->pm_notifier.notifier_call = exynos4_busfreq_pm_notifier_event; |
| 1000 | data->dev = dev; |
| 1001 | mutex_init(&data->lock); |
| 1002 | |
| 1003 | switch (data->type) { |
| 1004 | case TYPE_BUSF_EXYNOS4210: |
| 1005 | err = exynos4210_init_tables(data); |
| 1006 | break; |
| 1007 | case TYPE_BUSF_EXYNOS4x12: |
| 1008 | err = exynos4x12_init_tables(data); |
| 1009 | break; |
| 1010 | default: |
| 1011 | dev_err(dev, "Cannot determine the device id %d\n", data->type); |
| 1012 | err = -EINVAL; |
| 1013 | } |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1014 | if (err) { |
| 1015 | dev_err(dev, "Cannot initialize busfreq table %d\n", |
| 1016 | data->type); |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 1017 | return err; |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1018 | } |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1019 | |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 1020 | data->vdd_int = devm_regulator_get(dev, "vdd_int"); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1021 | if (IS_ERR(data->vdd_int)) { |
| 1022 | dev_err(dev, "Cannot get the regulator \"vdd_int\"\n"); |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 1023 | return PTR_ERR(data->vdd_int); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1024 | } |
| 1025 | if (data->type == TYPE_BUSF_EXYNOS4x12) { |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 1026 | data->vdd_mif = devm_regulator_get(dev, "vdd_mif"); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1027 | if (IS_ERR(data->vdd_mif)) { |
| 1028 | dev_err(dev, "Cannot get the regulator \"vdd_mif\"\n"); |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 1029 | return PTR_ERR(data->vdd_mif); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1030 | } |
| 1031 | } |
| 1032 | |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 1033 | rcu_read_lock(); |
Nishanth Menon | 5d4879c | 2013-09-19 16:03:50 -0500 | [diff] [blame] | 1034 | opp = dev_pm_opp_find_freq_floor(dev, |
| 1035 | &exynos4_devfreq_profile.initial_freq); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1036 | if (IS_ERR(opp)) { |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 1037 | rcu_read_unlock(); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1038 | dev_err(dev, "Invalid initial frequency %lu kHz.\n", |
Sangho Yi | dce9dc3 | 2012-10-20 01:16:34 +0900 | [diff] [blame] | 1039 | exynos4_devfreq_profile.initial_freq); |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 1040 | return PTR_ERR(opp); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1041 | } |
Nishanth Menon | 5d4879c | 2013-09-19 16:03:50 -0500 | [diff] [blame] | 1042 | data->curr_oppinfo.rate = dev_pm_opp_get_freq(opp); |
| 1043 | data->curr_oppinfo.volt = dev_pm_opp_get_voltage(opp); |
Nishanth Menon | 8fa938a | 2013-01-18 19:52:35 +0000 | [diff] [blame] | 1044 | rcu_read_unlock(); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1045 | |
| 1046 | platform_set_drvdata(pdev, data); |
| 1047 | |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1048 | data->devfreq = devfreq_add_device(dev, &exynos4_devfreq_profile, |
Nishanth Menon | 1b5c1be | 2012-10-29 15:01:45 -0500 | [diff] [blame] | 1049 | "simple_ondemand", NULL); |
Sachin Kamat | d789505 | 2012-08-21 15:35:32 +0530 | [diff] [blame] | 1050 | if (IS_ERR(data->devfreq)) |
| 1051 | return PTR_ERR(data->devfreq); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1052 | |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 1053 | /* |
| 1054 | * Start PPMU (Performance Profiling Monitoring Unit) to check |
| 1055 | * utilization of each IP in the Exynos4 SoC. |
| 1056 | */ |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 1057 | busfreq_mon_reset(ppmu_data); |
Chanwoo Choi | ba778b3 | 2014-03-21 18:31:43 +0100 | [diff] [blame] | 1058 | |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1059 | /* Register opp_notifier for Exynos4 busfreq */ |
| 1060 | err = devfreq_register_opp_notifier(dev, data->devfreq); |
| 1061 | if (err < 0) { |
| 1062 | dev_err(dev, "Failed to register opp notifier\n"); |
| 1063 | goto err_notifier_opp; |
| 1064 | } |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1065 | |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1066 | /* Register pm_notifier for Exynos4 busfreq */ |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1067 | err = register_pm_notifier(&data->pm_notifier); |
| 1068 | if (err) { |
| 1069 | dev_err(dev, "Failed to setup pm notifier\n"); |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1070 | goto err_notifier_pm; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | return 0; |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1074 | |
| 1075 | err_notifier_pm: |
| 1076 | devfreq_unregister_opp_notifier(dev, data->devfreq); |
| 1077 | err_notifier_opp: |
| 1078 | devfreq_remove_device(data->devfreq); |
| 1079 | |
| 1080 | return err; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1081 | } |
| 1082 | |
Greg Kroah-Hartman | 0fe763c | 2012-12-21 15:14:44 -0800 | [diff] [blame] | 1083 | static int exynos4_busfreq_remove(struct platform_device *pdev) |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1084 | { |
| 1085 | struct busfreq_data *data = platform_get_drvdata(pdev); |
| 1086 | |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1087 | /* Unregister all of notifier chain */ |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1088 | unregister_pm_notifier(&data->pm_notifier); |
Chanwoo Choi | 45c58e9 | 2014-03-20 11:59:09 +0900 | [diff] [blame] | 1089 | devfreq_unregister_opp_notifier(data->dev, data->devfreq); |
| 1090 | |
| 1091 | /* Remove devfreq instance */ |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1092 | devfreq_remove_device(data->devfreq); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1093 | |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
Chanwoo Choi | 60d6977 | 2014-03-20 11:59:10 +0900 | [diff] [blame] | 1097 | #ifdef CONFIG_PM_SLEEP |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1098 | static int exynos4_busfreq_resume(struct device *dev) |
| 1099 | { |
Axel Lin | f0c28b0 | 2012-01-14 16:56:43 +0800 | [diff] [blame] | 1100 | struct busfreq_data *data = dev_get_drvdata(dev); |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 1101 | struct busfreq_ppmu_data *ppmu_data = &data->ppmu_data; |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1102 | |
Bartlomiej Zolnierkiewicz | f414527 | 2014-03-21 18:31:44 +0100 | [diff] [blame^] | 1103 | busfreq_mon_reset(ppmu_data); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1104 | return 0; |
| 1105 | } |
Chanwoo Choi | 60d6977 | 2014-03-20 11:59:10 +0900 | [diff] [blame] | 1106 | #endif |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1107 | |
Chanwoo Choi | 60d6977 | 2014-03-20 11:59:10 +0900 | [diff] [blame] | 1108 | static SIMPLE_DEV_PM_OPS(exynos4_busfreq_pm_ops, NULL, exynos4_busfreq_resume); |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1109 | |
| 1110 | static const struct platform_device_id exynos4_busfreq_id[] = { |
| 1111 | { "exynos4210-busfreq", TYPE_BUSF_EXYNOS4210 }, |
| 1112 | { "exynos4412-busfreq", TYPE_BUSF_EXYNOS4x12 }, |
| 1113 | { "exynos4212-busfreq", TYPE_BUSF_EXYNOS4x12 }, |
| 1114 | { }, |
| 1115 | }; |
| 1116 | |
| 1117 | static struct platform_driver exynos4_busfreq_driver = { |
| 1118 | .probe = exynos4_busfreq_probe, |
Greg Kroah-Hartman | 0fe763c | 2012-12-21 15:14:44 -0800 | [diff] [blame] | 1119 | .remove = exynos4_busfreq_remove, |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1120 | .id_table = exynos4_busfreq_id, |
| 1121 | .driver = { |
| 1122 | .name = "exynos4-busfreq", |
| 1123 | .owner = THIS_MODULE, |
Chanwoo Choi | 60d6977 | 2014-03-20 11:59:10 +0900 | [diff] [blame] | 1124 | .pm = &exynos4_busfreq_pm_ops, |
MyungJoo Ham | 7b40503 | 2011-07-14 10:33:55 +0900 | [diff] [blame] | 1125 | }, |
| 1126 | }; |
| 1127 | |
| 1128 | static int __init exynos4_busfreq_init(void) |
| 1129 | { |
| 1130 | return platform_driver_register(&exynos4_busfreq_driver); |
| 1131 | } |
| 1132 | late_initcall(exynos4_busfreq_init); |
| 1133 | |
| 1134 | static void __exit exynos4_busfreq_exit(void) |
| 1135 | { |
| 1136 | platform_driver_unregister(&exynos4_busfreq_driver); |
| 1137 | } |
| 1138 | module_exit(exynos4_busfreq_exit); |
| 1139 | |
| 1140 | MODULE_LICENSE("GPL"); |
| 1141 | MODULE_DESCRIPTION("EXYNOS4 busfreq driver with devfreq framework"); |
| 1142 | MODULE_AUTHOR("MyungJoo Ham <myungjoo.ham@samsung.com>"); |