/* * Suspend */ int s5p_tv_early_suspend(struct platform_device *dev, pm_message_t state) { BASEPRINTK("(hpd_status = %d)++\n", s5ptv_status.hpd_status); mutex_lock(mutex_for_fo); s5ptv_status.suspend_status = true; if(!(s5ptv_status.hpd_status)) { mutex_unlock(mutex_for_fo); return 0; } else { /* video layer stop */ if ( s5ptv_status.vp_layer_enable ) { _s5p_vlayer_stop(); s5ptv_status.vp_layer_enable = true; } /* grp0 layer stop */ if ( s5ptv_status.grp_layer_enable[0] ) { _s5p_grp_stop(VM_GPR0_LAYER); s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true; } /* grp1 layer stop */ if ( s5ptv_status.grp_layer_enable[1] ) { _s5p_grp_stop(VM_GPR1_LAYER); s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true; } /* tv off */ if ( s5ptv_status.tvout_output_enable ) { _s5p_tv_if_stop(); s5ptv_status.tvout_output_enable = true; s5ptv_status.tvout_param_available = true; } #ifdef CONFIG_PM_PWR_GATING /* clk & power off */ s5p_tv_clk_gate( false ); if(s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI || s5ptv_status.tvout_param.out_mode == TVOUT_OUTPUT_HDMI_RGB) tv_phy_power( false ); #endif #if 0 #ifdef CONFIG_CPU_FREQ s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_4); #endif #endif } mutex_unlock(mutex_for_fo); BASEPRINTK("()--\n"); return 0; }
static int mfc_release(struct inode *inode, struct file *file) { mfc_inst_ctx *mfc_ctx; int ret; #if ENABLE_MONITORING_MFC_DD mfc_info("MFC Release..\n"); #endif mutex_lock(&mfc_mutex); #if Frame_Base_Power_CTR_ON clk_enable(mfc_clk); #endif mfc_ctx = (mfc_inst_ctx *)file->private_data; if (mfc_ctx == NULL) { mfc_err("MFCINST_ERR_INVALID_PARAM\n"); ret = -EIO; goto out_release; } mfc_release_all_buffer(mfc_ctx->mem_inst_no); mfc_merge_fragment(mfc_ctx->mem_inst_no); mfc_return_mem_inst_no(mfc_ctx->mem_inst_no); /* In case of no instance, we should not release codec instance */ if (mfc_ctx->InstNo >= 0) mfc_return_inst_no(mfc_ctx->InstNo, mfc_ctx->MfcCodecType); kfree(mfc_ctx); ret = 0; out_release: if (!mfc_is_running()) { #ifdef CONFIG_CPU_FREQ s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_1); #endif #ifdef CONFIG_PM_PWR_GATING s5pc110_unlock_power_domain(MFC_DOMAIN_LOCK_TOKEN); #endif #ifdef CONFIG_S5PC11X_LPAUDIO s5pc110_set_lpaudio_lock(0); #endif /* CONFIG_S5PC11X_LPAUDIO */ } clk_disable(mfc_clk); mutex_unlock(&mfc_mutex); return ret; }
int s5p_tv_v_release(struct file *filp) { #if defined(CONFIG_CPU_S5PV210) && defined(CONFIG_PM_PWR_GATING) if((s5ptv_status.hpd_status) && !(s5ptv_status.suspend_status)) { #endif if(s5ptv_status.vp_layer_enable) _s5p_vlayer_stop(); if(s5ptv_status.tvout_output_enable) _s5p_tv_if_stop(); #if defined(CONFIG_CPU_S5PV210) && defined(CONFIG_PM_PWR_GATING) }else s5ptv_status.vp_layer_enable = false; #endif s5ptv_status.hdcp_en = false; s5ptv_status.tvout_output_enable = false; /* * drv. release * - just check drv. state reg. or not. */ #ifdef I2C_BASE mutex_lock(mutex_for_i2c); if (hdcp_i2c_drv_state) { i2c_del_driver(&hdcp_i2c_driver); hdcp_i2c_drv_state = false; } mutex_unlock(mutex_for_i2c); #endif #ifdef CONFIG_CPU_S5PV210 #ifdef CONFIG_PM_PWR_GATING if((s5ptv_status.hpd_status) && !(s5ptv_status.suspend_status)) { #endif s5p_tv_clk_gate(false); tv_phy_power( false ); #if 0 #ifdef CONFIG_CPU_FREQ if(s5ptv_status.hpd_status) s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_4); #endif #endif #ifdef CONFIG_PM_PWR_GATING } #endif #endif return 0; }
static ssize_t dvfslock_ctrl(const char *buf, size_t count) { unsigned int ret = -EINVAL; int dlevel; int dtime_msec; //mutex_lock(&dvfslock_ctrl_mutex); ret = sscanf(buf, "%u", &gdDvfsctrl); if (ret != 1) return -EINVAL; if (!g_dbs_timer_started) return -EINVAL; if (gdDvfsctrl == 0) { if (dvfsctrl_locked) { s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_6); dvfsctrl_locked = 0; return -EINVAL; } else { return -EINVAL; } } if (dvfsctrl_locked) return 0; dlevel = gdDvfsctrl & 0xffff0000; dtime_msec = gdDvfsctrl & 0x0000ffff; if (dtime_msec <16) dtime_msec=16; if (dtime_msec == 0) return -EINVAL; if(dlevel) dlevel = LEV_800MHZ; else dlevel = LEV_1000MHZ; printk("+++++DBG dvfs lock level=%d, time=%d, scanVal=%08x\n",dlevel,dtime_msec, gdDvfsctrl); s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_6, dlevel); dvfsctrl_locked=1; schedule_delayed_work(&dvfslock_crtl_unlock_work, msecs_to_jiffies(dtime_msec)); //mutex_unlock(&dvfslock_ctrl_mutex); return -EINVAL; }
/** * enter_state - Do common work of entering low-power state. * @state: pm_state structure for state we're entering. * * Make sure we're the only ones trying to enter a sleep state. Fail * if someone has beat us to it, since we don't want anything weird to * happen when we wake up. * Then, do the setup for suspend, enter the state, and cleaup (after * we've woken up). */ static int enter_state(suspend_state_t state) { int error; extern unsigned long set1_gpio; extern unsigned long set2_gpio; if (!valid_state(state)) return -ENODEV; if (!mutex_trylock(&pm_mutex)) return -EBUSY; #ifdef CONFIG_CPU_FREQ #ifdef SLEEP_CPUFREQ_CONSERVATIVE // change cpufreq governor to performance // if conservative governor #ifdef SLEEP_CPUFREQ_MANUAL_SET if(is_userspace_gov()) { g_cpuspeed = s5pc110_getspeed(0); printk("userspace cpu speed %d \n",g_cpuspeed); userSpaceGovernor=true; } else if(is_conservative_gov()) { s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_5, 0); gbGovernorTransition=true; } #else//SLEEP_CPUFREQ_MANUAL_SET if(is_conservative_gov()) { s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_5, 0); gbGovernorTransition = true; gpio_set_value(set2_gpio, 0); gpio_set_value(set1_gpio, 1); } #endif//SLEEP_CPUFREQ_MANUAL_SET #else//SLEEP_CPUFREQ_CONSERVATIVE cpufreq_direct_set_policy(0, "userspace"); cpufreq_direct_store_scaling_setspeed(0, "800000", 0); #endif//SLEEP_CPUFREQ_CONSERVATIVE #endif//CONFIG_CPU_FREQ printk(KERN_INFO "PM: Syncing filesystems ... "); sys_sync(); printk("done.\n"); pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]); error = suspend_prepare(); if (error) goto Unlock; if (suspend_test(TEST_FREEZER)) goto Finish; pr_debug("PM: Entering %s sleep\n", pm_states[state]); error = suspend_devices_and_enter(state); Finish: pr_debug("PM: Finishing wakeup.\n"); suspend_finish(); Unlock: mutex_unlock(&pm_mutex); #ifdef CONFIG_CPU_FREQ #ifdef SLEEP_CPUFREQ_CONSERVATIVE #ifdef SLEEP_CPUFREQ_MANUAL_SET if(userSpaceGovernor) { s5pc110_pm_target(g_cpuspeed); printk("recover userspace cpu speed %d \n",g_cpuspeed); g_cpuspeed=0; userSpaceGovernor=false; } if(gbGovernorTransition) { s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_5); gbGovernorTransition=false; } #else//SLEEP_CPUFREQ_MANUAL_SET // change cpufreq to original one if(gbGovernorTransition) { s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_5); gbGovernorTransition = false; } #endif//SLEEP_CPUFREQ_MANUAL_SET #else//SLEEP_CPUFREQ_CONSERVATIVE cpufreq_direct_set_policy(0, "conservative"); #endif//SLEEP_CPUFREQ_CONSERVATIVE #endif//CONFIG_CPU_FREQ return error; }
static void do_dvfsunlock_timer(struct work_struct *work) { //printk("----DBG dvfs unlock\n"); dvfsctrl_locked = 0; s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_6); }
int enter_state(suspend_state_t state) { int error; struct cpufreq_policy policy; if (!valid_state(state)) return -ENODEV; if (!mutex_trylock(&pm_mutex)) return -EBUSY; #ifdef CONFIG_CPU_FREQ #if 1 // change cpufreq governor to performance // if conservative governor if(is_userspace_gov()) { g_cpuspeed = s5pc110_getspeed(0); printk("userspace cpu speed %d \n",g_cpuspeed); userSpaceGovernor=true; } else if(is_conservative_gov()) { /*Fix the upper transition scaling*/ g_dvfs_fix_lock_limit = true; #if MAXIMUM_FREQ == 1200000 s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_7, LEV_800MHZ); #else s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_7, LEV_832MHZ); #endif gbClockFix = true; error = cpufreq_get_policy(&policy, 0); if(error) { printk("Failed to get policy\n"); goto Unlock; } cpufreq_driver_target(&policy, 800000, CPUFREQ_RELATION_L); } #else // cpufreq_direct_set_policy(0, "userspace"); // cpufreq_direct_store_scaling_setspeed(0, "800000", 0); #endif #endif printk(KERN_INFO "PM: Syncing filesystems ... "); sys_sync(); printk("done.\n"); pr_debug("PM: Preparing system for %s sleep\n", pm_states[state]); error = suspend_prepare(); if (error) goto Unlock; if (suspend_test(TEST_FREEZER)) goto Finish; pr_debug("PM: Entering %s sleep\n", pm_states[state]); error = suspend_devices_and_enter(state); Finish: pr_debug("PM: Finishing wakeup.\n"); suspend_finish(); Unlock: mutex_unlock(&pm_mutex); #ifdef CONFIG_CPU_FREQ #if 1 if(userSpaceGovernor) { s5pc110_pm_target(g_cpuspeed); printk("recover userspace cpu speed %d \n",g_cpuspeed); g_cpuspeed=0; userSpaceGovernor=false; } // change cpufreq to original one if(gbClockFix) { g_dvfs_fix_lock_limit = false; s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_7); gbClockFix = false; } #else // cpufreq_direct_set_policy(0, "conservative"); #endif #endif return error; }
void s5p_handle_cable(void) { char env_buf[120]; char *envp[2]; int env_offset = 0; #if defined (CONFIG_S5PC110_DEMPSEY_BOARD) //MHL v1 //NAGSM_Android_SEL_Kernel_Aakash_20101130 #else if(s5ptv_status.tvout_param.out_mode != TVOUT_OUTPUT_HDMI && s5ptv_status.tvout_param.out_mode != TVOUT_OUTPUT_HDMI_RGB) return; #endif bool previous_hpd_status = s5ptv_status.hpd_status; #ifdef CONFIG_HDMI_HPD s5ptv_status.hpd_status= s5p_hpd_get_state(); #else return; #endif memset(env_buf, 0, sizeof(env_buf)); if(previous_hpd_status == s5ptv_status.hpd_status) { BASEPRINTK("same hpd_status value: %d\n", previous_hpd_status); return; } if(s5ptv_status.hpd_status) { BASEPRINTK("\n hdmi cable is connected \n"); if(s5ptv_status.suspend_status) return; #if 0 #ifdef CONFIG_CPU_FREQ #ifdef CONFIG_CPU_MAX_FREQ_1GHZ // 2010.3.9. s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 3); #else s5pc110_lock_dvfs_high_level(DVFS_LOCK_TOKEN_4, 2); #endif #endif #endif #ifdef CONFIG_PM_PWR_GATING s5p_tv_clk_gate( true ); tv_phy_power( true ); #endif /* tv on */ if ( s5ptv_status.tvout_output_enable ) _s5p_tv_if_start(); /* video layer start */ if ( s5ptv_status.vp_layer_enable ) _s5p_vlayer_start(); /* grp0 layer start */ if ( s5ptv_status.grp_layer_enable[0] ) _s5p_grp_start(VM_GPR0_LAYER); /* grp1 layer start */ if ( s5ptv_status.grp_layer_enable[1] ) _s5p_grp_start(VM_GPR1_LAYER); sprintf(env_buf, "HDMI_STATE=online"); envp[env_offset++] = env_buf; envp[env_offset] = NULL; kobject_uevent_env(&(s5p_tvout[0].dev.kobj), KOBJ_CHANGE, envp); } else{ BASEPRINTK("\n hdmi cable is disconnected \n"); if(s5ptv_status.suspend_status) return; sprintf(env_buf, "HDMI_STATE=offline"); envp[env_offset++] = env_buf; envp[env_offset] = NULL; kobject_uevent_env(&(s5p_tvout[0].dev.kobj), KOBJ_CHANGE, envp); if ( s5ptv_status.vp_layer_enable ) { _s5p_vlayer_stop(); s5ptv_status.vp_layer_enable = true; } /* grp0 layer stop */ if ( s5ptv_status.grp_layer_enable[0] ) { _s5p_grp_stop(VM_GPR0_LAYER); s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true; } /* grp1 layer stop */ if ( s5ptv_status.grp_layer_enable[1] ) { _s5p_grp_stop(VM_GPR1_LAYER); s5ptv_status.grp_layer_enable[VM_GPR0_LAYER] = true; } /* tv off */ if ( s5ptv_status.tvout_output_enable ) { _s5p_tv_if_stop(); s5ptv_status.tvout_output_enable = true; s5ptv_status.tvout_param_available = true; } #ifdef CONFIG_PM_PWR_GATING /* clk & power off */ s5p_tv_clk_gate( false ); tv_phy_power( false ); #endif #if 0 #ifdef CONFIG_CPU_FREQ s5pc110_unlock_dvfs_high_level(DVFS_LOCK_TOKEN_4); #endif #endif } }