]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - arch/arm/mach-imx/busfreq-imx6.c
5f7649bc5a1a31d19348922579ca6e9545c98474
[karo-tx-linux.git] / arch / arm / mach-imx / busfreq-imx6.c
1 /*
2  * Copyright (C) 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 /*!
20  * @file busfreq-imx6.c
21  *
22  * @brief A common API for the Freescale Semiconductor iMX6 Busfreq API
23  *
24  * The APIs are for setting bus frequency to different values based on the
25  * highest freqeuncy requested.
26  *
27  * @ingroup PM
28  */
29
30 #include <asm/cacheflush.h>
31 #include <asm/fncpy.h>
32 #include <asm/io.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach-types.h>
35 #include <asm/tlb.h>
36 #include <linux/busfreq-imx6.h>
37 #include <linux/clk.h>
38 #include <linux/clk-provider.h>
39 #include <linux/delay.h>
40 #include <linux/module.h>
41 #include <linux/mutex.h>
42 #include <linux/of.h>
43 #include <linux/of_fdt.h>
44 #include <linux/platform_device.h>
45 #include <linux/proc_fs.h>
46 #include <linux/reboot.h>
47 #include <linux/regulator/consumer.h>
48 #include <linux/sched.h>
49 #include <linux/suspend.h>
50 #include "clk.h"
51 #include "hardware.h"
52 #include "common.h"
53
54 #define LPAPM_CLK               24000000
55 #define DDR3_AUDIO_CLK          50000000
56 #define LPDDR2_AUDIO_CLK        100000000
57
58 #define MMDC_MDMISC_DDR_TYPE_DDR3       0
59 #define MMDC_MDMISC_DDR_TYPE_LPDDR2     1
60
61 static int ddr_type;
62 int high_bus_freq_mode;
63 int med_bus_freq_mode;
64 int audio_bus_freq_mode;
65 int low_bus_freq_mode;
66 int ultra_low_bus_freq_mode;
67 unsigned int ddr_med_rate;
68 unsigned int ddr_normal_rate;
69 unsigned long ddr_freq_change_total_size;
70 unsigned long ddr_freq_change_iram_base;
71 unsigned long ddr_freq_change_iram_phys;
72
73 static int bus_freq_scaling_initialized;
74 static struct device *busfreq_dev;
75 static int busfreq_suspended;
76 static u32 org_arm_rate;
77 static int bus_freq_scaling_is_active;
78 static int high_bus_count, med_bus_count, audio_bus_count, low_bus_count;
79 static unsigned int ddr_low_rate;
80
81 extern unsigned long iram_tlb_phys_addr;
82 extern int unsigned long iram_tlb_base_addr;
83
84 extern int init_mmdc_lpddr2_settings(struct platform_device *dev);
85 extern int init_mmdc_ddr3_settings_imx6q(struct platform_device *dev);
86 extern int init_mmdc_ddr3_settings_imx6sx(struct platform_device *dev);
87 extern int update_ddr_freq_imx6q(int ddr_rate);
88 extern int update_ddr_freq_imx6sx(int ddr_rate);
89 extern int update_lpddr2_freq(int ddr_rate);
90
91 DEFINE_MUTEX(bus_freq_mutex);
92
93 static struct clk *mmdc_clk;
94 static struct clk *pll2_400;
95 static struct clk *periph_clk;
96 static struct clk *periph_pre_clk;
97 static struct clk *periph_clk2_sel;
98 static struct clk *periph_clk2;
99 static struct clk *osc_clk;
100 static struct clk *cpu_clk;
101 static struct clk *pll3;
102 static struct clk *pll2;
103 static struct clk *pll2_bus;
104 static struct clk *pll2_bypass_src;
105 static struct clk *pll2_bypass;
106 static struct clk *pll2_200;
107 static struct clk *pll1_sys;
108 static struct clk *periph2_clk;
109 static struct clk *ocram_clk;
110 static struct clk *ahb_clk;
111 static struct clk *pll1_sw_clk;
112 static struct clk *periph2_pre_clk;
113 static struct clk *periph2_clk2_sel;
114 static struct clk *periph2_clk2;
115 static struct clk *step_clk;
116 static struct clk *axi_alt_sel_clk;
117 static struct clk *axi_sel_clk;
118 static struct clk *pll3_pfd1_540m;
119 static struct clk *m4_clk;
120
121 static u32 pll2_org_rate;
122 static struct delayed_work low_bus_freq_handler;
123 static struct delayed_work bus_freq_daemon;
124
125 static RAW_NOTIFIER_HEAD(busfreq_notifier_chain);
126
127 static int busfreq_notify(enum busfreq_event event)
128 {
129         int ret;
130
131         ret = raw_notifier_call_chain(&busfreq_notifier_chain, event, NULL);
132
133         return notifier_to_errno(ret);
134 }
135
136 int register_busfreq_notifier(struct notifier_block *nb)
137 {
138         return raw_notifier_chain_register(&busfreq_notifier_chain, nb);
139 }
140 EXPORT_SYMBOL(register_busfreq_notifier);
141
142 int unregister_busfreq_notifier(struct notifier_block *nb)
143 {
144         return raw_notifier_chain_unregister(&busfreq_notifier_chain, nb);
145 }
146 EXPORT_SYMBOL(unregister_busfreq_notifier);
147
148 static bool check_m4_sleep(void)
149 {
150         unsigned long timeout = jiffies + msecs_to_jiffies(500);
151
152         while (imx_gpc_is_m4_sleeping() == 0)
153                 if (time_after(jiffies, timeout))
154                         return false;
155         return  true;
156 }
157
158 static void enter_lpm_imx6sx(void)
159 {
160         if (imx_src_is_m4_enabled())
161                 if (!check_m4_sleep())
162                         pr_err("M4 is NOT in sleep!!!\n");
163
164         /* set periph_clk2 to source from OSC for periph */
165         imx_clk_set_parent(periph_clk2_sel, osc_clk);
166         imx_clk_set_parent(periph_clk, periph_clk2);
167         /* set ahb/ocram to 24MHz */
168         imx_clk_set_rate(ahb_clk, LPAPM_CLK);
169         imx_clk_set_rate(ocram_clk, LPAPM_CLK);
170
171         if (audio_bus_count) {
172                 /* Need to ensure that PLL2_PFD_400M is kept ON. */
173                 clk_prepare_enable(pll2_400);
174                 if (ddr_type == MMDC_MDMISC_DDR_TYPE_DDR3)
175                         update_ddr_freq_imx6sx(DDR3_AUDIO_CLK);
176                 else if (ddr_type == MMDC_MDMISC_DDR_TYPE_LPDDR2)
177                         update_lpddr2_freq(LPDDR2_AUDIO_CLK);
178                 imx_clk_set_parent(periph2_clk2_sel, pll3);
179                 imx_clk_set_parent(periph2_pre_clk, pll2_400);
180                 imx_clk_set_parent(periph2_clk, periph2_pre_clk);
181                 /*
182                  * As periph2_clk's parent is not changed from
183                  * high mode to audio mode, so clk framework
184                  * will not update its children's freq, but we
185                  * change the mmdc's podf in asm code, so here
186                  * need to update mmdc rate to make sure clk
187                  * tree is right, although it will not do any
188                  * change to hardware.
189                  */
190                 if (high_bus_freq_mode) {
191                         if (ddr_type == MMDC_MDMISC_DDR_TYPE_DDR3)
192                                 imx_clk_set_rate(mmdc_clk, DDR3_AUDIO_CLK);
193                         else if (ddr_type == MMDC_MDMISC_DDR_TYPE_LPDDR2)
194                                 imx_clk_set_rate(mmdc_clk, LPDDR2_AUDIO_CLK);
195                 }
196                 audio_bus_freq_mode = 1;
197                 low_bus_freq_mode = 0;
198         } else {
199                 if (ddr_type == MMDC_MDMISC_DDR_TYPE_DDR3)
200                         update_ddr_freq_imx6sx(LPAPM_CLK);
201                 else if (ddr_type == MMDC_MDMISC_DDR_TYPE_LPDDR2)
202                         update_lpddr2_freq(LPAPM_CLK);
203                 imx_clk_set_parent(periph2_clk2_sel, osc_clk);
204                 imx_clk_set_parent(periph2_clk, periph2_clk2);
205
206                 if (audio_bus_freq_mode)
207                         clk_disable_unprepare(pll2_400);
208                 low_bus_freq_mode = 1;
209                 audio_bus_freq_mode = 0;
210         }
211 }
212
213 static void exit_lpm_imx6sx(void)
214 {
215         clk_prepare_enable(pll2_400);
216
217         /*
218          * lower ahb/ocram's freq first to avoid too high
219          * freq during parent switch from OSC to pll3.
220          */
221         imx_clk_set_rate(ahb_clk, LPAPM_CLK / 3);
222         imx_clk_set_rate(ocram_clk, LPAPM_CLK / 2);
223         /* set periph_clk2 to pll3 */
224         imx_clk_set_parent(periph_clk2_sel, pll3);
225         /* set periph clk to from pll2_400 */
226         imx_clk_set_parent(periph_pre_clk, pll2_400);
227         imx_clk_set_parent(periph_clk, periph_pre_clk);
228
229         if (ddr_type == MMDC_MDMISC_DDR_TYPE_DDR3)
230                 update_ddr_freq_imx6sx(ddr_normal_rate);
231         else if (ddr_type == MMDC_MDMISC_DDR_TYPE_LPDDR2)
232                 update_lpddr2_freq(ddr_normal_rate);
233         /* correct parent info after ddr freq change in asm code */
234         imx_clk_set_parent(periph2_clk2_sel, pll3);
235         imx_clk_set_parent(periph2_pre_clk, pll2_400);
236         imx_clk_set_parent(periph2_clk, periph2_pre_clk);
237         /*
238          * As periph2_clk's parent is not changed from
239          * audio mode to high mode, so clk framework
240          * will not update its children's freq, but we
241          * change the mmdc's podf in asm code, so here
242          * need to update mmdc rate to make sure clk
243          * tree is right, although it will not do any
244          * change to hardware.
245          */
246         if (audio_bus_freq_mode)
247                 imx_clk_set_rate(mmdc_clk, ddr_normal_rate);
248
249         clk_disable_unprepare(pll2_400);
250         if (audio_bus_freq_mode)
251                 clk_disable_unprepare(pll2_400);
252 }
253
254 static void enter_lpm_imx6sl(void)
255 {
256         if (high_bus_freq_mode) {
257                 pll2_org_rate = clk_get_rate(pll2_bus);
258                 /* Set periph_clk to be sourced from OSC_CLK */
259                 imx_clk_set_parent(periph_clk2_sel, osc_clk);
260                 imx_clk_set_parent(periph_clk, periph_clk2);
261                 /* Ensure AHB/AXI clks are at 24MHz. */
262                 imx_clk_set_rate(ahb_clk, LPAPM_CLK);
263                 imx_clk_set_rate(ocram_clk, LPAPM_CLK);
264         }
265         if (audio_bus_count) {
266                 /* Set AHB to 8MHz to lower pwer.*/
267                 imx_clk_set_rate(ahb_clk, LPAPM_CLK / 3);
268
269                 /* Set up DDR to 100MHz. */
270                 update_lpddr2_freq(LPDDR2_AUDIO_CLK);
271
272                 /* Fix the clock tree in kernel */
273                 imx_clk_set_parent(periph2_pre_clk, pll2_200);
274                 imx_clk_set_parent(periph2_clk, periph2_pre_clk);
275
276                 if (low_bus_freq_mode || ultra_low_bus_freq_mode) {
277                         /*
278                          * Fix the clock tree in kernel, make sure
279                          * pll2_bypass is updated as it is
280                          * sourced from PLL2.
281                          */
282                         imx_clk_set_parent(pll2_bypass, pll2);
283                         /*
284                          * Swtich ARM to run off PLL2_PFD2_400MHz
285                          * since DDR is anyway at 100MHz.
286                          */
287                         imx_clk_set_parent(step_clk, pll2_400);
288                         imx_clk_set_parent(pll1_sw_clk, step_clk);
289                         /*
290                          * Ensure that the clock will be
291                          * at original speed.
292                          */
293                         imx_clk_set_rate(cpu_clk, org_arm_rate);
294                 }
295                 low_bus_freq_mode = 0;
296                 ultra_low_bus_freq_mode = 0;
297                 audio_bus_freq_mode = 1;
298         } else {
299                 u32 arm_div, pll1_rate;
300                 org_arm_rate = clk_get_rate(cpu_clk);
301                 if (low_bus_freq_mode && low_bus_count == 0) {
302                         /*
303                          * We are already in DDR @ 24MHz state, but
304                          * no one but ARM needs the DDR. In this case,
305                          * we can lower the DDR freq to 1MHz when ARM
306                          * enters WFI in this state. Keep track of this state.
307                          */
308                         ultra_low_bus_freq_mode = 1;
309                         low_bus_freq_mode = 0;
310                         audio_bus_freq_mode = 0;
311                 } else {
312                         if (!ultra_low_bus_freq_mode && !low_bus_freq_mode) {
313                                 /*
314                                  * Anyway, make sure the AHB is running at 24MHz
315                                  * in low_bus_freq_mode.
316                                  */
317                                 if (audio_bus_freq_mode)
318                                         imx_clk_set_rate(ahb_clk, LPAPM_CLK);
319                                 /*
320                                  * Set DDR to 24MHz.
321                                  * Since we are going to bypass PLL2,
322                                  * we need to move ARM clk off PLL2_PFD2
323                                  * to PLL1. Make sure the PLL1 is running
324                                  * at the lowest possible freq.
325                                  * To work well with CPUFREQ we want to ensure that
326                                  * the CPU freq does not change, so attempt to
327                                  * get a freq as close to 396MHz as possible.
328                                  */
329                                 imx_clk_set_rate(pll1_sys,
330                                         clk_round_rate(pll1_sys, (org_arm_rate * 2)));
331                                 pll1_rate = clk_get_rate(pll1_sys);
332                                 arm_div = pll1_rate / org_arm_rate;
333                                 if (pll1_rate / arm_div > org_arm_rate)
334                                         arm_div++;
335                                 /*
336                                  * Ensure ARM CLK is lower before
337                                  * changing the parent.
338                                  */
339                                 imx_clk_set_rate(cpu_clk, org_arm_rate / arm_div);
340                                 /* Now set the ARM clk parent to PLL1_SYS. */
341                                 imx_clk_set_parent(pll1_sw_clk, pll1_sys);
342
343                                 /*
344                                  * Set STEP_CLK back to OSC to save power and
345                                  * also to maintain the parent.The WFI iram code
346                                  * will switch step_clk to osc, but the clock API
347                                  * is not aware of the change and when a new request
348                                  * to change the step_clk parent to pll2_pfd2_400M
349                                  * is requested sometime later, the change is ignored.
350                                  */
351                                 imx_clk_set_parent(step_clk, osc_clk);
352                                 /* Now set DDR to 24MHz. */
353                                 update_lpddr2_freq(LPAPM_CLK);
354
355                                 /*
356                                  * Fix the clock tree in kernel.
357                                  * Make sure PLL2 rate is updated as it gets
358                                  * bypassed in the DDR freq change code.
359                                  */
360                                 imx_clk_set_parent(pll2_bypass, pll2_bypass_src);
361                                 imx_clk_set_parent(periph2_clk2_sel, pll2_bus);
362                                 imx_clk_set_parent(periph2_clk, periph2_clk2);
363
364                         }
365                         if (low_bus_count == 0) {
366                                 ultra_low_bus_freq_mode = 1;
367                                 low_bus_freq_mode = 0;
368                         } else {
369                                 ultra_low_bus_freq_mode = 0;
370                                 low_bus_freq_mode = 1;
371                         }
372                         audio_bus_freq_mode = 0;
373                 }
374         }
375 }
376
377 static void exit_lpm_imx6sl(void)
378 {
379         /* Change DDR freq in IRAM. */
380         update_lpddr2_freq(ddr_normal_rate);
381
382         /*
383          * Fix the clock tree in kernel.
384          * Make sure PLL2 rate is updated as it gets
385          * un-bypassed in the DDR freq change code.
386          */
387         imx_clk_set_parent(pll2_bypass, pll2);
388         imx_clk_set_parent(periph2_pre_clk, pll2_400);
389         imx_clk_set_parent(periph2_clk, periph2_pre_clk);
390
391         /* Ensure that periph_clk is sourced from PLL2_400. */
392         imx_clk_set_parent(periph_pre_clk, pll2_400);
393         /*
394          * Before switching the perhiph_clk, ensure that the
395          * AHB/AXI will not be too fast.
396          */
397         imx_clk_set_rate(ahb_clk, LPAPM_CLK / 3);
398         imx_clk_set_rate(ocram_clk, LPAPM_CLK / 2);
399         imx_clk_set_parent(periph_clk, periph_pre_clk);
400
401         if (low_bus_freq_mode || ultra_low_bus_freq_mode) {
402                 /* Move ARM from PLL1_SW_CLK to PLL2_400. */
403                 imx_clk_set_parent(step_clk, pll2_400);
404                 imx_clk_set_parent(pll1_sw_clk, step_clk);
405                 imx_clk_set_rate(cpu_clk, org_arm_rate);
406                 ultra_low_bus_freq_mode = 0;
407         }
408 }
409
410 static void reduce_bus_freq(void)
411 {
412         clk_prepare_enable(pll3);
413         if (audio_bus_count && (low_bus_freq_mode || ultra_low_bus_freq_mode))
414                 busfreq_notify(LOW_BUSFREQ_EXIT);
415         else if (!audio_bus_count)
416                 busfreq_notify(LOW_BUSFREQ_ENTER);
417         if (cpu_is_imx6sl())
418                 enter_lpm_imx6sl();
419         else if (cpu_is_imx6sx())
420                 enter_lpm_imx6sx();
421         else {
422                 if (cpu_is_imx6dl())
423                         /* Set axi to periph_clk */
424                         imx_clk_set_parent(axi_sel_clk, periph_clk);
425
426                 if (audio_bus_count) {
427                         /* Need to ensure that PLL2_PFD_400M is kept ON. */
428                         clk_prepare_enable(pll2_400);
429                         update_ddr_freq_imx6q(DDR3_AUDIO_CLK);
430                         /* Make sure periph clk's parent also got updated */
431                         imx_clk_set_parent(periph_clk2_sel, pll3);
432                         imx_clk_set_parent(periph_pre_clk, pll2_200);
433                         imx_clk_set_parent(periph_clk, periph_pre_clk);
434                         audio_bus_freq_mode = 1;
435                         low_bus_freq_mode = 0;
436                 } else {
437                         update_ddr_freq_imx6q(LPAPM_CLK);
438                         /* Make sure periph clk's parent also got updated */
439                         imx_clk_set_parent(periph_clk2_sel, osc_clk);
440                         /* Set periph_clk parent to OSC via periph_clk2_sel */
441                         imx_clk_set_parent(periph_clk, periph_clk2);
442                         if (audio_bus_freq_mode)
443                                 clk_disable_unprepare(pll2_400);
444                         low_bus_freq_mode = 1;
445                         audio_bus_freq_mode = 0;
446                 }
447         }
448         clk_disable_unprepare(pll3);
449
450         med_bus_freq_mode = 0;
451         high_bus_freq_mode = 0;
452
453         if (audio_bus_freq_mode)
454                 dev_dbg(busfreq_dev, "Bus freq set to audio mode. Count:\
455                         high %d, med %d, audio %d\n",
456                         high_bus_count, med_bus_count, audio_bus_count);
457         if (low_bus_freq_mode)
458                 dev_dbg(busfreq_dev, "Bus freq set to low mode. Count:\
459                         high %d, med %d, audio %d\n",
460                         high_bus_count, med_bus_count, audio_bus_count);
461 }
462
463 static void reduce_bus_freq_handler(struct work_struct *work)
464 {
465         mutex_lock(&bus_freq_mutex);
466
467         reduce_bus_freq();
468
469         mutex_unlock(&bus_freq_mutex);
470 }
471
472 /*
473  * Set the DDR, AHB to 24MHz.
474  * This mode will be activated only when none of the modules that
475  * need a higher DDR or AHB frequency are active.
476  */
477 int set_low_bus_freq(void)
478 {
479         if (busfreq_suspended)
480                 return 0;
481
482         if (!bus_freq_scaling_initialized || !bus_freq_scaling_is_active)
483                 return 0;
484
485         /*
486          * Check to see if we need to got from
487          * low bus freq mode to audio bus freq mode.
488          * If so, the change needs to be done immediately.
489          */
490         if (audio_bus_count && (low_bus_freq_mode || ultra_low_bus_freq_mode))
491                 reduce_bus_freq();
492         else
493                 /*
494                  * Don't lower the frequency immediately. Instead
495                  * scheduled a delayed work and drop the freq if
496                  * the conditions still remain the same.
497                  */
498                 schedule_delayed_work(&low_bus_freq_handler,
499                                         usecs_to_jiffies(3000000));
500         return 0;
501 }
502
503 /*
504  * Set the DDR to either 528MHz or 400MHz for iMX6qd
505  * or 400MHz for iMX6dl.
506  */
507 static int set_high_bus_freq(int high_bus_freq)
508 {
509         struct clk *periph_clk_parent;
510
511         if (bus_freq_scaling_initialized && bus_freq_scaling_is_active)
512                 cancel_delayed_work_sync(&low_bus_freq_handler);
513
514         if (busfreq_suspended)
515                 return 0;
516
517         if (cpu_is_imx6q())
518                 periph_clk_parent = pll2_bus;
519         else
520                 periph_clk_parent = pll2_400;
521
522         if (!bus_freq_scaling_initialized || !bus_freq_scaling_is_active)
523                 return 0;
524
525         if (high_bus_freq_mode)
526                 return 0;
527
528         /* medium bus freq is only supported for MX6DQ */
529         if (med_bus_freq_mode && !high_bus_freq)
530                 return 0;
531
532         if (low_bus_freq_mode || ultra_low_bus_freq_mode)
533                 busfreq_notify(LOW_BUSFREQ_EXIT);
534
535         clk_prepare_enable(pll3);
536         if (cpu_is_imx6sl())
537                 exit_lpm_imx6sl();
538         else if (cpu_is_imx6sx())
539                 exit_lpm_imx6sx();
540         else {
541                 if (high_bus_freq) {
542                         clk_prepare_enable(pll2_400);
543                         update_ddr_freq_imx6q(ddr_normal_rate);
544                         /* Make sure periph clk's parent also got updated */
545                         imx_clk_set_parent(periph_clk2_sel, pll3);
546                         imx_clk_set_parent(periph_pre_clk, periph_clk_parent);
547                         imx_clk_set_parent(periph_clk, periph_pre_clk);
548                         if (cpu_is_imx6dl()) {
549                                 /* Set axi to pll3_pfd1_540m */
550                                 imx_clk_set_parent(axi_alt_sel_clk, pll3_pfd1_540m);
551                                 imx_clk_set_parent(axi_sel_clk, axi_alt_sel_clk);
552                         }
553                         clk_disable_unprepare(pll2_400);
554                 } else {
555                         update_ddr_freq_imx6q(ddr_med_rate);
556                         /* Make sure periph clk's parent also got updated */
557                         imx_clk_set_parent(periph_clk2_sel, pll3);
558                         imx_clk_set_parent(periph_pre_clk, pll2_400);
559                         imx_clk_set_parent(periph_clk, periph_pre_clk);
560                 }
561                 if (audio_bus_freq_mode)
562                         clk_disable_unprepare(pll2_400);
563         }
564
565         high_bus_freq_mode = 1;
566         med_bus_freq_mode = 0;
567         low_bus_freq_mode = 0;
568         audio_bus_freq_mode = 0;
569
570         clk_disable_unprepare(pll3);
571         if (high_bus_freq_mode)
572                 dev_dbg(busfreq_dev, "Bus freq set to high mode. Count:\
573                         high %d, med %d, audio %d\n",
574                         high_bus_count, med_bus_count, audio_bus_count);
575         if (med_bus_freq_mode)
576                 dev_dbg(busfreq_dev, "Bus freq set to med mode. Count:\
577                         high %d, med %d, audio %d\n",
578                         high_bus_count, med_bus_count, audio_bus_count);
579
580         return 0;
581 }
582
583 void request_bus_freq(enum bus_freq_mode mode)
584 {
585         mutex_lock(&bus_freq_mutex);
586
587         if (mode == BUS_FREQ_HIGH)
588                 high_bus_count++;
589         else if (mode == BUS_FREQ_MED)
590                 med_bus_count++;
591         else if (mode == BUS_FREQ_AUDIO)
592                 audio_bus_count++;
593         else if (mode == BUS_FREQ_LOW)
594                 low_bus_count++;
595
596         if (busfreq_suspended || !bus_freq_scaling_initialized ||
597                 !bus_freq_scaling_is_active) {
598                 mutex_unlock(&bus_freq_mutex);
599                 return;
600         }
601         cancel_delayed_work_sync(&low_bus_freq_handler);
602
603         if (cpu_is_imx6dl() || cpu_is_imx6sx()) {
604                 /* No support for medium setpoint on i.MX6DL and i.MX6SX. */
605                 if (mode == BUS_FREQ_MED) {
606                         high_bus_count++;
607                         mode = BUS_FREQ_HIGH;
608                 }
609         }
610
611         if ((mode == BUS_FREQ_HIGH) && (!high_bus_freq_mode)) {
612                 set_high_bus_freq(1);
613                 mutex_unlock(&bus_freq_mutex);
614                 return;
615         }
616
617         if ((mode == BUS_FREQ_MED) && (!high_bus_freq_mode) &&
618                 (!med_bus_freq_mode)) {
619                 set_high_bus_freq(0);
620                 mutex_unlock(&bus_freq_mutex);
621                 return;
622         }
623         if ((mode == BUS_FREQ_AUDIO) && (!high_bus_freq_mode) &&
624                 (!med_bus_freq_mode) && (!audio_bus_freq_mode)) {
625                 set_low_bus_freq();
626                 mutex_unlock(&bus_freq_mutex);
627                 return;
628         }
629         mutex_unlock(&bus_freq_mutex);
630         return;
631 }
632 EXPORT_SYMBOL(request_bus_freq);
633
634 void release_bus_freq(enum bus_freq_mode mode)
635 {
636         mutex_lock(&bus_freq_mutex);
637
638         if (mode == BUS_FREQ_HIGH) {
639                 if (high_bus_count == 0) {
640                         dev_err(busfreq_dev, "high bus count mismatch!\n");
641                         dump_stack();
642                         mutex_unlock(&bus_freq_mutex);
643                         return;
644                 }
645                 high_bus_count--;
646         } else if (mode == BUS_FREQ_MED) {
647                 if (med_bus_count == 0) {
648                         dev_err(busfreq_dev, "med bus count mismatch!\n");
649                         dump_stack();
650                         mutex_unlock(&bus_freq_mutex);
651                         return;
652                 }
653                 med_bus_count--;
654         } else if (mode == BUS_FREQ_AUDIO) {
655                 if (audio_bus_count == 0) {
656                         dev_err(busfreq_dev, "audio bus count mismatch!\n");
657                         dump_stack();
658                         mutex_unlock(&bus_freq_mutex);
659                         return;
660                 }
661                 audio_bus_count--;
662         } else if (mode == BUS_FREQ_LOW) {
663                 if (low_bus_count == 0) {
664                         dev_err(busfreq_dev, "low bus count mismatch!\n");
665                         dump_stack();
666                         mutex_unlock(&bus_freq_mutex);
667                         return;
668                 }
669                 low_bus_count--;
670         }
671
672         if (busfreq_suspended || !bus_freq_scaling_initialized ||
673                 !bus_freq_scaling_is_active) {
674                 mutex_unlock(&bus_freq_mutex);
675                 return;
676         }
677
678         if (cpu_is_imx6dl() || cpu_is_imx6sx()) {
679                 /* No support for medium setpoint on i.MX6DL and i.MX6SX. */
680                 if (mode == BUS_FREQ_MED) {
681                         high_bus_count--;
682                         mode = BUS_FREQ_HIGH;
683                 }
684         }
685
686         if ((!audio_bus_freq_mode) && (high_bus_count == 0) &&
687                 (med_bus_count == 0) && (audio_bus_count != 0)) {
688                 set_low_bus_freq();
689                 mutex_unlock(&bus_freq_mutex);
690                 return;
691         }
692         if ((!low_bus_freq_mode) && (high_bus_count == 0) &&
693                 (med_bus_count == 0) && (audio_bus_count == 0) &&
694                 (low_bus_count != 0)) {
695                 set_low_bus_freq();
696                 mutex_unlock(&bus_freq_mutex);
697                 return;
698         }
699         if ((!ultra_low_bus_freq_mode) && (high_bus_count == 0) &&
700                 (med_bus_count == 0) && (audio_bus_count == 0) &&
701                 (low_bus_count == 0)) {
702                 set_low_bus_freq();
703                 mutex_unlock(&bus_freq_mutex);
704                 return;
705         }
706
707         mutex_unlock(&bus_freq_mutex);
708         return;
709 }
710 EXPORT_SYMBOL(release_bus_freq);
711
712 static struct map_desc ddr_iram_io_desc __initdata = {
713         /* .virtual and .pfn are run-time assigned */
714         .length         = SZ_1M,
715         .type           = MT_MEMORY_RWX_NONCACHED,
716 };
717
718 const static char *ddr_freq_iram_match[] __initconst = {
719         "fsl,ddr-lpm-sram",
720         NULL
721 };
722
723 static int __init imx6_dt_find_ddr_sram(unsigned long node,
724                 const char *uname, int depth, void *data)
725 {
726         unsigned long ddr_iram_addr;
727         __be32 *prop;
728
729         if (of_flat_dt_match(node, ddr_freq_iram_match)) {
730                 unsigned long len;
731                 prop = of_get_flat_dt_prop(node, "reg", &len);
732                 if (prop == NULL || len != (sizeof(unsigned long) * 2))
733                         return EINVAL;
734                 ddr_iram_addr = be32_to_cpu(prop[0]);
735                 ddr_freq_change_total_size = be32_to_cpu(prop[1]);
736                 ddr_freq_change_iram_phys = ddr_iram_addr;
737
738                 /* Make sure ddr_freq_change_iram_phys is 8 byte aligned. */
739                 if ((uintptr_t)(ddr_freq_change_iram_phys) & (FNCPY_ALIGN - 1))
740                         ddr_freq_change_iram_phys += FNCPY_ALIGN - ((uintptr_t)ddr_freq_change_iram_phys % (FNCPY_ALIGN));
741         }
742         return 0;
743 }
744
745 void __init imx6_busfreq_map_io(void)
746 {
747         /*
748          * Get the address of IRAM to be used by the ddr frequency
749          * change code from the device tree.
750          */
751         WARN_ON(of_scan_flat_dt(imx6_dt_find_ddr_sram, NULL));
752
753         if (ddr_freq_change_iram_phys) {
754                 ddr_freq_change_iram_base = IMX_IO_P2V(ddr_freq_change_iram_phys);
755                 if ((iram_tlb_phys_addr & 0xFFF00000) != (ddr_freq_change_iram_phys & 0xFFF00000)) {
756                         /* We need to create a 1M page table entry. */
757                         ddr_iram_io_desc.virtual = IMX_IO_P2V(ddr_freq_change_iram_phys & 0xFFF00000);
758                         ddr_iram_io_desc.pfn = __phys_to_pfn(ddr_freq_change_iram_phys & 0xFFF00000);
759                         iotable_init(&ddr_iram_io_desc, 1);
760                 }
761                 memset((void *)ddr_freq_change_iram_base, 0, ddr_freq_change_total_size);
762         }
763 }
764
765 static void bus_freq_daemon_handler(struct work_struct *work)
766 {
767         mutex_lock(&bus_freq_mutex);
768         if ((!low_bus_freq_mode) && (high_bus_count == 0) &&
769                 (med_bus_count == 0) && (audio_bus_count == 0))
770                 set_low_bus_freq();
771         mutex_unlock(&bus_freq_mutex);
772 }
773
774 static ssize_t bus_freq_scaling_enable_show(struct device *dev,
775                                 struct device_attribute *attr, char *buf)
776 {
777         if (bus_freq_scaling_is_active)
778                 return sprintf(buf, "Bus frequency scaling is enabled\n");
779         else
780                 return sprintf(buf, "Bus frequency scaling is disabled\n");
781 }
782
783 static ssize_t bus_freq_scaling_enable_store(struct device *dev,
784                                  struct device_attribute *attr,
785                                  const char *buf, size_t size)
786 {
787         if (strncmp(buf, "1", 1) == 0) {
788                 bus_freq_scaling_is_active = 1;
789                 set_high_bus_freq(1);
790                 /*
791                  * We set bus freq to highest at the beginning,
792                  * so we use this daemon thread to make sure system
793                  * can enter low bus mode if
794                  * there is no high bus request pending
795                  */
796                 schedule_delayed_work(&bus_freq_daemon,
797                         usecs_to_jiffies(5000000));
798         } else if (strncmp(buf, "0", 1) == 0) {
799                 if (bus_freq_scaling_is_active)
800                         set_high_bus_freq(1);
801                 bus_freq_scaling_is_active = 0;
802         }
803         return size;
804 }
805
806 static int bus_freq_pm_notify(struct notifier_block *nb, unsigned long event,
807         void *dummy)
808 {
809         mutex_lock(&bus_freq_mutex);
810
811         if (event == PM_SUSPEND_PREPARE) {
812                 high_bus_count++;
813                 set_high_bus_freq(1);
814                 busfreq_suspended = 1;
815         } else if (event == PM_POST_SUSPEND) {
816                 busfreq_suspended = 0;
817                 high_bus_count--;
818                 schedule_delayed_work(&bus_freq_daemon,
819                         usecs_to_jiffies(5000000));
820         }
821
822         mutex_unlock(&bus_freq_mutex);
823
824         return NOTIFY_OK;
825 }
826
827 static int busfreq_reboot_notifier_event(struct notifier_block *this,
828                                                  unsigned long event, void *ptr)
829 {
830         /* System is rebooting. Set the system into high_bus_freq_mode. */
831         request_bus_freq(BUS_FREQ_HIGH);
832
833         return 0;
834 }
835
836 static struct notifier_block imx_bus_freq_pm_notifier = {
837         .notifier_call = bus_freq_pm_notify,
838 };
839
840 static struct notifier_block imx_busfreq_reboot_notifier = {
841         .notifier_call = busfreq_reboot_notifier_event,
842 };
843
844
845 static DEVICE_ATTR(enable, 0644, bus_freq_scaling_enable_show,
846                         bus_freq_scaling_enable_store);
847
848 /*!
849  * This is the probe routine for the bus frequency driver.
850  *
851  * @param   pdev   The platform device structure
852  *
853  * @return         The function returns 0 on success
854  *
855  */
856
857 static int busfreq_probe(struct platform_device *pdev)
858 {
859         u32 err;
860
861         busfreq_dev = &pdev->dev;
862
863         /* Return if no IRAM space is allocated for ddr freq change code. */
864         if (!ddr_freq_change_iram_base)
865                 return ENOMEM;
866
867         pll2_400 = devm_clk_get(&pdev->dev, "pll2_pfd2_396m");
868         if (IS_ERR(pll2_400)) {
869                 dev_err(busfreq_dev, "%s: failed to get pll2_pfd2_396m\n",
870                 __func__);
871                 return PTR_ERR(pll2_400);
872         }
873
874         pll2_200 = devm_clk_get(&pdev->dev, "pll2_198m");
875         if (IS_ERR(pll2_200)) {
876                 dev_err(busfreq_dev, "%s: failed to get pll2_198m\n",
877                         __func__);
878                 return PTR_ERR(pll2_200);
879         }
880
881         pll2_bus = devm_clk_get(&pdev->dev, "pll2_bus");
882         if (IS_ERR(pll2_bus)) {
883                 dev_err(busfreq_dev, "%s: failed to get pll2_bus\n",
884                         __func__);
885                 return PTR_ERR(pll2_bus);
886         }
887
888         cpu_clk = devm_clk_get(&pdev->dev, "arm");
889         if (IS_ERR(cpu_clk)) {
890                 dev_err(busfreq_dev, "%s: failed to get cpu_clk\n",
891                         __func__);
892                 return PTR_ERR(cpu_clk);
893         }
894
895         pll3 = devm_clk_get(&pdev->dev, "pll3_usb_otg");
896         if (IS_ERR(pll3)) {
897                 dev_err(busfreq_dev, "%s: failed to get pll3_usb_otg\n",
898                         __func__);
899                 return PTR_ERR(pll3);
900         }
901
902         periph_clk = devm_clk_get(&pdev->dev, "periph");
903         if (IS_ERR(periph_clk)) {
904                 dev_err(busfreq_dev, "%s: failed to get periph\n",
905                         __func__);
906                 return PTR_ERR(periph_clk);
907         }
908
909         periph_pre_clk = devm_clk_get(&pdev->dev, "periph_pre");
910         if (IS_ERR(periph_pre_clk)) {
911                 dev_err(busfreq_dev, "%s: failed to get periph_pre\n",
912                         __func__);
913                 return PTR_ERR(periph_pre_clk);
914         }
915
916         periph_clk2 = devm_clk_get(&pdev->dev, "periph_clk2");
917         if (IS_ERR(periph_clk2)) {
918                 dev_err(busfreq_dev, "%s: failed to get periph_clk2\n",
919                         __func__);
920                 return PTR_ERR(periph_clk2);
921         }
922
923         periph_clk2_sel = devm_clk_get(&pdev->dev, "periph_clk2_sel");
924         if (IS_ERR(periph_clk2_sel)) {
925                 dev_err(busfreq_dev, "%s: failed to get periph_clk2_sel\n",
926                         __func__);
927                 return PTR_ERR(periph_clk2_sel);
928         }
929
930         osc_clk = devm_clk_get(&pdev->dev, "osc");
931         if (IS_ERR(osc_clk)) {
932                 dev_err(busfreq_dev, "%s: failed to get osc_clk\n",
933                         __func__);
934                 return PTR_ERR(osc_clk);
935         }
936
937         if (cpu_is_imx6dl()) {
938                 axi_alt_sel_clk = devm_clk_get(&pdev->dev, "axi_alt_sel");
939                 if (IS_ERR(axi_alt_sel_clk)) {
940                         dev_err(busfreq_dev, "%s: failed to get axi_alt_sel_clk\n",
941                                 __func__);
942                         return PTR_ERR(axi_alt_sel_clk);
943                 }
944
945                 axi_sel_clk = devm_clk_get(&pdev->dev, "axi_sel");
946                 if (IS_ERR(axi_sel_clk)) {
947                         dev_err(busfreq_dev, "%s: failed to get axi_sel_clk\n",
948                                 __func__);
949                         return PTR_ERR(axi_sel_clk);
950                 }
951
952                 pll3_pfd1_540m = devm_clk_get(&pdev->dev, "pll3_pfd1_540m");
953                 if (IS_ERR(pll3_pfd1_540m)) {
954                         dev_err(busfreq_dev,
955                                 "%s: failed to get pll3_pfd1_540m\n", __func__);
956                         return PTR_ERR(pll3_pfd1_540m);
957                 }
958         }
959
960         if (cpu_is_imx6sl() || cpu_is_imx6sx()) {
961                 pll1_sys = devm_clk_get(&pdev->dev, "pll1_sys");
962                 if (IS_ERR(pll1_sys)) {
963                         dev_err(busfreq_dev, "%s: failed to get pll1_sys\n",
964                                 __func__);
965                         return PTR_ERR(pll1_sys);
966                 }
967
968                 ahb_clk = devm_clk_get(&pdev->dev, "ahb");
969                 if (IS_ERR(ahb_clk)) {
970                         dev_err(busfreq_dev, "%s: failed to get ahb_clk\n",
971                                 __func__);
972                         return PTR_ERR(ahb_clk);
973                 }
974
975                 ocram_clk = devm_clk_get(&pdev->dev, "ocram");
976                 if (IS_ERR(ocram_clk)) {
977                         dev_err(busfreq_dev, "%s: failed to get ocram_clk\n",
978                                 __func__);
979                         return PTR_ERR(ocram_clk);
980                 }
981
982                 pll1_sw_clk = devm_clk_get(&pdev->dev, "pll1_sw");
983                 if (IS_ERR(pll1_sw_clk)) {
984                         dev_err(busfreq_dev, "%s: failed to get pll1_sw_clk\n",
985                                 __func__);
986                         return PTR_ERR(pll1_sw_clk);
987                 }
988
989                 periph2_clk = devm_clk_get(&pdev->dev, "periph2");
990                 if (IS_ERR(periph2_clk)) {
991                         dev_err(busfreq_dev, "%s: failed to get periph2\n",
992                                 __func__);
993                         return PTR_ERR(periph2_clk);
994                 }
995
996                 periph2_pre_clk = devm_clk_get(&pdev->dev, "periph2_pre");
997                 if (IS_ERR(periph2_pre_clk)) {
998                         dev_err(busfreq_dev,
999                                 "%s: failed to get periph2_pre_clk\n",
1000                                 __func__);
1001                         return PTR_ERR(periph2_pre_clk);
1002                 }
1003
1004                 periph2_clk2 = devm_clk_get(&pdev->dev, "periph2_clk2");
1005                 if (IS_ERR(periph2_clk2)) {
1006                         dev_err(busfreq_dev,
1007                                 "%s: failed to get periph2_clk2\n",
1008                                 __func__);
1009                         return PTR_ERR(periph2_clk2);
1010                 }
1011
1012                 periph2_clk2_sel = devm_clk_get(&pdev->dev, "periph2_clk2_sel");
1013                 if (IS_ERR(periph2_clk2_sel)) {
1014                         dev_err(busfreq_dev,
1015                                 "%s: failed to get periph2_clk2_sel\n",
1016                                 __func__);
1017                         return PTR_ERR(periph2_clk2_sel);
1018                 }
1019
1020                 step_clk = devm_clk_get(&pdev->dev, "step");
1021                 if (IS_ERR(step_clk)) {
1022                         dev_err(busfreq_dev,
1023                                 "%s: failed to get step_clk\n",
1024                                 __func__);
1025                         return PTR_ERR(step_clk);
1026                 }
1027         }
1028         if (cpu_is_imx6sl()) {
1029                 pll2_bypass_src = devm_clk_get(&pdev->dev, "pll2_bypass_src");
1030                 if (IS_ERR(pll2_bypass_src)) {
1031                         dev_err(busfreq_dev, "%s: failed to get pll2_bypass_src\n",
1032                                 __func__);
1033                         return PTR_ERR(pll2_bypass_src);
1034                 }
1035
1036                 pll2 = devm_clk_get(&pdev->dev, "pll2");
1037                 if (IS_ERR(pll2)) {
1038                         dev_err(busfreq_dev, "%s: failed to get pll2\n",
1039                                 __func__);
1040                         return PTR_ERR(pll2);
1041                 }
1042
1043                 pll2_bypass = devm_clk_get(&pdev->dev, "pll2_bypass");
1044                 if (IS_ERR(pll2_bypass)) {
1045                         dev_err(busfreq_dev, "%s: failed to get pll2_bypass\n",
1046                                 __func__);
1047                         return PTR_ERR(pll2_bypass);
1048                 }
1049         }
1050         if (cpu_is_imx6sx()) {
1051                 mmdc_clk = devm_clk_get(&pdev->dev, "mmdc");
1052                 if (IS_ERR(mmdc_clk)) {
1053                         dev_err(busfreq_dev,
1054                                 "%s: failed to get mmdc_clk\n",
1055                                 __func__);
1056                         return PTR_ERR(mmdc_clk);
1057                 }
1058                 m4_clk = devm_clk_get(&pdev->dev, "m4");
1059                 if (IS_ERR(m4_clk)) {
1060                         dev_err(busfreq_dev,
1061                                 "%s: failed to get m4_clk\n",
1062                                 __func__);
1063                         return PTR_ERR(m4_clk);
1064                 }
1065         }
1066
1067         err = sysfs_create_file(&busfreq_dev->kobj, &dev_attr_enable.attr);
1068         if (err) {
1069                 dev_err(busfreq_dev,
1070                        "Unable to register sysdev entry for BUSFREQ");
1071                 return err;
1072         }
1073
1074         if (of_property_read_u32(pdev->dev.of_node, "fsl,max_ddr_freq",
1075                         &ddr_normal_rate)) {
1076                 dev_err(busfreq_dev, "max_ddr_freq entry missing\n");
1077                 return -EINVAL;
1078         }
1079
1080         high_bus_freq_mode = 1;
1081         med_bus_freq_mode = 0;
1082         low_bus_freq_mode = 0;
1083         audio_bus_freq_mode = 0;
1084         ultra_low_bus_freq_mode = 0;
1085
1086         bus_freq_scaling_is_active = 1;
1087         bus_freq_scaling_initialized = 1;
1088
1089         ddr_low_rate = LPAPM_CLK;
1090         if (cpu_is_imx6q()) {
1091                 if (of_property_read_u32(pdev->dev.of_node, "fsl,med_ddr_freq",
1092                                 &ddr_med_rate)) {
1093                         dev_info(busfreq_dev,
1094                                         "DDR medium rate not supported.\n");
1095                         ddr_med_rate = ddr_normal_rate;
1096                 }
1097         }
1098
1099         INIT_DELAYED_WORK(&low_bus_freq_handler, reduce_bus_freq_handler);
1100         INIT_DELAYED_WORK(&bus_freq_daemon, bus_freq_daemon_handler);
1101         register_pm_notifier(&imx_bus_freq_pm_notifier);
1102         register_reboot_notifier(&imx_busfreq_reboot_notifier);
1103
1104         /*
1105          * Need to make sure to an entry for the ddr freq change code address in the IRAM page table.
1106          * This is only required if the DDR freq code and suspend/idle code are in different OCRAM spaces.
1107          */
1108         if ((iram_tlb_phys_addr & 0xFFF00000) != (ddr_freq_change_iram_phys & 0xFFF00000)) {
1109                 unsigned long i;
1110
1111                 /*
1112                  * Make sure the ddr_iram virtual address has a mapping
1113                  * in the IRAM page table.
1114                  */
1115                 i = ((IMX_IO_P2V(ddr_freq_change_iram_phys) >> 20) << 2) / 4;
1116                 *((unsigned long *)iram_tlb_base_addr + i) =
1117                         (ddr_freq_change_iram_phys  & 0xFFF00000) | TT_ATTRIB_NON_CACHEABLE_1M;
1118         }
1119
1120         if (cpu_is_imx6sl()) {
1121                 err = init_mmdc_lpddr2_settings(pdev);
1122         } else if (cpu_is_imx6sx()) {
1123                 ddr_type = imx_mmdc_get_ddr_type();
1124                 /* check whether it is a DDR3 or LPDDR2 board */
1125                 if (ddr_type == MMDC_MDMISC_DDR_TYPE_DDR3)
1126                         err = init_mmdc_ddr3_settings_imx6sx(pdev);
1127                 else if (ddr_type == MMDC_MDMISC_DDR_TYPE_LPDDR2)
1128                         err = init_mmdc_lpddr2_settings(pdev);
1129                 /* if M4 is enabled and rate > 24MHz, add high bus count */
1130                 if (imx_src_is_m4_enabled() &&
1131                         (clk_get_rate(m4_clk) > LPAPM_CLK))
1132                         high_bus_count++;
1133         } else {
1134                 err = init_mmdc_ddr3_settings_imx6q(pdev);
1135         }
1136
1137         if (err) {
1138                 dev_err(busfreq_dev, "Busfreq init of MMDC failed\n");
1139                 return err;
1140         }
1141         return 0;
1142 }
1143
1144 static const struct of_device_id imx6_busfreq_ids[] = {
1145         { .compatible = "fsl,imx6_busfreq", },
1146         { /* sentinel */ }
1147 };
1148
1149 static struct platform_driver busfreq_driver = {
1150         .driver = {
1151                 .name = "imx6_busfreq",
1152                 .owner  = THIS_MODULE,
1153                 .of_match_table = imx6_busfreq_ids,
1154                 },
1155         .probe = busfreq_probe,
1156 };
1157
1158 /*!
1159  * Initialise the busfreq_driver.
1160  *
1161  * @return  The function always returns 0.
1162  */
1163
1164 static int __init busfreq_init(void)
1165 {
1166 #ifndef CONFIG_MX6_VPU_352M
1167         if (platform_driver_register(&busfreq_driver) != 0)
1168                 return -ENODEV;
1169
1170         printk(KERN_INFO "Bus freq driver module loaded\n");
1171 #endif
1172         return 0;
1173 }
1174
1175 static void __exit busfreq_cleanup(void)
1176 {
1177         sysfs_remove_file(&busfreq_dev->kobj, &dev_attr_enable.attr);
1178
1179         /* Unregister the device structure */
1180         platform_driver_unregister(&busfreq_driver);
1181         bus_freq_scaling_initialized = 0;
1182 }
1183
1184 module_init(busfreq_init);
1185 module_exit(busfreq_cleanup);
1186
1187 MODULE_AUTHOR("Freescale Semiconductor, Inc.");
1188 MODULE_DESCRIPTION("BusFreq driver");
1189 MODULE_LICENSE("GPL");