void switch_lcd_mod_gate(int flag) { unsigned long flags; spin_lock_irqsave(&gate_lock, flags); PRINT_INFO("turn %s lcd module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VCLK2_ENCL); __CLK_GATE_ON(VCLK2_VENCL); } else { __CLK_GATE_OFF(VCLK2_VENCL); __CLK_GATE_OFF(VCLK2_ENCL); } spin_unlock_irqrestore(&gate_lock, flags); }
static int _switch_gate(mod_type_t type, int flag) { int ret = 0; switch(type) { case MOD_VDEC: PRINT_INFO("turn %s vdec module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VLD_CLK); __CLK_GATE_ON(IQIDCT_CLK); __CLK_GATE_ON(MC_CLK); __CLK_GATE_ON(MDEC_CLK_ASSIST); __CLK_GATE_ON(MDEC_CLK_DBLK); __CLK_GATE_ON(MDEC_CLK_PIC_DC); __CLK_GATE_ON(MDEC_CLK_PSC); } else { __CLK_GATE_OFF(VLD_CLK); __CLK_GATE_OFF(IQIDCT_CLK); __CLK_GATE_OFF(MC_CLK); __CLK_GATE_OFF(MDEC_CLK_ASSIST); __CLK_GATE_OFF(MDEC_CLK_DBLK); __CLK_GATE_OFF(MDEC_CLK_PIC_DC); __CLK_GATE_OFF(MDEC_CLK_PSC); } break; case MOD_AUDIO: PRINT_INFO("turn %s audio module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(AIU_AI_TOP_GLUE); __CLK_GATE_ON(AIU_IEC958); __CLK_GATE_ON(AIU_I2S_OUT); __CLK_GATE_ON(AIU_AMCLK_MEASURE); __CLK_GATE_ON(AIU_AIFIFO2); __CLK_GATE_ON(AIU_AUD_MIXER); __CLK_GATE_ON(AIU_MIXER_REG); __CLK_GATE_ON(AIU_ADC); //__CLK_GATE_ON(AIU_PCLK); __CLK_GATE_ON(AIU_AOCLK); __CLK_GATE_ON(AIU_ICE958_AMCLK); } else { __CLK_GATE_OFF(AIU_AI_TOP_GLUE); __CLK_GATE_OFF(AIU_IEC958); __CLK_GATE_OFF(AIU_I2S_OUT); __CLK_GATE_OFF(AIU_AMCLK_MEASURE); __CLK_GATE_OFF(AIU_AIFIFO2); __CLK_GATE_OFF(AIU_AUD_MIXER); __CLK_GATE_OFF(AIU_MIXER_REG); __CLK_GATE_OFF(AIU_ADC); //__CLK_GATE_OFF(AIU_PCLK); __CLK_GATE_OFF(AIU_AOCLK); __CLK_GATE_OFF(AIU_ICE958_AMCLK); } break; case MOD_HDMI: PRINT_INFO("turn %s hdmi module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(HDMI_INTR_SYNC); __CLK_GATE_ON(HDMI_PCLK); __CLK_GATE_ON(VCLK1_HDMI); } else { __CLK_GATE_OFF(HDMI_INTR_SYNC); __CLK_GATE_OFF(HDMI_PCLK); __CLK_GATE_OFF(VCLK1_HDMI); } break; case MOD_VENC: PRINT_INFO("turn %s venc module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VCLK2_VENCI); __CLK_GATE_ON(VCLK2_VENCI1); __CLK_GATE_ON(VCLK2_VENCP); __CLK_GATE_ON(VCLK2_VENCP1); __CLK_GATE_ON(VCLK2_ENCI); __CLK_GATE_ON(VCLK2_ENCP); __CLK_GATE_ON(VCLK2_OTHER); __CLK_GATE_ON(VCLK2_OTHER1); __CLK_GATE_ON(ENC480P); __CLK_GATE_ON(VENC_DAC); __CLK_GATE_ON(DAC_CLK); } else { __CLK_GATE_OFF(VCLK2_VENCI); __CLK_GATE_OFF(VCLK2_VENCI1); __CLK_GATE_OFF(VCLK2_VENCP); __CLK_GATE_OFF(VCLK2_VENCP1); __CLK_GATE_OFF(VCLK2_ENCI); __CLK_GATE_OFF(VCLK2_ENCP); __CLK_GATE_OFF(VCLK2_OTHER); __CLK_GATE_OFF(VCLK2_OTHER1); __CLK_GATE_OFF(ENC480P); __CLK_GATE_OFF(VENC_DAC); __CLK_GATE_OFF(DAC_CLK); } break; case MOD_TCON: //PRINT_INFO("turn %s tcon module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VENCT_INT); __CLK_GATE_ON(VCLK2_ENCT); __CLK_GATE_ON(VCLK2_VENCT); __CLK_GATE_ON(VCLK2_VENCT1); } else { __CLK_GATE_OFF(VENCT_INT); __CLK_GATE_OFF(VCLK2_ENCT); __CLK_GATE_OFF(VCLK2_VENCT); __CLK_GATE_OFF(VCLK2_VENCT1); } break; case MOD_LVDS: PRINT_INFO("turn %s lcd module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VENCL_INT); __CLK_GATE_ON(VCLK2_ENCL); __CLK_GATE_ON(VCLK2_VENCL); } else { __CLK_GATE_OFF(VENCL_INT); __CLK_GATE_OFF(VCLK2_VENCL); __CLK_GATE_OFF(VCLK2_ENCL); } break; case MOD_SPI: PRINT_INFO("turn %s spi module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(SPICC); __CLK_GATE_ON(SPI1); __CLK_GATE_ON(SPI2); } else { __CLK_GATE_OFF(SPICC); __CLK_GATE_OFF(SPI1); __CLK_GATE_OFF(SPI2); } break; case MOD_UART0: PRINT_INFO("turn %s uart0 module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(UART0); } else { __CLK_GATE_OFF(UART0); } break; case MOD_UART1: PRINT_INFO("turn %s uart1 module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(UART1); } else { __CLK_GATE_OFF(UART1); } break; case MOD_UART2: PRINT_INFO("turn %s uart2 module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(UART2); } else { __CLK_GATE_OFF(UART2); } break; case MOD_ROM: PRINT_INFO("turn %s rom module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(ROM_CLK); } else { __CLK_GATE_OFF(ROM_CLK); } break; case MOD_EFUSE: PRINT_INFO("turn %s efuse module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(EFUSE); } else { __CLK_GATE_OFF(EFUSE); } break; case MOD_RANDOM_NUM_GEN: PRINT_INFO("turn %s random_num_gen module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(RANDOM_NUM_GEN); } else { __CLK_GATE_OFF(RANDOM_NUM_GEN); } break; case MOD_ETHERNET: PRINT_INFO("turn %s ethernet module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(ETHERNET); } else { __CLK_GATE_OFF(ETHERNET); } break; case MOD_MEDIA_CPU: PRINT_INFO("trun %s Audio DSP\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(MEDIA_CPU); }else{ __CLK_GATE_OFF(MEDIA_CPU); } break; case MOD_GE2D: PRINT_INFO("trun %s GE2D\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(GE2D); }else{ __CLK_GATE_OFF(GE2D); } break; case MOD_AHB: PRINT_INFO("trun %s ahb\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(AHB_ARB0); __CLK_GATE_ON(AHB_BRIDGE); __CLK_GATE_ON(AHB_DATA_BUS); __CLK_GATE_ON(AHB_CONTROL_BUS); __CLK_GATE_ON(AHB_BUS); __CLK_GATE_ON(AHB_SRAM); }else{ __CLK_GATE_OFF(AHB_ARB0); __CLK_GATE_OFF(AHB_BRIDGE); __CLK_GATE_OFF(AHB_DATA_BUS); __CLK_GATE_OFF(AHB_CONTROL_BUS); __CLK_GATE_OFF(AHB_BUS); __CLK_GATE_OFF(AHB_SRAM); } break; case MOD_DEMUX: PRINT_INFO("trun %s demux\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(DEMUX); }else{ __CLK_GATE_OFF(DEMUX); } break; case MOD_SMART_CARD: PRINT_INFO("trun %s smart card\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(SMART_CARD_MPEG_DOMAIN); }else{ __CLK_GATE_OFF(SMART_CARD_MPEG_DOMAIN); } break; case MOD_SDHC: PRINT_INFO("trun %s sdhc\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(SDHC); }else{ __CLK_GATE_OFF(SDHC); } break; case MOD_STREAM: PRINT_INFO("trun %s stream\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(STREAM); }else{ __CLK_GATE_OFF(STREAM); } break; case MOD_BLK_MOV: PRINT_INFO("trun %s blk_mov\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(BLK_MOV); }else{ __CLK_GATE_OFF(BLK_MOV); } break; case MOD_MISC_DVIN: PRINT_INFO("trun %s dvin\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(MISC_DVIN); }else{ __CLK_GATE_OFF(MISC_DVIN); } break; case MOD_MISC_RDMA: PRINT_INFO("trun %s rdma\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(MISC_RDMA); }else{ __CLK_GATE_OFF(MISC_RDMA); } break; case MOD_USB0: PRINT_INFO("trun %s rdma\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(USB0); __CLK_GATE_ON(MISC_USB0_TO_DDR); }else{ __CLK_GATE_OFF(USB0); __CLK_GATE_OFF(MISC_USB0_TO_DDR); } break; case MOD_USB1: PRINT_INFO("trun %s rdma\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(USB1); __CLK_GATE_ON(MISC_USB1_TO_DDR); }else{ __CLK_GATE_OFF(USB1); __CLK_GATE_ON(MISC_USB1_TO_DDR); } break; case MOD_SDIO: PRINT_INFO("trun %s rdma\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(SDIO); }else{ __CLK_GATE_OFF(SDIO); } break; case MOD_VI_CORE: PRINT_INFO("trun %s vi core\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(VI_CORE); }else{ __CLK_GATE_OFF(VI_CORE); } break; case MOD_LED_PWM: PRINT_INFO("trun %s led pwm\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(LED_PWM); }else{ __CLK_GATE_OFF(LED_PWM); } break; case MOD_VDAC: printk("trun %s vdac\n", flag? " on" : "off"); if(flag){ aml_write_reg32(P_VENC_VDAC_SETTING, 0x0); }else{ aml_write_reg32(P_VENC_VDAC_SETTING, 0xffffffff); } break; default: PRINT_INFO("mod type not support\n"); ret = -1; break; } return ret; }
static int _switch_gate(mod_type_t type, int flag) { int ret = 0; switch(type) { case MOD_VDEC: PRINT_INFO("turn %s vdec module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(DOS); } else { __CLK_GATE_OFF(DOS); } break; case MOD_AUDIO: PRINT_INFO("turn %s audio module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(AIU_AI_TOP_GLUE); __CLK_GATE_ON(AIU_IEC958); __CLK_GATE_ON(AIU_I2S_OUT); __CLK_GATE_ON(AIU_AMCLK_MEASURE); __CLK_GATE_ON(AIU_AIFIFO2); __CLK_GATE_ON(AIU_AUD_MIXER); __CLK_GATE_ON(AIU_MIXER_REG); __CLK_GATE_ON(AIU_ADC); __CLK_GATE_ON(AIU_TOP_LEVEL); __CLK_GATE_ON(AIU_PCLK); __CLK_GATE_ON(AIU_AOCLK); __CLK_GATE_ON(AIU_ICE958_AMCLK); __CLK_GATE_ON(AUD_IN); } else { __CLK_GATE_OFF(AIU_AI_TOP_GLUE); __CLK_GATE_OFF(AIU_IEC958); __CLK_GATE_OFF(AIU_I2S_OUT); __CLK_GATE_OFF(AIU_AMCLK_MEASURE); __CLK_GATE_OFF(AIU_AIFIFO2); __CLK_GATE_OFF(AIU_AUD_MIXER); __CLK_GATE_OFF(AIU_MIXER_REG); __CLK_GATE_OFF(AIU_ADC); __CLK_GATE_OFF(AIU_TOP_LEVEL); __CLK_GATE_OFF(AIU_PCLK); __CLK_GATE_OFF(AIU_AOCLK); __CLK_GATE_OFF(AIU_ICE958_AMCLK); __CLK_GATE_OFF(AUD_IN); } break; #if 0 case MOD_HDMI: PRINT_INFO("turn %s hdmi module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(HDMI_INTR_SYNC); __CLK_GATE_ON(HDMI_RX); __CLK_GATE_ON(HDMI_PCLK); } else { __CLK_GATE_OFF(HDMI_INTR_SYNC); __CLK_GATE_OFF(HDMI_RX); __CLK_GATE_OFF(HDMI_PCLK); } break; case MOD_VENC: PRINT_INFO("turn %s venc module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VCLK2_VENCI); __CLK_GATE_ON(VCLK2_VENCI1); __CLK_GATE_ON(VCLK2_VENCP); __CLK_GATE_ON(VCLK2_VENCP1); __CLK_GATE_ON(VCLK2_ENCI); __CLK_GATE_ON(VCLK2_ENCP); __CLK_GATE_ON(VCLK2_VENCT); __CLK_GATE_ON(VCLK2_VENCT1); __CLK_GATE_ON(VCLK2_OTHER); __CLK_GATE_ON(VCLK2_OTHER1); __CLK_GATE_ON(ENC480P); //__CLK_GATE_ON(VENC_DAC); __CLK_GATE_ON(DAC_CLK); } else { __CLK_GATE_OFF(VCLK2_VENCI); __CLK_GATE_OFF(VCLK2_VENCI1); __CLK_GATE_OFF(VCLK2_VENCP); #ifndef CONFIG_MACH_MESON6_G02_DONGLE __CLK_GATE_OFF(VCLK2_VENCP1); #endif __CLK_GATE_OFF(VCLK2_ENCI); #ifndef CONFIG_MACH_MESON6_G02_DONGLE __CLK_GATE_OFF(VCLK2_ENCP); #endif __CLK_GATE_OFF(VCLK2_VENCT); __CLK_GATE_OFF(VCLK2_VENCT1); __CLK_GATE_OFF(VCLK2_OTHER); __CLK_GATE_OFF(VCLK2_OTHER1); __CLK_GATE_OFF(ENC480P); __CLK_GATE_OFF(DAC_CLK); } break; case MOD_TCON: PRINT_INFO("turn %s tcon module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VCLK2_ENCT); } else { __CLK_GATE_OFF(VCLK2_ENCT); } break; case MOD_LCD: PRINT_INFO("turn %s lcd module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(VCLK2_ENCL); __CLK_GATE_ON(VCLK2_VENCL); __CLK_GATE_ON(EDP_CLK); } else { __CLK_GATE_OFF(EDP_CLK); __CLK_GATE_OFF(VCLK2_VENCL); __CLK_GATE_OFF(VCLK2_ENCL); } break; #endif case MOD_SPI: PRINT_INFO("turn %s spi module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(SPICC); __CLK_GATE_ON(SPI); } else { __CLK_GATE_OFF(SPICC); __CLK_GATE_OFF(SPI); } break; case MOD_UART0: PRINT_INFO("turn %s uart0 module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(UART0); } else { __CLK_GATE_OFF(UART0); } break; case MOD_UART1: PRINT_INFO("turn %s uart1 module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(UART1); } else { __CLK_GATE_OFF(UART1); } break; case MOD_UART2: PRINT_INFO("turn %s uart2 module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(UART2); } else { __CLK_GATE_OFF(UART2); } break; case MOD_UART3: PRINT_INFO("turn %s uart3 module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(UART3); } else { __CLK_GATE_OFF(UART3); } break; case MOD_ROM: PRINT_INFO("turn %s rom module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(ROM_CLK); } else { __CLK_GATE_OFF(ROM_CLK); } break; case MOD_EFUSE: PRINT_INFO("turn %s efuse module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(EFUSE); } else { __CLK_GATE_OFF(EFUSE); } break; case MOD_RANDOM_NUM_GEN: PRINT_INFO("turn %s random_num_gen module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(RANDOM_NUM_GEN); __CLK_GATE_ON(RANDOM_NUM_GEN1); } else { __CLK_GATE_OFF(RANDOM_NUM_GEN); __CLK_GATE_OFF(RANDOM_NUM_GEN1); } break; case MOD_ETHERNET: PRINT_INFO("turn %s ethernet module\n", flag?"on":"off"); if (flag) { __CLK_GATE_ON(ETHERNET); } else { __CLK_GATE_OFF(ETHERNET); } break; case MOD_MEDIA_CPU: PRINT_INFO("trun %s Audio DSP\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(MEDIA_CPU); }else{ __CLK_GATE_OFF(MEDIA_CPU); } break; case MOD_GE2D: PRINT_INFO("trun %s GE2D\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(GE2D); }else{ __CLK_GATE_OFF(GE2D); } break; case MOD_AHB: PRINT_INFO("trun %s ahb\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(AHB_ARB0); __CLK_GATE_ON(AHB_BRIDGE); __CLK_GATE_ON(AHB_DATA_BUS); __CLK_GATE_ON(AHB_CONTROL_BUS); }else{ __CLK_GATE_OFF(AHB_ARB0); __CLK_GATE_OFF(AHB_BRIDGE); __CLK_GATE_OFF(AHB_DATA_BUS); __CLK_GATE_OFF(AHB_CONTROL_BUS); } break; case MOD_DEMUX: PRINT_INFO("trun %s demux\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(DEMUX); }else{ __CLK_GATE_OFF(DEMUX); } break; case MOD_SMART_CARD: PRINT_INFO("trun %s smart card\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(SMART_CARD_MPEG_DOMAIN); }else{ __CLK_GATE_OFF(SMART_CARD_MPEG_DOMAIN); } break; case MOD_SDHC: PRINT_INFO("trun %s sdhc\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(SDHC); }else{ __CLK_GATE_OFF(SDHC); } break; case MOD_STREAM: PRINT_INFO("trun %s stream\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(STREAM); }else{ __CLK_GATE_OFF(STREAM); } break; case MOD_BLK_MOV: PRINT_INFO("trun %s blk_mov\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(BLK_MOV); }else{ __CLK_GATE_OFF(BLK_MOV); } break; case MOD_MISC_DVIN: PRINT_INFO("trun %s dvin\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(MISC_DVIN); }else{ __CLK_GATE_OFF(MISC_DVIN); } break; case MOD_USB0: PRINT_INFO("trun %s rdma\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(USB_GENERAL); __CLK_GATE_ON(USB0); __CLK_GATE_ON(MISC_USB0_TO_DDR); }else{ __CLK_GATE_OFF(USB0); __CLK_GATE_OFF(MISC_USB0_TO_DDR); __CLK_GATE_OFF(USB_GENERAL); } break; case MOD_USB1: PRINT_INFO("trun %s rdma\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(USB_GENERAL); __CLK_GATE_ON(USB1); __CLK_GATE_ON(MISC_USB1_TO_DDR); }else{ __CLK_GATE_OFF(USB1); __CLK_GATE_ON(MISC_USB1_TO_DDR); __CLK_GATE_OFF(USB_GENERAL); } break; case MOD_SDIO: PRINT_INFO("trun %s rdma\n", flag? " on" : "off"); if(flag){ __CLK_GATE_ON(SDIO); }else{ __CLK_GATE_OFF(SDIO); } break; default: PRINT_INFO("mod type not support\n"); ret = -1; break; } return ret; }