45
45
#include <mach/hardware.h>
46
46
#include <mach/mxc_dvfs.h>
47
47
#include <mach/sdram_autogating.h>
48
#include <mach/clock.h>
48
49
#if defined(CONFIG_ARCH_MX37)
49
50
#include <mach/mxc_dptc.h>
82
83
void stop_dvfs_per(void);
83
84
int dvfs_per_active(void);
84
85
int dvfs_per_divider_active(void);
85
int dvfs_per_pixel_clk_limit(int pix_clk);
86
int dvfs_per_pixel_clk_limit();
87
88
extern int low_bus_freq_mode;
88
89
extern int bus_freq_scaling_is_active;
502
503
if (bus_freq_scaling_is_active) {
504
dvfs_per_is_paused = 1;
503
505
printk(KERN_INFO "Cannot start DVFS-PER since bus_freq_scaling is active\n");
507
if (!ipu_freq_scaled) {
508
printk(KERN_INFO "Cannot start DVFS-PER since pixel clock is above 60MHz\n");
509
if (!dvfs_per_pixel_clk_limit()) {
510
dvfs_per_is_paused = 1;
511
printk(KERN_INFO "Cannot start DVFS-PER since pixel clock is\
512
above 60MHz or divider is not even\n");
613
617
return dvfs_per_low_freq;
616
int dvfs_per_pixel_clk_limit(int pix_clk)
620
int dvfs_per_pixel_clk_limit()
618
if (pix_clk < DVFS_MAX_PIX_CLK && (!ipu_freq_scaled))
622
struct clk *disp0_pixel_clk;
623
struct clk *disp1_pixel_clk;
631
disp0_pixel_clk = clk_get(NULL, "pixel_clk.0");
632
disp1_pixel_clk = clk_get(NULL, "pixel_clk.1");
634
if (disp0_pixel_clk != NULL)
635
disp0_rate = clk_get_rate(disp0_pixel_clk);
637
if (disp1_pixel_clk != NULL)
638
disp1_rate = clk_get_rate(disp1_pixel_clk);
640
/* DVFS-PER will not work if pixel clock divider is odd */
642
div1 = (clk_get_rate(
643
clk_get_parent(disp0_pixel_clk)) * 10) / disp0_rate;
645
if ((div1 % 2) || ((div1 / 10) % 2))
648
if ((div2 % 2) || ((div2 / 10) % 2))
652
div2 = (clk_get_rate(
653
clk_get_parent(disp1_pixel_clk)) * 10) / disp1_rate;
655
if (((disp0_rate < DVFS_MAX_PIX_CLK && even_div1) ||
656
!clk_get_usecount(disp0_pixel_clk)) &&
657
((disp1_rate < DVFS_MAX_PIX_CLK && even_div2) ||
658
!clk_get_usecount(disp1_pixel_clk)))
619
659
ipu_freq_scaled = 1;
621
661
ipu_freq_scaled = 0;
663
clk_put(disp0_pixel_clk);
664
clk_put(disp1_pixel_clk);
622
666
return ipu_freq_scaled;
747
791
cpu_clk = clk_get(NULL, "cpu_clk");
748
792
ahb_clk = clk_get(NULL, "ahb_clk");
749
793
axi_b_clk = clk_get(NULL, "axi_b_clk");
750
795
if (cpu_is_mx51())
751
796
ddr_hf_clk = clk_get(NULL, "ddr_hf_clk");