static void ke_gen_ind_msg(struct aee_oops *oops) { unsigned long flags = 0; xlog_printk(ANDROID_LOG_DEBUG, AEK_LOG_TAG, "%s oops %p\n", __func__, oops); if (oops == NULL) { return; } spin_lock_irqsave(&aed_device_lock, flags); if (aed_dev.kerec.lastlog == NULL) { aed_dev.kerec.lastlog = oops; } else { /* * waaa.. Two ke api at the same time * or ke api during aed process is still busy at ke * discard the new oops! */ xlog_printk(ANDROID_LOG_WARN, AEK_LOG_TAG, "%s: More than on kernel message queued\n", __func__); aee_oops_free(oops); spin_unlock_irqrestore(&aed_device_lock, flags); return; } spin_unlock_irqrestore(&aed_device_lock, flags); if (aed_dev.kerec.lastlog != NULL) { AE_Msg *rep_msg; rep_msg = msg_create(&aed_dev.kerec.msg, 0); if(rep_msg == NULL) return; rep_msg->cmdType = AE_IND; switch (oops->attr) { case AE_DEFECT_REMINDING: rep_msg->cmdId = AE_IND_REM_RAISED; break; case AE_DEFECT_WARNING: rep_msg->cmdId = AE_IND_WRN_RAISED; break; case AE_DEFECT_EXCEPTION: rep_msg->cmdId = AE_IND_EXP_RAISED; break; case AE_DEFECT_FATAL: rep_msg->cmdId = AE_IND_FATAL_RAISED; break; default: /* Huh... something wrong, just go to exception */ rep_msg->cmdId = AE_IND_EXP_RAISED; break; } rep_msg->arg = oops->clazz; rep_msg->len = 0; rep_msg->dbOption = oops->dump_option; wake_up(&aed_dev.kewait); } }
static void __exit charging_ic_exit(void) { xlog_printk(ANDROID_LOG_INFO, "Power/Charger", "LGE : Charging IC Driver Exit \n"); platform_driver_unregister(&charging_ic_driver); }
static int __init mtk_cooler_shutdown_init(void) { int err = 0; int i; for (i = MAX_NUM_INSTANCE_MTK_COOLER_SHUTDOWN; i-- > 0; ) { cl_shutdown_dev[i] = NULL; cl_shutdown_state[i] = 0; } mtk_cooler_shutdown_dprintk("init\n"); #if defined(MTK_COOLER_SHUTDOWN_SIGNAL) { struct proc_dir_entry *entry; #if 0 entry = create_proc_entry("driver/mtk_cl_sd_pid", S_IRUGO | S_IWUSR, NULL); if (NULL != entry) { entry->read_proc = _mtk_cl_sd_pid_read; entry->write_proc = _mtk_cl_sd_pid_write; } #endif entry = proc_create("driver/mtk_cl_sd_pid", S_IRUGO | S_IWUSR | S_IWGRP, NULL, &_cl_sd_pid_fops); if (!entry) { xlog_printk(ANDROID_LOG_DEBUG, "thermal/cooler/shutdown", "mtk_cooler_shutdown_init driver/mtk_cl_sd_pid creation failed\n"); } else { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) proc_set_user(entry, 0, 1000); #else entry->gid = 1000; #endif } } { struct proc_dir_entry *entry; #if 0 entry = create_proc_entry("driver/mtk_cl_sd_rst", S_IRUGO | S_IWUSR | S_IWGRP, NULL); if (NULL != entry) { entry->write_proc = _mtk_cl_sd_rst_write; entry->gid = 1000; } #endif entry = proc_create("driver/mtk_cl_sd_rst", S_IRUGO | S_IWUSR | S_IWGRP, NULL, &_cl_sd_rst_fops); if (!entry) { xlog_printk(ANDROID_LOG_DEBUG, "thermal/cooler/shutdown", "mtk_cooler_shutdown_init driver/mtk_cl_sd_rst creation failed\n"); } else { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) proc_set_user(entry, 0, 1000); #else entry->gid = 1000; #endif } } { struct proc_dir_entry *entry; entry = proc_create("driver/mtk_cl_sd_dbt", S_IRUGO | S_IWUSR | S_IWGRP, NULL, &_cl_sd_debouncet_fops); if (!entry) { xlog_printk(ANDROID_LOG_DEBUG, "thermal/cooler/shutdown", "mtk_cooler_shutdown_init driver/mtk_cl_sd_dbt creation failed\n"); } else { #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0) proc_set_user(entry, 0, 1000); #else entry->gid = 1000; #endif } } #endif err = mtk_cooler_shutdown_register_ltf(); if (err) goto err_unreg; return 0; err_unreg: mtk_cooler_shutdown_unregister_ltf(); return err; }
void charging_ic_set_factory_mode() { u32 wait; if(charging_ic_status == POWER_SUPPLY_TYPE_FACTORY) { xlog_printk(ANDROID_LOG_INFO, "Power/Charger", "[charger_rt9536] :: it's already %s mode!! : \n", __func__); return; } /* */ #if 0 if(charging_ic_status != POWER_SUPPLY_TYPE_BATTERY) { charging_ic_deactive(); } #endif /* */ /* */ #ifdef SINGLE_CHARGER_CONTOL_USING_GPT_TIMER mutex_lock(&charging_lock); wait = 0; while (wait < 10) { if (Set_Charging_Commmand(CHARGING_SET_FACTORY_MODE_COMMAND) == KAL_TRUE) { break; } wait++; mdelay(10); } charging_ic_status = POWER_SUPPLY_TYPE_FACTORY; mutex_unlock(&charging_lock); #else mutex_lock(&charging_lock); // #if defined(SINGLE_CHARGER_CONTROL_USING_SPIN_LOCK) charging_ic_set_chargingmode(CHR_FACTORY_MODE); #else mt_set_gpio_out(CHG_EN_SET_N, GPIO_OUT_ZERO); udelay(400); mt_set_gpio_out(CHG_EN_SET_N, GPIO_OUT_ONE); udelay(400); mt_set_gpio_out(CHG_EN_SET_N, GPIO_OUT_ZERO); udelay(400); mt_set_gpio_out(CHG_EN_SET_N, GPIO_OUT_ONE); udelay(400); mt_set_gpio_out(CHG_EN_SET_N, GPIO_OUT_ZERO); udelay(400); mt_set_gpio_out(CHG_EN_SET_N, GPIO_OUT_ONE); udelay(400); mt_set_gpio_out(CHG_EN_SET_N, GPIO_OUT_ZERO); udelay(1800); /* */ high_volt_setting(); /* */ #endif // charging_ic_status = POWER_SUPPLY_TYPE_FACTORY; mutex_unlock(&charging_lock); #endif /* */ xlog_printk(ANDROID_LOG_INFO, "Power/Charger", "[charger_rt9536] :: %s : \n", __func__); }
static int charging_ic_resume(struct platform_device *dev) { xlog_printk(ANDROID_LOG_INFO, "Power/Charger", "[charger_rt9536] :: charging_ic_resume \n"); dev->dev.power.power_state = PMSG_ON; return 0; }
static struct aee_oops *mtd_ipanic_oops_copy(void) { struct mtd_ipanic_data *ctx = &mtd_drv_ctx; struct aee_oops *oops; if ((ctx->curr.magic != AEE_IPANIC_MAGIC) || (ctx->curr.version != AEE_IPANIC_PHDR_VERSION)) { return NULL; } oops = aee_oops_create(AE_DEFECT_FATAL, AE_KE, IPANIC_MODULE_TAG); if (oops != NULL) { struct ipanic_oops_header *oops_header = kzalloc(sizeof(struct ipanic_oops_header), GFP_KERNEL); if (oops_header == NULL) goto error_return; if (mtd_ipanic_block_read(ctx, ctx->curr.oops_header_offset, ctx->curr.oops_header_length, oops_header) != 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd read header failed\n", __FUNCTION__); kfree(oops_header); goto error_return; } aee_oops_set_process_path(oops, oops_header->process_path); aee_oops_set_backtrace(oops, oops_header->backtrace); kfree(oops_header); if(ctx->curr.oops_detail_length != 0) { oops->detail = kmalloc(ctx->curr.oops_detail_length, GFP_KERNEL); oops->detail_len = ctx->curr.oops_detail_length; if (oops->detail != NULL) { if (mtd_ipanic_block_read(ctx, ctx->curr.oops_detail_offset, ctx->curr.oops_detail_length, oops->detail) != 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd read detail failed\n", __FUNCTION__); kfree(oops->detail); goto error_return; } } }else { #define TMPDETAILSTR "panic detail is empty" oops->detail = kstrdup(TMPDETAILSTR,GFP_KERNEL); oops->detail_len = sizeof TMPDETAILSTR; } if(oops->detail == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at detail\n", __FUNCTION__); kfree(oops); return NULL; } oops->console = kmalloc(ctx->curr.console_length, GFP_KERNEL); oops->console_len = ctx->curr.console_length; if (oops->console != NULL) { if (mtd_ipanic_block_read(ctx, ctx->curr.console_offset, ctx->curr.console_length, oops->console) != 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd read console failed\n", __FUNCTION__); kfree(oops->detail); goto error_return; } } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at detail\n", __FUNCTION__); kfree(oops); return NULL; } /* Android log */ oops->android_main = kmalloc(ctx->curr.android_main_length, GFP_KERNEL); oops->android_main_len = ctx->curr.android_main_length; if (oops->android_main) { if (mtd_ipanic_block_read(ctx, ctx->curr.android_main_offset, ctx->curr.android_main_length, oops->android_main) != 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd read android_main failed\n", __FUNCTION__); kfree(oops->detail); kfree(oops->console); goto error_return; } } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at android_main\n", __FUNCTION__); aee_oops_free(oops); return NULL; } oops->android_radio = kmalloc(ctx->curr.android_radio_length, GFP_KERNEL); oops->android_radio_len = ctx->curr.android_radio_length; if (oops->android_radio) { if (mtd_ipanic_block_read(ctx, ctx->curr.android_radio_offset, ctx->curr.android_radio_length, oops->android_radio) != 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd read android_radio failed\n", __FUNCTION__); kfree(oops->detail); kfree(oops->console); kfree(oops->android_main); goto error_return; } } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at android_radio\n", __FUNCTION__); aee_oops_free(oops); return NULL; } oops->android_system = kmalloc(ctx->curr.android_system_length, GFP_KERNEL); oops->android_system_len = ctx->curr.android_system_length; if (oops->android_system) { if (mtd_ipanic_block_read(ctx, ctx->curr.android_system_offset, ctx->curr.android_system_length, oops->android_system) != 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd read android_system failed\n", __FUNCTION__); kfree(oops->detail); kfree(oops->console); kfree(oops->android_main); kfree(oops->android_radio); goto error_return; } } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at android_system\n", __FUNCTION__); aee_oops_free(oops); return NULL; } #if 0 xlog_printk(ANDROID_LOG_INFO, IPANIC_LOG_TAG, "android log length, 0x%x, 0x%x, 0x%x, 0x%x\n", oops->android_main_len,oops->android_event_len,oops->android_radio_len,oops->android_system_len); #endif /* Process dump */ oops->userspace_info = kmalloc(ctx->curr.userspace_info_length, GFP_KERNEL); oops->userspace_info_len = ctx->curr.userspace_info_length; if (oops->userspace_info) { if (mtd_ipanic_block_read(ctx, ctx->curr.userspace_info_offset, ctx->curr.userspace_info_length, oops->userspace_info) != 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: mtd read usrespace info failed\n", __FUNCTION__); kfree(oops->detail); kfree(oops->console); kfree(oops->android_main); kfree(oops->android_radio); kfree(oops->userspace_info); goto error_return; } } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at userspace info failed\n", __FUNCTION__); aee_oops_free(oops); return NULL; } xlog_printk(ANDROID_LOG_DEBUG, IPANIC_LOG_TAG, "ipanic_oops_copy return OK\n"); return oops; } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at header\n", __FUNCTION__); return NULL; } error_return: kfree(oops); memset(&ctx->curr, 0, sizeof(struct ipanic_header)); mtd_ipanic_block_erase(); return NULL; }
static void __exit mtk_cpe_exit(void) { xlog_printk(ANDROID_LOG_INFO, "Power/CPE", "critical path emulator de-initialized\n"); }
static MTKLFB_ERROR MTKLFBInitFBDev(MTKLFB_DEVINFO *psDevInfo) { struct fb_info *psLINFBInfo; struct module *psLINFBOwner; MTKLFB_FBINFO *psPVRFBInfo = &psDevInfo->sFBInfo; MTKLFB_ERROR eError = MTKLFB_ERROR_GENERIC; unsigned long FBSize; unsigned long ulLCM; unsigned uiFBDevID = psDevInfo->uiFBDevID; MTKLFB_CONSOLE_LOCK(); psLINFBInfo = registered_fb[uiFBDevID]; if (psLINFBInfo == NULL) { eError = MTKLFB_ERROR_INVALID_DEVICE; goto ErrorRelSem; } #ifdef USE_RGBA_8888_FB { int res; struct fb_var_screeninfo info; info = psLINFBInfo->var; info.activate = FB_ACTIVATE_NOW; info.bits_per_pixel = 32; info.transp.offset = 24; info.transp.length = 8; info.red.offset = 0; info.red.length = 8; info.green.offset = 8; info.green.length = 8; info.blue.offset = 16; info.blue.length = 8; res = fb_set_var(psLINFBInfo, &info); if (res != 0) { xlog_printk(ANDROID_LOG_INFO, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: fb_set_var failed (Error: %d)\n", __FUNCTION__, uiFBDevID, res); eError = MTKLFB_ERROR_INIT_FAILURE; goto ErrorRelSem; } } #endif FBSize = (psLINFBInfo->screen_size) != 0 ? psLINFBInfo->screen_size : psLINFBInfo->fix.smem_len; if (FBSize == 0 || psLINFBInfo->fix.line_length == 0) { eError = MTKLFB_ERROR_INVALID_DEVICE; goto ErrorRelSem; } psLINFBOwner = psLINFBInfo->fbops->owner; if (!try_module_get(psLINFBOwner)) { xlog_printk(ANDROID_LOG_INFO, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Couldn't get framebuffer module\n", __FUNCTION__, uiFBDevID); goto ErrorRelSem; } if (psLINFBInfo->fbops->fb_open != NULL) { int res; res = psLINFBInfo->fbops->fb_open(psLINFBInfo, 0); if (res != 0) { xlog_printk(ANDROID_LOG_INFO, DRIVER_PREFIX, DRIVER_PREFIX " %s: Device %u: Couldn't open framebuffer(%d)\n", __FUNCTION__, uiFBDevID, res); goto ErrorModPut; } } psDevInfo->psLINFBInfo = psLINFBInfo; ulLCM = LCM(psLINFBInfo->fix.line_length, MTKLFB_PAGE_SIZE); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer physical address: 0x%lx\n", psDevInfo->uiFBDevID, psLINFBInfo->fix.smem_start)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer virtual address: 0x%lx\n", psDevInfo->uiFBDevID, (unsigned long)psLINFBInfo->screen_base)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer size: %lu\n", psDevInfo->uiFBDevID, FBSize)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer virtual width: %u\n", psDevInfo->uiFBDevID, psLINFBInfo->var.xres_virtual)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer virtual height: %u\n", psDevInfo->uiFBDevID, psLINFBInfo->var.yres_virtual)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer width: %u\n", psDevInfo->uiFBDevID, psLINFBInfo->var.xres)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer height: %u\n", psDevInfo->uiFBDevID, psLINFBInfo->var.yres)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Framebuffer stride: %u\n", psDevInfo->uiFBDevID, psLINFBInfo->fix.line_length)); DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: LCM of stride and page size: %lu\n", psDevInfo->uiFBDevID, ulLCM)); psPVRFBInfo->sSysAddr.uiAddr = psLINFBInfo->fix.smem_start; psPVRFBInfo->sCPUVAddr = psLINFBInfo->screen_base; psPVRFBInfo->ulWidth = psLINFBInfo->var.xres; psPVRFBInfo->ulHeight = psLINFBInfo->var.yres; psPVRFBInfo->ulByteStride = psLINFBInfo->fix.line_length; psPVRFBInfo->ulFBSize = FBSize; psPVRFBInfo->ulBufferSize = psPVRFBInfo->ulHeight * psPVRFBInfo->ulByteStride; psPVRFBInfo->ulRoundedBufferSize = RoundUpToMultiple(psPVRFBInfo->ulBufferSize, ulLCM); if(psLINFBInfo->var.bits_per_pixel == 16) { if((psLINFBInfo->var.red.length == 5) && (psLINFBInfo->var.green.length == 6) && (psLINFBInfo->var.blue.length == 5) && (psLINFBInfo->var.red.offset == 11) && (psLINFBInfo->var.green.offset == 5) && (psLINFBInfo->var.blue.offset == 0) && (psLINFBInfo->var.red.msb_right == 0)) { psPVRFBInfo->ePixelFormat = PVRSRV_PIXEL_FORMAT_RGB565; } else { xlog_printk(ANDROID_LOG_INFO, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Unknown FB format\n", __FUNCTION__, uiFBDevID); } } else if(psLINFBInfo->var.bits_per_pixel == 32) { if((psLINFBInfo->var.red.length == 8) && (psLINFBInfo->var.green.length == 8) && (psLINFBInfo->var.blue.length == 8) && (psLINFBInfo->var.red.offset == 16) && (psLINFBInfo->var.green.offset == 8) && (psLINFBInfo->var.blue.offset == 0) && (psLINFBInfo->var.red.msb_right == 0)) { psPVRFBInfo->ePixelFormat = PVRSRV_PIXEL_FORMAT_ARGB8888; } else if((psLINFBInfo->var.red.length == 8) && (psLINFBInfo->var.green.length == 8) && (psLINFBInfo->var.blue.length == 8) && (psLINFBInfo->var.red.offset == 0) && (psLINFBInfo->var.green.offset == 8) && (psLINFBInfo->var.blue.offset == 16) && (psLINFBInfo->var.red.msb_right == 0)) { // yu-fu: PVR2D does not support ABGR8888 ... psPVRFBInfo->ePixelFormat = PVRSRV_PIXEL_FORMAT_ARGB8888; } else { xlog_printk(ANDROID_LOG_INFO, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Unknown FB format\n", __FUNCTION__, uiFBDevID); } } else { xlog_printk(ANDROID_LOG_INFO, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Unknown FB format\n", __FUNCTION__, uiFBDevID); } psDevInfo->sFBInfo.ulPhysicalWidthmm = ((int)psLINFBInfo->var.width > 0) ? psLINFBInfo->var.width : 0; psDevInfo->sFBInfo.ulPhysicalHeightmm = ((int)psLINFBInfo->var.height > 0) ? psLINFBInfo->var.height : 0; psDevInfo->sFBInfo.sSysAddr.uiAddr = psPVRFBInfo->sSysAddr.uiAddr; psDevInfo->sFBInfo.sCPUVAddr = psPVRFBInfo->sCPUVAddr; eError = MTKLFB_OK; goto ErrorRelSem; ErrorModPut: module_put(psLINFBOwner); ErrorRelSem: MTKLFB_CONSOLE_UNLOCK(); return eError; }
static kal_uint32 charging_hw_init(void *data) { //static kal_uint32 run_hw_init_once_flag=1; kal_uint32 ncp1854_status; kal_uint32 status = STATUS_OK; if (Enable_BATDRV_LOG == 1) { xlog_printk(ANDROID_LOG_INFO, "Power/Battery", "[BATTERY:ncp1854] ChargerHwInit_ncp1854\n" ); } ncp1854_status = ncp1854_get_chip_status(); ncp1854_set_otg_en(0x0); ncp1854_set_trans_en(0); ncp1854_set_tj_warn_opt(0x0);//set at disabled, by MT6325 BATON // ncp1854_set_int_mask(0x0); //disable all interrupt ncp1854_set_int_mask(0x1); //enable all interrupt for boost mode status monitor // ncp1854_set_tchg_rst(0x1); //reset charge timer #ifdef NCP1854_PWR_PATH ncp1854_set_pwr_path(0x1); #else ncp1854_set_pwr_path(0x0); #endif ncp1854_set_chgto_dis(0x1); //disable charge timer if((ncp1854_status == 0x8) || (ncp1854_status == 0x9) || (ncp1854_status == 0xA)) //WEAK WAIT, WEAK SAFE, WEAK CHARGE ncp1854_set_ctrl_vbat(0x1C); //VCHG = 4.0V //if(run_hw_init_once_flag) //{ ncp1854_set_ieoc(0x4); // terminate current = 200mA for ICS optimized suspend power ncp1854_set_iweak(0x3); //weak charge current = 300mA // run_hw_init_once_flag=0; //} ncp1854_set_aicl_en(0x1); //enable AICL as PT team suggest ncp1854_set_iinset_pin_en(0x0); //Input current limit and AICL control by I2C ncp1854_set_ctrl_vfet(0x3); // VFET = 3.4V #if defined(MTK_WIRELESS_CHARGER_SUPPORT) if(wireless_charger_gpio_number!=0) { mt_set_gpio_mode(wireless_charger_gpio_number,0); // 0:GPIO mode mt_set_gpio_dir(wireless_charger_gpio_number,0); // 0: input, 1: output } #endif #ifdef CONFIG_MTK_DUAL_INPUT_CHARGER_SUPPORT mt_set_gpio_mode(vin_sel_gpio_number,0); // 0:GPIO mode mt_set_gpio_dir(vin_sel_gpio_number,0); // 0: input, 1: output #endif /*lenovo-sw weiweij added for charging terminate as 0.1c*/ #ifdef LENOVO_CHARGING_TERM lenovo_charging_term_set_iterm(); #endif /*lenovo-sw weiweij added for charging terminate as 0.1c end*/ return status; }
static MTKLFB_DEVINFO *MTKLFBInitDev(unsigned uiFBDevID) { PFN_CMD_PROC pfnCmdProcList[MTKLFB_COMMAND_COUNT]; IMG_UINT32 aui32SyncCountList[MTKLFB_COMMAND_COUNT][2]; MTKLFB_DEVINFO *psDevInfo = NULL; psDevInfo = (MTKLFB_DEVINFO *)MTKLFBAllocKernelMem(sizeof(MTKLFB_DEVINFO)); if(psDevInfo == NULL) { xlog_printk(ANDROID_LOG_ERROR, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Couldn't allocate device information structure\n", __FUNCTION__, uiFBDevID); goto ErrorExit; } memset(psDevInfo, 0, sizeof(MTKLFB_DEVINFO)); psDevInfo->uiFBDevID = uiFBDevID; if(!(*gpfnGetPVRJTable)(&psDevInfo->sPVRJTable)) { goto ErrorFreeDevInfo; } if(MTKLFBInitFBDev(psDevInfo) != MTKLFB_OK) { goto ErrorFreeDevInfo; } psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers = (IMG_UINT32)(psDevInfo->sFBInfo.ulFBSize / psDevInfo->sFBInfo.ulRoundedBufferSize); if (psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers != 0) { psDevInfo->sDisplayInfo.ui32MaxSwapChains = 1; psDevInfo->sDisplayInfo.ui32MaxSwapInterval = 1; } psDevInfo->sDisplayInfo.ui32PhysicalWidthmm = psDevInfo->sFBInfo.ulPhysicalWidthmm; psDevInfo->sDisplayInfo.ui32PhysicalHeightmm = psDevInfo->sFBInfo.ulPhysicalHeightmm; strncpy(psDevInfo->sDisplayInfo.szDisplayName, DISPLAY_DEVICE_NAME, MAX_DISPLAY_NAME_SIZE); psDevInfo->sDisplayFormat.pixelformat = psDevInfo->sFBInfo.ePixelFormat; psDevInfo->sDisplayDim.ui32Width = (IMG_UINT32)psDevInfo->sFBInfo.ulWidth; psDevInfo->sDisplayDim.ui32Height = (IMG_UINT32)psDevInfo->sFBInfo.ulHeight; psDevInfo->sDisplayDim.ui32ByteStride = (IMG_UINT32)psDevInfo->sFBInfo.ulByteStride; DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: Maximum number of swap chain buffers: %u\n", psDevInfo->uiFBDevID, psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers)); psDevInfo->sSystemBuffer.sSysAddr = psDevInfo->sFBInfo.sSysAddr; psDevInfo->sSystemBuffer.sCPUVAddr = psDevInfo->sFBInfo.sCPUVAddr; psDevInfo->sSystemBuffer.psDevInfo = psDevInfo; MTKLFBInitBufferForSwap(&psDevInfo->sSystemBuffer); psDevInfo->sDCJTable.ui32TableSize = sizeof(PVRSRV_DC_SRV2DISP_KMJTABLE); psDevInfo->sDCJTable.pfnOpenDCDevice = OpenDCDevice; psDevInfo->sDCJTable.pfnCloseDCDevice = CloseDCDevice; psDevInfo->sDCJTable.pfnEnumDCFormats = EnumDCFormats; psDevInfo->sDCJTable.pfnEnumDCDims = EnumDCDims; psDevInfo->sDCJTable.pfnGetDCSystemBuffer = GetDCSystemBuffer; psDevInfo->sDCJTable.pfnGetDCInfo = GetDCInfo; psDevInfo->sDCJTable.pfnGetBufferAddr = GetDCBufferAddr; psDevInfo->sDCJTable.pfnCreateDCSwapChain = CreateDCSwapChain; psDevInfo->sDCJTable.pfnDestroyDCSwapChain = DestroyDCSwapChain; psDevInfo->sDCJTable.pfnSetDCDstRect = SetDCDstRect; psDevInfo->sDCJTable.pfnSetDCSrcRect = SetDCSrcRect; psDevInfo->sDCJTable.pfnSetDCDstColourKey = SetDCDstColourKey; psDevInfo->sDCJTable.pfnSetDCSrcColourKey = SetDCSrcColourKey; psDevInfo->sDCJTable.pfnGetDCBuffers = GetDCBuffers; psDevInfo->sDCJTable.pfnSwapToDCBuffer = SwapToDCBuffer; psDevInfo->sDCJTable.pfnSetDCState = SetDCState; if(psDevInfo->sPVRJTable.pfnPVRSRVRegisterDCDevice( &psDevInfo->sDCJTable, &psDevInfo->uiPVRDevID) != PVRSRV_OK) { xlog_printk(ANDROID_LOG_ERROR, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: PVR Services device registration failed\n", __FUNCTION__, uiFBDevID); goto ErrorDeInitFBDev; } DEBUG_PRINTK((KERN_INFO DRIVER_PREFIX ": Device %u: PVR Device ID: %u\n", psDevInfo->uiFBDevID, psDevInfo->uiPVRDevID)); pfnCmdProcList[DC_FLIP_COMMAND] = ProcessFlip; aui32SyncCountList[DC_FLIP_COMMAND][0] = 0; aui32SyncCountList[DC_FLIP_COMMAND][1] = 10; if (psDevInfo->sPVRJTable.pfnPVRSRVRegisterCmdProcList(psDevInfo->uiPVRDevID, &pfnCmdProcList[0], aui32SyncCountList, MTKLFB_COMMAND_COUNT) != PVRSRV_OK) { xlog_printk(ANDROID_LOG_ERROR, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Couldn't register command processing functions with PVR Services\n", __FUNCTION__, uiFBDevID); goto ErrorUnregisterDevice; } MTKLFBCreateSwapChainLockInit(psDevInfo); MTKLFBAtomicBoolInit(&psDevInfo->sBlanked, MTKLFB_FALSE); MTKLFBAtomicIntInit(&psDevInfo->sBlankEvents, 0); MTKLFBAtomicBoolInit(&psDevInfo->sFlushCommands, MTKLFB_FALSE); #if defined(CONFIG_HAS_EARLYSUSPEND) MTKLFBAtomicBoolInit(&psDevInfo->sEarlySuspendFlag, MTKLFB_FALSE); #endif #if defined(SUPPORT_DRI_DRM) MTKLFBAtomicBoolInit(&psDevInfo->sLeaveVT, MTKLFB_FALSE); #endif return psDevInfo; ErrorUnregisterDevice: (void)psDevInfo->sPVRJTable.pfnPVRSRVRemoveDCDevice(psDevInfo->uiPVRDevID); ErrorDeInitFBDev: MTKLFBDeInitFBDev(psDevInfo); ErrorFreeDevInfo: MTKLFBFreeKernelMem(psDevInfo); ErrorExit: return NULL; }
static PVRSRV_ERROR CreateDCSwapChain(IMG_HANDLE hDevice, IMG_UINT32 ui32Flags, DISPLAY_SURF_ATTRIBUTES *psDstSurfAttrib, DISPLAY_SURF_ATTRIBUTES *psSrcSurfAttrib, IMG_UINT32 ui32BufferCount, PVRSRV_SYNC_DATA **ppsSyncData, IMG_UINT32 ui32OEMFlags, IMG_HANDLE *phSwapChain, IMG_UINT32 *pui32SwapChainID) { MTKLFB_DEVINFO *psDevInfo; MTKLFB_SWAPCHAIN *psSwapChain; MTKLFB_BUFFER *psBuffer; IMG_UINT32 i; PVRSRV_ERROR eError; IMG_UINT32 ui32BuffersToSkip; UNREFERENCED_PARAMETER(ui32OEMFlags); if(!hDevice || !psDstSurfAttrib || !psSrcSurfAttrib || !ppsSyncData || !phSwapChain) { return PVRSRV_ERROR_INVALID_PARAMS; } psDevInfo = (MTKLFB_DEVINFO*)hDevice; if (psDevInfo->sDisplayInfo.ui32MaxSwapChains == 0) { return PVRSRV_ERROR_NOT_SUPPORTED; } MTKLFBCreateSwapChainLock(psDevInfo); if(psDevInfo->psSwapChain != NULL) { eError = PVRSRV_ERROR_FLIP_CHAIN_EXISTS; goto ExitUnLock; } if(ui32BufferCount > psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers) { eError = PVRSRV_ERROR_TOOMANYBUFFERS; goto ExitUnLock; } if ((psDevInfo->sFBInfo.ulRoundedBufferSize * (unsigned long)ui32BufferCount) > psDevInfo->sFBInfo.ulFBSize) { eError = PVRSRV_ERROR_TOOMANYBUFFERS; goto ExitUnLock; } ui32BuffersToSkip = psDevInfo->sDisplayInfo.ui32MaxSwapChainBuffers - ui32BufferCount; if(psDstSurfAttrib->pixelformat != psDevInfo->sDisplayFormat.pixelformat || psDstSurfAttrib->sDims.ui32ByteStride != psDevInfo->sDisplayDim.ui32ByteStride || psDstSurfAttrib->sDims.ui32Width != psDevInfo->sDisplayDim.ui32Width || psDstSurfAttrib->sDims.ui32Height != psDevInfo->sDisplayDim.ui32Height) { eError = PVRSRV_ERROR_INVALID_PARAMS; goto ExitUnLock; } if(psDstSurfAttrib->pixelformat != psSrcSurfAttrib->pixelformat || psDstSurfAttrib->sDims.ui32ByteStride != psSrcSurfAttrib->sDims.ui32ByteStride || psDstSurfAttrib->sDims.ui32Width != psSrcSurfAttrib->sDims.ui32Width || psDstSurfAttrib->sDims.ui32Height != psSrcSurfAttrib->sDims.ui32Height) { eError = PVRSRV_ERROR_INVALID_PARAMS; goto ExitUnLock; } UNREFERENCED_PARAMETER(ui32Flags); #if defined(PVR_MTKFB3_UPDATE_MODE) if (!MTKLFBSetUpdateMode(psDevInfo, PVR_MTKFB3_UPDATE_MODE)) { xlog_printk(ANDROID_LOG_WARN, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Couldn't set frame buffer update mode %d\n", __FUNCTION__, psDevInfo->uiFBDevID, PVR_MTKFB3_UPDATE_MODE); } #endif psSwapChain = (MTKLFB_SWAPCHAIN*)MTKLFBAllocKernelMem(sizeof(MTKLFB_SWAPCHAIN)); if(!psSwapChain) { eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ExitUnLock; } psBuffer = (MTKLFB_BUFFER*)MTKLFBAllocKernelMem(sizeof(MTKLFB_BUFFER) * ui32BufferCount); if(!psBuffer) { eError = PVRSRV_ERROR_OUT_OF_MEMORY; goto ErrorFreeSwapChain; } psSwapChain->ulBufferCount = (unsigned long)ui32BufferCount; psSwapChain->psBuffer = psBuffer; psSwapChain->bNotVSynced = MTKLFB_TRUE; psSwapChain->uiFBDevID = psDevInfo->uiFBDevID; for(i=0; i<ui32BufferCount-1; i++) { psBuffer[i].psNext = &psBuffer[i+1]; } psBuffer[i].psNext = &psBuffer[0]; for (i = 0; i < ui32BufferCount; i++) { IMG_UINT32 ui32SwapBuffer = i + ui32BuffersToSkip; IMG_UINT32 ui32BufferOffset = ui32SwapBuffer * (IMG_UINT32)psDevInfo->sFBInfo.ulRoundedBufferSize; psBuffer[i].psSyncData = ppsSyncData[i]; psBuffer[i].sSysAddr.uiAddr = psDevInfo->sFBInfo.sSysAddr.uiAddr + ui32BufferOffset; psBuffer[i].sCPUVAddr = psDevInfo->sFBInfo.sCPUVAddr + ui32BufferOffset; psBuffer[i].ulYOffset = ui32BufferOffset / psDevInfo->sFBInfo.ulByteStride; psBuffer[i].psDevInfo = psDevInfo; MTKLFBInitBufferForSwap(&psBuffer[i]); } if (MTKLFBCreateSwapQueue(psSwapChain) != MTKLFB_OK) { xlog_printk(ANDROID_LOG_WARN, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Failed to create workqueue\n", __FUNCTION__, psDevInfo->uiFBDevID); eError = PVRSRV_ERROR_UNABLE_TO_INSTALL_ISR; goto ErrorFreeBuffers; } if (MTKLFBEnableLFBEventNotification(psDevInfo)!= MTKLFB_OK) { eError = PVRSRV_ERROR_UNABLE_TO_ENABLE_EVENT; xlog_printk(ANDROID_LOG_WARN, DRIVER_PREFIX, DRIVER_PREFIX ": %s: Device %u: Couldn't enable framebuffer event notification\n", __FUNCTION__, psDevInfo->uiFBDevID); goto ErrorDestroySwapQueue; } psDevInfo->uiSwapChainID++; if (psDevInfo->uiSwapChainID == 0) { psDevInfo->uiSwapChainID++; } psSwapChain->uiSwapChainID = psDevInfo->uiSwapChainID; psDevInfo->psSwapChain = psSwapChain; *pui32SwapChainID = psDevInfo->uiSwapChainID; *phSwapChain = (IMG_HANDLE)psSwapChain; eError = PVRSRV_OK; goto ExitUnLock; ErrorDestroySwapQueue: MTKLFBDestroySwapQueue(psSwapChain); ErrorFreeBuffers: MTKLFBFreeKernelMem(psBuffer); ErrorFreeSwapChain: MTKLFBFreeKernelMem(psSwapChain); ExitUnLock: MTKLFBCreateSwapChainUnLock(psDevInfo); return eError; }
static ssize_t aed_ke_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) { AE_Msg msg; int rsize; // recevied a new request means the previous response is unavilable // 1. set position to be zero // 2. destroy the previous response message *f_pos = 0; msg_destroy(&aed_dev.kerec.msg); // the request must be an *AE_Msg buffer if (count != sizeof(AE_Msg)) { xlog_printk(ANDROID_LOG_DEBUG, AEK_LOG_TAG, "ERR: aed_wirte count=%d\n", count); return -1; } rsize = copy_from_user(&msg, buf, count); if (rsize != 0) { xlog_printk(ANDROID_LOG_DEBUG, AEK_LOG_TAG, "copy_from_user rsize=%d\n", rsize); return -1; } msg_show(__func__, &msg); if (msg.cmdType == AE_REQ) { if (!ke_log_avail()) { ke_gen_notavail_msg(); return count; } switch(msg.cmdId) { case AE_REQ_CLASS: ke_gen_class_msg(); break; case AE_REQ_TYPE: ke_gen_type_msg(); break; case AE_REQ_MODULE: ke_gen_module_msg(); break; case AE_REQ_DETAIL: ke_gen_detail_msg(&msg); break; case AE_REQ_PROCESS: ke_gen_process_msg(); break; case AE_REQ_BACKTRACE: ke_gen_backtrace_msg(); break; default: ke_gen_notavail_msg(); break; } } else if (msg.cmdType == AE_IND) { switch(msg.cmdId) { case AE_IND_LOG_CLOSE: ke_destroy_log(); break; default: // IGNORE break; } } else if (msg.cmdType == AE_RSP) { // IGNORE } return count; }
static int aed_ke_release(struct inode *inode, struct file *filp) { xlog_printk(ANDROID_LOG_DEBUG, AEK_LOG_TAG, "%s:%d:%d\n", __func__, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); return 0; }
/****************************************************************************** * AED EE File operations *****************************************************************************/ static int aed_ee_open(struct inode *inode, struct file *filp) { ee_destroy_log(); //Destroy last log record xlog_printk(ANDROID_LOG_DEBUG, AEK_LOG_TAG, "%s:%d:%d\n", __func__, MAJOR(inode->i_rdev), MINOR(inode->i_rdev)); return 0; }
void AudDrv_Suspend_Clk_On(void) { unsigned long flags; spin_lock_irqsave(&auddrv_Clk_lock, flags); if (Aud_Core_Clk_cntr > 0) { #ifdef PM_MANAGER_API if (Aud_AFE_Clk_cntr > 0) { if (enable_clock(MT_CG_AUDIO_AFE, "AUDIO")) { xlog_printk(ANDROID_LOG_ERROR, "Sound", "Aud enable_clock MT_CG_AUDIO_AFE fail !!!\n"); } } if (Aud_I2S_Clk_cntr > 0) { if (enable_clock(MT_CG_AUDIO_I2S, "AUDIO")) { PRINTK_AUD_ERROR("enable_clock MT_CG_AUDIO_I2S fail"); } } if (Aud_ADC_Clk_cntr > 0) { Afe_Set_Reg(AUDIO_TOP_CON0, 0 << 24 , 1 << 24); } if (Aud_ADC2_Clk_cntr > 0) { #if 0 //K2 removed if (enable_clock(MT_CG_AUDIO_ADDA2, "AUDIO")) { PRINTK_AUD_CLK("%s fail", __func__); } #endif } if (Aud_ADC3_Clk_cntr > 0) { #if 0 //K2 removed if (enable_clock(MT_CG_AUDIO_ADDA3, "AUDIO")) { PRINTK_AUD_CLK("%s fail", __func__); } #endif } if (Aud_ANA_Clk_cntr > 0) { } if (Aud_HDMI_Clk_cntr > 0) { } if (Aud_APLL22M_Clk_cntr > 0) { enable_mux(MT_MUX_AUD1, "AUDIO"); clkmux_sel(MT_MUX_AUD1, 1 , "AUDIO"); //select APLL1 if (enable_clock(MT_CG_AUDIO_22M, "AUDIO")) { PRINTK_AUD_CLK("%s fail", __func__); } if (enable_clock(MT_CG_AUDIO_APLL_TUNER, "AUDIO")) { PRINTK_AUD_CLK("%s fail", __func__); } } if (Aud_APLL24M_Clk_cntr > 0) { enable_mux(MT_MUX_AUD2, "AUDIO"); clkmux_sel(MT_MUX_AUD2, 1, "AUDIO"); //APLL2 if (enable_clock(MT_CG_AUDIO_24M, "AUDIO")) { PRINTK_AUD_CLK("%s fail", __func__); } if (enable_clock(MT_CG_AUDIO_APLL2_TUNER, "AUDIO")) { PRINTK_AUD_CLK("%s fail", __func__); } } #endif } spin_unlock_irqrestore(&auddrv_Clk_lock, flags); }
int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) { struct address_space *mapping = file->f_mapping; int err, ret; #ifdef FEATURE_PRINT_FSYNC_PID pid_t curr_pid; unsigned int i; unsigned long long time1=0; bool ptr_flag=false; #endif if (!file->f_op || !file->f_op->fsync) { ret = -EINVAL; goto out; } ret = filemap_write_and_wait_range(mapping, start, end); /* * We need to protect against concurrent writers, which could cause * livelocks in fsync_buffers_list(). */ mutex_lock(&mapping->host->i_mutex); #ifdef FEATURE_PRINT_FSYNC_PID time1 = sched_clock(); mutex_lock(&fsync_mutex); if(fsync_last_t == 0) { fsync_last_t = time1; } if (time1 - fsync_last_t >= (unsigned long long)PRT_TIME_PERIOD) { sprintf(xlog_buf, "Fsync [(PID):cnt] -- "); for(i=0;i<ID_CNT;i++) { if(fsync[i].pid==0) break; else { sprintf(xlog_buf+21+i*9, "(%4d):%d ", fsync[i].pid, fsync[i].cnt); //21=strlen("Fsync [(PID):cnt] -- "), 9=strlen("(%4d):%d ") ptr_flag = true; } } if(ptr_flag) { xlog_printk(ANDROID_LOG_INFO, "BLOCK_TAG", "Fsync statistic in timeline %lld\n", fsync_last_t); xlog_printk(ANDROID_LOG_INFO, "BLOCK_TAG", "%s", xlog_buf); } for (i=0;i<ID_CNT;i++) //clear { fsync[i].pid=0; fsync[i].cnt=0; } fsync_last_t = time1; } curr_pid = task_pid_nr(current); do{ if(fsync[0].pid ==0) { fsync[0].pid= curr_pid; fsync[0].cnt ++; break; } if(curr_pid == fsync[idx].pid) { fsync[idx].cnt++; break; } for(i=0;i<ID_CNT;i++) { if (curr_pid == fsync[i].pid) //found in the array { fsync[i].cnt++; idx =i; break; } else if (fsync[i+1].pid== 0) //find the empty space { if(i+1==ID_CNT) //check buf full, record in the last element { i -= 1; fsync[i+1].cnt =0; } fsync[i+1].pid = curr_pid; fsync[i+1].cnt++; idx=i+1; break; } } }while(0); mutex_unlock(&fsync_mutex); #endif err = file->f_op->fsync(file, datasync); if (!ret) ret = err; mutex_unlock(&mapping->host->i_mutex); out: return ret; }
static void mtd_ipanic_block_erase(void) { struct mtd_ipanic_data *ctx = &mtd_drv_ctx; struct erase_info erase; DECLARE_WAITQUEUE(wait, current); wait_queue_head_t wait_q; int rc, i; init_waitqueue_head(&wait_q); erase.mtd = ctx->mtd; erase.callback = mtd_ipanic_block_erase_callback; erase.len = ctx->mtd->erasesize; erase.priv = (u_long)&wait_q; for (i = 0; i < ctx->mtd->size; i += ctx->mtd->erasesize) { erase.addr = i; set_current_state(TASK_INTERRUPTIBLE); add_wait_queue(&wait_q, &wait); rc = ctx->mtd->_block_isbad(ctx->mtd, erase.addr); if (rc < 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "aee-ipanic: Bad block check " "failed (%d)\n", rc); goto out; } if (rc) { xlog_printk(ANDROID_LOG_WARN, IPANIC_LOG_TAG, "aee-ipanic: Skipping erase of bad " "block @%llx\n", erase.addr); set_current_state(TASK_RUNNING); remove_wait_queue(&wait_q, &wait); continue; } rc = ctx->mtd->_erase(ctx->mtd, &erase); if (rc) { set_current_state(TASK_RUNNING); remove_wait_queue(&wait_q, &wait); xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "aee-ipanic: Erase of 0x%llx, 0x%llx failed\n", (unsigned long long) erase.addr, (unsigned long long) erase.len); if (rc == -EIO) { if (ctx->mtd->_block_markbad(ctx->mtd, erase.addr)) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "aee-ipanic: Err marking blk bad\n"); goto out; } xlog_printk(ANDROID_LOG_INFO, IPANIC_LOG_TAG, "aee-ipanic: Marked a bad block" " @%llx\n", erase.addr); continue; } goto out; } schedule(); remove_wait_queue(&wait_q, &wait); } xlog_printk(ANDROID_LOG_DEBUG, IPANIC_LOG_TAG, "aee-ipanic: %s partition erased\n", AEE_IPANIC_PLABEL); out: return; }
/** * vfs_fsync_range - helper to sync a range of data & metadata to disk * @file: file to sync * @start: offset in bytes of the beginning of data range to sync * @end: offset in bytes of the end of data range (inclusive) * @datasync: perform only datasync * * Write back data in range @start..@end and metadata for @file to disk. If * @datasync is set only metadata needed to access modified file data is * written. */ int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync) { #ifdef FEATURE_PRINT_FSYNC_PID pid_t curr_pid; unsigned int i; unsigned long long time1=0; bool ptr_flag=false; #endif #ifdef CONFIG_DYNAMIC_FSYNC if (likely(dyn_fsync_active && !early_suspend_active)) return 0; else { #endif if (!file->f_op || !file->f_op->fsync) return -EINVAL; #ifdef FEATURE_PRINT_FSYNC_PID time1 = sched_clock(); mutex_lock(&fsync_mutex); if(fsync_last_t == 0) { fsync_last_t = time1; } if (time1 - fsync_last_t >= (unsigned long long)SYNC_PRT_TIME_PERIOD) { sprintf(xlog_buf, "Fsync [(PID):cnt] -- "); for(i=0;i<ID_CNT;i++) { if(fsync[i].pid==0) break; else { sprintf(xlog_buf+21+i*9, "(%4d):%d ", fsync[i].pid, fsync[i].cnt); //21=strlen("Fsync [(PID):cnt] -- "), 9=strlen("(%4d):%d ") ptr_flag = true; } } if(ptr_flag) { xlog_printk(ANDROID_LOG_DEBUG, "BLOCK_TAG", "Fsync statistic in timeline %lld\n", fsync_last_t); xlog_printk(ANDROID_LOG_DEBUG, "BLOCK_TAG", "%s\n", xlog_buf); } for (i=0;i<ID_CNT;i++) //clear { fsync[i].pid=0; fsync[i].cnt=0; } fsync_last_t = time1; } curr_pid = task_pid_nr(current); do{ if(fsync[0].pid ==0) { fsync[0].pid= curr_pid; fsync[0].cnt ++; f_idx=0; break; } if(curr_pid == fsync[f_idx].pid) { fsync[f_idx].cnt++; break; } for(i=0;i<ID_CNT;i++) { if(curr_pid == fsync[i].pid) //found { fsync[i].cnt++; f_idx = i; break; } if((fsync[i].pid ==0) || (i==ID_CNT-1) ) //found empty space or (full and NOT found) { fsync[i].pid = curr_pid; fsync[i].cnt=1; f_idx=i; break; } } }while(0); mutex_unlock(&fsync_mutex); #endif return file->f_op->fsync(file, start, end, datasync); #ifdef CONFIG_DYNAMIC_FSYNC } #endif }
/*----------------------------------------------------------------------------*/ VOID dumpMemory8 ( IN UINT_32 log_level, IN PUINT_8 pucStartAddr, IN UINT_32 u4Length ) { ASSERT(pucStartAddr); if (log_level == ANDROID_LOG_ERROR) { xlog_printk(ANDROID_LOG_ERROR, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length); } else if (log_level == ANDROID_LOG_WARN) { xlog_printk(ANDROID_LOG_WARN, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length); } else if (log_level == ANDROID_LOG_INFO) { xlog_printk(ANDROID_LOG_INFO, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length); } else if (log_level == ANDROID_LOG_DEBUG) { xlog_printk(ANDROID_LOG_DEBUG, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length); } else if (log_level == ANDROID_LOG_VERBOSE) { xlog_printk(ANDROID_LOG_VERBOSE, XLOG_TAG, "DUMP8 ADDRESS: %08lx, Length: %ld\n", (UINT_32)pucStartAddr, u4Length); } while (u4Length > 0) { if (u4Length >= 16) { XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11], pucStartAddr[12], pucStartAddr[13], pucStartAddr[14], pucStartAddr[15]); u4Length -= 16; pucStartAddr += 16; } else { switch (u4Length) { case 1: XLOG_FUNC(log_level, "%02x\n", pucStartAddr[ 0]); break; case 2: XLOG_FUNC(log_level, "%02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1]); break; case 3: XLOG_FUNC(log_level, "%02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2]); break; case 4: XLOG_FUNC(log_level, "%02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3]); break; case 5: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4]); break; case 6: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5]); break; case 7: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6]); break; case 8: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7]); break; case 9: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8]); break; case 10: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8], pucStartAddr[ 9]); break; case 11: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10]); break; case 12: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11]); break; case 13: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11], pucStartAddr[12]); break; case 14: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11], pucStartAddr[12], pucStartAddr[13]); break; case 15: XLOG_FUNC(log_level, "%02x %02x %02x %02x %02x %02x %02x %02x - %02x %02x %02x %02x %02x %02x %02x\n", pucStartAddr[ 0], pucStartAddr[ 1], pucStartAddr[ 2], pucStartAddr[ 3], pucStartAddr[ 4], pucStartAddr[ 5], pucStartAddr[ 6], pucStartAddr[ 7], pucStartAddr[ 8], pucStartAddr[ 9], pucStartAddr[10], pucStartAddr[11], pucStartAddr[12], pucStartAddr[13], pucStartAddr[14]); break; default: break; } u4Length = 0; } } return; } /* end of dumpMemory8() */
static void fs_sync_mmcblk0_log(void) { pid_t curr_pid; unsigned int i; unsigned long long time1=0; bool ptr_flag=false; time1 = sched_clock(); mutex_lock(&fs_sync_mutex); if(fs_sync_last_t == 0) { fs_sync_last_t = time1; } if (time1 - fs_sync_last_t >= (unsigned long long)SYNC_PRT_TIME_PERIOD) { sprintf(xlog_buf2, "MMCBLK0_FS_Sync [(PID):cnt] -- "); for(i=0;i<ID_CNT;i++) { if(fs_sync[i].pid==0) break; else { sprintf(xlog_buf2+31+i*9, "(%4d):%d ", fs_sync[i].pid, fs_sync[i].cnt); //31=strlen("MMCBLK1_FS_Sync [(PID):cnt] -- "), 9=strlen("(%4d):%d ") ptr_flag = true; } } if(ptr_flag) { xlog_printk(ANDROID_LOG_DEBUG, "BLOCK_TAG", "MMCBLK0_FS_Sync statistic in timeline %lld\n", fs_sync_last_t); xlog_printk(ANDROID_LOG_DEBUG, "BLOCK_TAG", "%s\n", xlog_buf2); } for (i=0;i<ID_CNT;i++) //clear { fs_sync[i].pid=0; fs_sync[i].cnt=0; } fs_sync_last_t = time1; } curr_pid = task_pid_nr(current); do{ if(fs_sync[0].pid ==0) { fs_sync[0].pid= curr_pid; fs_sync[0].cnt ++; fs_idx=0; break; } if(curr_pid == fs_sync[fs_idx].pid) { fs_sync[fs_idx].cnt++; break; } for(i=0;i<ID_CNT;i++) { if(curr_pid == fs_sync[i].pid) //found { fs_sync[i].cnt++; fs_idx = i; break; } if((fs_sync[i].pid ==0) || (i==ID_CNT-1) ) //found empty space or (full and NOT found) { fs_sync[i].pid = curr_pid; fs_sync[i].cnt=1; fs_idx=i; break; } } }while(0); mutex_unlock(&fs_sync_mutex); }
/* Find an unused file structure and return a pointer to it. * Returns NULL, if there are no more free file structures or * we run out of memory. * * Be very careful using this. You are responsible for * getting write access to any mount that you might assign * to this filp, if it is opened for write. If this is not * done, you will imbalance int the mount's writer count * and a warning at __fput() time. */ struct file *get_empty_filp(void) { const struct cred *cred = current_cred(); static long old_max; struct file * f; /* * Privileged users can go above max_files */ if (get_nr_files() >= files_stat.max_files && !capable(CAP_SYS_ADMIN)) { /* * percpu_counters are inaccurate. Do an expensive check before * we go and fail. */ if (percpu_counter_sum_positive(&nr_files) >= files_stat.max_files) goto over; } f = kmem_cache_zalloc(filp_cachep, GFP_KERNEL); if (f == NULL) goto fail; percpu_counter_inc(&nr_files); f->f_cred = get_cred(cred); if (security_file_alloc(f)) goto fail_sec; INIT_LIST_HEAD(&f->f_u.fu_list); atomic_long_set(&f->f_count, 1); rwlock_init(&f->f_owner.lock); spin_lock_init(&f->f_lock); eventpoll_init_file(f); /* f->f_version: 0 */ return f; over: /* Ran out of filps - report that */ if (get_nr_files() > old_max) { #ifdef FILE_OVER_MAX static int fd_dump_all_files = 0; if(!fd_dump_all_files) { struct task_struct *p; xlog_printk(ANDROID_LOG_INFO, FS_TAG, "(PID:%d)files %d over old_max:%d", current->pid, get_nr_files(), old_max); for_each_process(p) { pid_t pid = p->pid; struct files_struct *files = p->files; struct fdtable *fdt = files_fdtable(files); #ifdef FD_OVER_CHECK if(files && fdt) { fd_show_open_files(pid, files, fdt); } #endif } fd_dump_all_files = 0x1; } #endif pr_info("VFS: file-max limit %lu reached\n", get_max_files()); old_max = get_nr_files(); } goto fail; fail_sec: file_free(f); fail: return NULL; }
/* * gs_start_tx * * This function finds available write requests, calls * gs_send_packet to fill these packets with data, and * continues until either there are no more write requests * available or no more data to send. This function is * run whenever data arrives or write requests are available. * * Context: caller owns port_lock; port_usb is non-null. */ static int gs_start_tx(struct gs_port *port) /* __releases(&port->port_lock) __acquires(&port->port_lock) */ { struct list_head *pool = &port->write_pool; //struct usb_ep *in = port->port_usb->in; struct usb_ep *in; int status = 0; bool do_tty_wake = false; static unsigned int skip = 0; static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 10); if (!port->port_usb) /* abort immediately after disconnect */ return -EINVAL; in = port->port_usb->in; while (!list_empty(pool)) { struct usb_request *req; int len; if (port->write_started >= QUEUE_SIZE) break; req = list_entry(pool->next, struct usb_request, list); len = gs_send_packet(port, req->buf, in->maxpacket); if (len == 0) { wake_up_interruptible(&port->drain_wait); break; } do_tty_wake = true; req->length = len; list_del(&req->list); req->zero = (gs_buf_data_avail(&port->port_write_buf) == 0); pr_vdebug(PREFIX "%d: tx len=%d, 0x%02x 0x%02x 0x%02x ...\n", port->port_num, len, *((u8 *)req->buf), *((u8 *)req->buf+1), *((u8 *)req->buf+2)); if (__ratelimit(&ratelimit)) { xlog_printk(ANDROID_LOG_VERBOSE, ACM_LOG, \ "%s: ttyGS%d: tx len=%d, 0x%02x 0x%02x 0x%02x ...\n", \ __func__, port->port_num, len, *((u8 *)req->buf), \ *((u8 *)req->buf+1), *((u8 *)req->buf+2)); if (skip > 0) { xlog_printk(ANDROID_LOG_VERBOSE, ACM_LOG, "%s Too many data, skipped %d bytes", __func__, skip); skip = 0; } } else skip += req->actual; USB_LOGGER(GS_START_TX, GS_START_TX, port->port_num, len); #ifdef ENABLE_USB_LOGGER #define OUTPUT_BTYE_NUM 5 { int i,j = 0; char* prefix[] = {"p1","p2","p3","p4","p5"}; char* suffix[] = {"s1","s2","s3","s4","s5"}; for (i = 0; i < req->actual && i < OUTPUT_BTYE_NUM; i++) USB_LOGGER(HEX_NUM, GS_START_TX, prefix[i], *((u8 *)req->buf+i)); if (req->actual >= OUTPUT_BTYE_NUM*2) { for(i = req->actual-1, j = 1; i >= (req->actual - OUTPUT_BTYE_NUM) \ && i >= OUTPUT_BTYE_NUM; i--,j++) { USB_LOGGER(HEX_NUM, GS_START_TX, suffix[OUTPUT_BTYE_NUM-j], \ *((u8 *)req->buf+i)); } } } #endif /* Drop lock while we call out of driver; completions * could be issued while we do so. Disconnection may * happen too; maybe immediately before we queue this! * * NOTE that we may keep sending data for a while after * the TTY closed (dev->ioport->port_tty is NULL). */ spin_unlock(&port->port_lock); status = usb_ep_queue(in, req, GFP_ATOMIC); spin_lock(&port->port_lock); if (status) { pr_debug("%s: %s %s err %d\n", __func__, "queue", in->name, status); list_add(&req->list, pool); break; } port->write_started++; /* abort immediately after disconnect */ if (!port->port_usb) break; } if (do_tty_wake && port->port_tty) tty_wakeup(port->port_tty); return status; }
static int charging_ic_suspend(struct platform_device *dev, pm_message_t state) { xlog_printk(ANDROID_LOG_INFO, "Power/Charger", "[charger_rt9536] :: charging_ic_suspend \n"); dev->dev.power.power_state = state; return 0; }
/* * RX tasklet takes data out of the RX queue and hands it up to the TTY * layer until it refuses to take any more data (or is throttled back). * Then it issues reads for any further data. * * If the RX queue becomes full enough that no usb_request is queued, * the OUT endpoint may begin NAKing as soon as its FIFO fills up. * So QUEUE_SIZE packets plus however many the FIFO holds (usually two) * can be buffered before the TTY layer's buffers (currently 64 KB). */ static void gs_rx_push(unsigned long _port) { struct gs_port *port = (void *)_port; struct tty_struct *tty; struct list_head *queue = &port->read_queue; bool disconnect = false; bool do_push = false; static unsigned int skip = 0; static DEFINE_RATELIMIT_STATE(ratelimit, 1 * HZ, 10); /* hand any queued data to the tty */ spin_lock_irq(&port->port_lock); tty = port->port_tty; while (!list_empty(queue)) { struct usb_request *req; req = list_first_entry(queue, struct usb_request, list); /* discard data if tty was closed */ if (!tty) goto recycle; /* leave data queued if tty was rx throttled */ if (test_bit(TTY_THROTTLED, &tty->flags)) break; switch (req->status) { case -ESHUTDOWN: disconnect = true; pr_vdebug(PREFIX "%d: shutdown\n", port->port_num); break; default: /* presumably a transient fault */ pr_warning(PREFIX "%d: unexpected RX status %d\n", port->port_num, req->status); /* FALLTHROUGH */ case 0: /* normal completion */ break; } USB_LOGGER(GS_RX_PUSH, GS_RX_PUSH, port->port_num, req->actual, port->n_read); if (__ratelimit(&ratelimit)) { xlog_printk(ANDROID_LOG_INFO, ACM_LOG, \ "%s: ttyGS%d: actual=%d, n_read=%d 0x%02x 0x%02x 0x%02x ...\n", \ __func__, port->port_num, req->actual, port->n_read, *((u8 *)req->buf), *((u8 *)req->buf+1), *((u8 *)req->buf+2)); if (skip > 0) { xlog_printk(ANDROID_LOG_VERBOSE, ACM_LOG, "%s Too many data, skipped %d bytes", __func__, skip); skip = 0; } } else skip += req->actual; #ifdef ENABLE_USB_LOGGER #define OUTPUT_BTYE_NUM 5 { int i,j = 0; char* prefix[] = {"p1","p2","p3","p4","p5"}; char* suffix[] = {"s1","s2","s3","s4","s5"}; for (i = 0; i < req->actual && i < OUTPUT_BTYE_NUM; i++) USB_LOGGER(HEX_NUM, GS_RX_PUSH, prefix[i], *((u8 *)req->buf+i)); if (req->actual >= OUTPUT_BTYE_NUM*2) { for(i = req->actual-1, j = 1; i >= (req->actual - OUTPUT_BTYE_NUM) \ && i >= OUTPUT_BTYE_NUM; i--,j++) { USB_LOGGER(HEX_NUM, GS_RX_PUSH, suffix[OUTPUT_BTYE_NUM-j], \ *((u8 *)req->buf+i)); } } } #endif /* push data to (open) tty */ if (req->actual) { char *packet = req->buf; unsigned size = req->actual; unsigned n; int count; /* we may have pushed part of this packet already... */ n = port->n_read; if (n) { packet += n; size -= n; } count = tty_insert_flip_string(tty, packet, size); if (count) do_push = true; if (count != size) { /* stop pushing; TTY layer can't handle more */ port->n_read += count; pr_vdebug(PREFIX "%d: rx block %d/%d\n", port->port_num, count, req->actual); break; } port->n_read = 0; } recycle: list_move(&req->list, &port->read_pool); port->read_started--; } /* Push from tty to ldisc; without low_latency set this is handled by * a workqueue, so we won't get callbacks and can hold port_lock */ if (tty && do_push) tty_flip_buffer_push(tty); /* We want our data queue to become empty ASAP, keeping data * in the tty and ldisc (not here). If we couldn't push any * this time around, there may be trouble unless there's an * implicit tty_unthrottle() call on its way... * * REVISIT we should probably add a timer to keep the tasklet * from starving ... but it's not clear that case ever happens. */ if (!list_empty(queue) && tty) { if (!test_bit(TTY_THROTTLED, &tty->flags)) { if (do_push) tasklet_schedule(&port->push); else pr_warning(PREFIX "%d: RX not scheduled?\n", port->port_num); } } /* If we're still connected, refill the USB RX queue. */ if (!disconnect && port->port_usb) gs_start_rx(port); spin_unlock_irq(&port->port_lock); }
static int __init charging_ic_init(void) { xlog_printk(ANDROID_LOG_INFO, "Power/Charger", "LGE : Charging IC Driver Init \n"); return platform_driver_register(&charging_ic_driver); }
/* * gs_open sets up the link between a gs_port and its associated TTY. * That link is broken *only* by TTY close(), and all driver methods * know that. */ static int gs_open(struct tty_struct *tty, struct file *file) { int port_num = tty->index; struct gs_port *port; int status; do { mutex_lock(&ports[port_num].lock); port = ports[port_num].port; if (!port) status = -ENODEV; else { spin_lock_irq(&port->port_lock); /* already open? Great. */ if (port->open_count) { status = 0; port->open_count++; /* currently opening/closing? wait ... */ } else if (port->openclose) { status = -EBUSY; /* ... else we do the work */ } else { status = -EAGAIN; port->openclose = true; } spin_unlock_irq(&port->port_lock); } mutex_unlock(&ports[port_num].lock); switch (status) { default: /* fully handled */ return status; case -EAGAIN: /* must do the work */ break; case -EBUSY: /* wait for EAGAIN task to finish */ msleep(1); /* REVISIT could have a waitchannel here, if * concurrent open performance is important */ break; } } while (status != -EAGAIN); /* Do the "real open" */ spin_lock_irq(&port->port_lock); /* allocate circular buffer on first open */ if (port->port_write_buf.buf_buf == NULL) { spin_unlock_irq(&port->port_lock); status = gs_buf_alloc(&port->port_write_buf, WRITE_BUF_SIZE); spin_lock_irq(&port->port_lock); if (status) { pr_debug("gs_open: ttyGS%d (%p,%p) no buffer\n", port->port_num, tty, file); port->openclose = false; goto exit_unlock_port; } } /* REVISIT if REMOVED (ports[].port NULL), abort the open * to let rmmod work faster (but this way isn't wrong). */ /* REVISIT maybe wait for "carrier detect" */ tty->driver_data = port; port->port_tty = tty; port->open_count = 1; port->openclose = false; /* if connected, start the I/O stream */ if (port->port_usb) { struct gserial *gser = port->port_usb; pr_debug("gs_open: start ttyGS%d\n", port->port_num); gs_start_io(port); if (gser->connect) gser->connect(gser); } pr_debug("gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file); xlog_printk(ANDROID_LOG_INFO, ACM_LOG, \ "gs_open: ttyGS%d (%p,%p)\n", port->port_num, tty, file); USB_LOGGER(GS_OPEN, GS_OPEN, port->port_num, tty, file); status = 0; exit_unlock_port: spin_unlock_irq(&port->port_lock); return status; }
bool hwPowerOn(MT65XX_POWER powerId, MT65XX_POWER_VOLTAGE powerVolt, char *mode_name) { UINT32 i = 0; int j=0, k=0; if(first_power_on_flag == 1) { for(j=0 ; j<MT65XX_POWER_COUNT_END ; j++) { for(k=0 ; k<MAX_DEVICE ; k++) { sprintf(g_MT_PMIC_BusHW.Power[j].mod_name[k] , "%s", NON_OP); } g_MT_PMIC_BusHW.Power[j].dwPowerCount=0; } first_power_on_flag = 0; xlog_printk(ANDROID_LOG_DEBUG, "Power/PMIC", "[hwPowerOn] init done.\r\n"); } #if 1 if(powerId >= MT65XX_POWER_COUNT_END) { MSG(PMIC,"[MT65XX PMU] Error!! powerId is wrong\r\n"); return FALSE; } for (i = 0; i< MAX_DEVICE; i++) { xlog_printk(ANDROID_LOG_DEBUG, "Power/PMIC", "[hwPowerOn] %d,%s,%d\r\n", i, g_MT_PMIC_BusHW.Power[powerId].mod_name[i], g_MT_PMIC_BusHW.Power[powerId].dwPowerCount); if (!strcmp(g_MT_PMIC_BusHW.Power[powerId].mod_name[i], NON_OP)) { MSG(PMIC,"[%s] acquire powerId:%d index:%d mod_name: %s powerVolt:%d\r\n", __FUNCTION__,powerId, i, mode_name,powerVolt); sprintf(g_MT_PMIC_BusHW.Power[powerId].mod_name[i] , "%s", mode_name); break ; } /* already it */ #if 0 else if (!strcmp(g_MT_PMIC_BusHW.Power[powerId].mod_name[i], mode_name)) { MSG(CG,"[%d] Power already register\r\n",powerId ); } #endif } g_MT_PMIC_BusHW.Power[powerId].dwPowerCount++ ; /* We've already enable this LDO before */ if(g_MT_PMIC_BusHW.Power[powerId].dwPowerCount > 1) { xlog_printk(ANDROID_LOG_DEBUG, "Power/PMIC", "[hwPowerOn] g_MT_PMIC_BusHW.Power[powerId].dwPowerCount (%d) > 1\r\n", g_MT_PMIC_BusHW.Power[powerId].dwPowerCount); return TRUE; } #endif /* Turn on PMU LDO*/ MSG(CG,"[%d] PMU LDO Enable\r\n",powerId ); xlog_printk(ANDROID_LOG_DEBUG, "Power/PMIC", "[hwPowerOn] enable %d by %s \r\n", powerId, mode_name); if ((powerId == MT6323_POWER_LDO_VMC) ||(powerId == MT6323_POWER_LDO_VMCH) ||(powerId == MT6323_POWER_LDO_VEMC_3V3) ||(powerId == MT6323_POWER_LDO_VGP1) ||(powerId == MT6323_POWER_LDO_VGP2) ||(powerId == MT6323_POWER_LDO_VGP3) ||(powerId == MT6323_POWER_LDO_VSIM1) ||(powerId == MT6323_POWER_LDO_VSIM2) ||(powerId == MT6323_POWER_LDO_VCAM_AF) ||(powerId == MT6323_POWER_LDO_VIBR) ||(powerId == MT6323_POWER_LDO_VM) ||(powerId == MT6323_POWER_LDO_VCAMD) ||(powerId == MT6323_POWER_LDO_VA) ||(powerId == MT6323_POWER_LDO_VCAMA) ||(powerId == MT6323_POWER_LDO_VCN28) ||(powerId == MT6323_POWER_LDO_VCN33_BT) ||(powerId == MT6323_POWER_LDO_VCN33_WIFI) ||(powerId == MT6322_POWER_LDO_VMC) ||(powerId == MT6322_POWER_LDO_VMCH) ||(powerId == MT6322_POWER_LDO_VEMC_3V3) ||(powerId == MT6322_POWER_LDO_VGP1) ||(powerId == MT6322_POWER_LDO_VGP2) ||(powerId == MT6322_POWER_LDO_VGP3) ||(powerId == MT6322_POWER_LDO_VSIM1) ||(powerId == MT6322_POWER_LDO_VSIM2) ||(powerId == MT6322_POWER_LDO_VCAM_AF) ||(powerId == MT6322_POWER_LDO_VIBR) ||(powerId == MT6322_POWER_LDO_VM) ||(powerId == MT6322_POWER_LDO_VCAMD) ||(powerId == MT6322_POWER_LDO_VA) ||(powerId == MT6322_POWER_LDO_VCAMA) ||(powerId == MT6322_POWER_LDO_VCN28) ||(powerId == MT6322_POWER_LDO_VCN33_BT) ||(powerId == MT6322_POWER_LDO_VCN33_WIFI) ) { pmic_ldo_vol_sel(powerId, powerVolt); } pmic_ldo_enable(powerId, KAL_TRUE); return TRUE; }
static void gs_close(struct tty_struct *tty, struct file *file) { struct gs_port *port = tty->driver_data; struct gserial *gser; spin_lock_irq(&port->port_lock); if (port->open_count != 1) { if (port->open_count == 0) WARN_ON(1); else --port->open_count; goto exit; } pr_debug("gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file); xlog_printk(ANDROID_LOG_INFO, ACM_LOG, \ "gs_close: ttyGS%d (%p,%p) ...\n", port->port_num, tty, file); USB_LOGGER(GS_CLOSE,GS_CLOSE, port->port_num, tty, file); /* mark port as closing but in use; we can drop port lock * and sleep if necessary */ port->openclose = true; port->open_count = 0; gser = port->port_usb; if (gser && gser->disconnect) gser->disconnect(gser); /* wait for circular write buffer to drain, disconnect, or at * most GS_CLOSE_TIMEOUT seconds; then discard the rest */ if (gs_buf_data_avail(&port->port_write_buf) > 0 && gser) { spin_unlock_irq(&port->port_lock); wait_event_interruptible_timeout(port->drain_wait, gs_writes_finished(port), GS_CLOSE_TIMEOUT * HZ); spin_lock_irq(&port->port_lock); gser = port->port_usb; } /* Iff we're disconnected, there can be no I/O in flight so it's * ok to free the circular buffer; else just scrub it. And don't * let the push tasklet fire again until we're re-opened. */ if (gser == NULL) gs_buf_free(&port->port_write_buf); else gs_buf_clear(&port->port_write_buf); tty->driver_data = NULL; port->port_tty = NULL; port->openclose = false; pr_debug("gs_close: ttyGS%d (%p,%p) done!\n", port->port_num, tty, file); wake_up_interruptible(&port->close_wait); exit: spin_unlock_irq(&port->port_lock); }
static struct aee_oops *emmc_ipanic_oops_copy(void) { struct aee_oops *oops = NULL; struct ipanic_header *hdr = NULL; int hdr_size = ALIGN(sizeof(struct ipanic_header), EMMC_BLOCK_SIZE); hdr = kzalloc(hdr_size, GFP_KERNEL); if (hdr == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: Cannot allocate ipanic header memory\n", __FUNCTION__); return NULL; } if (card_dump_func_read((unsigned char *)hdr, hdr_size, 0, DUMP_INTO_BOOT_CARD_IPANIC) < 0) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: emmc panic log header read failed\n", __func__); return NULL; } ipanic_block_scramble((unsigned char *)hdr, hdr_size); if (ipanic_header_check(hdr) != 0) { return NULL; } oops = aee_oops_create(AE_DEFECT_FATAL, AE_KE, IPANIC_MODULE_TAG); if (oops != NULL) { struct ipanic_oops_header *oops_header = (struct ipanic_oops_header *) emmc_allocate_and_read(hdr->oops_header_offset, hdr->oops_header_length); if (oops_header == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: Can't read oops header(len:%d)\n", __FUNCTION__, hdr->oops_header_length); goto error_return; } aee_oops_set_process_path(oops, oops_header->process_path); aee_oops_set_backtrace(oops, oops_header->backtrace); kfree(oops_header); if(hdr->oops_detail_length != 0) { oops->detail = emmc_allocate_and_read(hdr->oops_detail_offset, hdr->oops_detail_length); oops->detail_len = hdr->oops_detail_length; }else { #define TMPDETAILSTR "panic detail is empty" oops->detail = kstrdup(TMPDETAILSTR, GFP_KERNEL); oops->detail_len = sizeof TMPDETAILSTR; } if (oops->detail == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read detail failed(len: %d)\n", __FUNCTION__, oops->detail_len); goto error_return; } oops->console = emmc_allocate_and_read(hdr->console_offset, hdr->console_length); oops->console_len = hdr->console_length; if (oops->console == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read console failed(len: %d)\n", __FUNCTION__, oops->console_len); goto error_return; } /*If panic from kernel context, no user sapce info available. Shouldn't fail*/ if (0 == hdr->userspace_info_length) { oops->userspace_info = NULL; oops->userspace_info_len = 0; } else { oops->userspace_info = emmc_allocate_and_read(hdr->userspace_info_offset, hdr->userspace_info_length); oops->userspace_info_len = hdr->userspace_info_length; if (oops->userspace_info == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read usrespace info failed\n", __FUNCTION__); goto error_return; } } oops->android_main = emmc_allocate_and_read(hdr->android_main_offset, hdr->android_main_length); oops->android_main_len = hdr->android_main_length; if (oops->android_main == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read android_main failed\n", __FUNCTION__); goto error_return; } oops->android_radio = emmc_allocate_and_read(hdr->android_radio_offset, hdr->android_radio_length); oops->android_radio_len = hdr->android_radio_length; if (oops->android_radio == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read android_radio failed\n", __FUNCTION__); goto error_return; } oops->android_system = emmc_allocate_and_read(hdr->android_system_offset, hdr->android_system_length); oops->android_system_len = hdr->android_system_length; if (oops->android_system == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read android_system failed\n", __FUNCTION__); goto error_return; } if (hdr->mmprofile_length == 0) { oops->mmprofile = NULL; oops->mmprofile_len = 0; } else { oops->mmprofile = emmc_allocate_and_read(hdr->mmprofile_offset, hdr->mmprofile_length); oops->mmprofile_len = hdr->mmprofile_length; } if (oops->mmprofile == NULL) { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: read mmprofile failed, offset - 0x%x, length - 0x%x\n", __FUNCTION__, oops->mmprofile, oops->mmprofile_len); } xlog_printk(ANDROID_LOG_DEBUG, IPANIC_LOG_TAG, "ipanic_oops_copy return OK\n"); kfree(hdr); return oops; } else { xlog_printk(ANDROID_LOG_ERROR, IPANIC_LOG_TAG, "%s: kmalloc failed at header\n", __FUNCTION__); kfree(hdr); return NULL; } error_return: kfree(hdr); aee_oops_free(oops); return NULL; }
static int aed_proc_init(void) { aed_proc_dir = proc_mkdir("aed", NULL); if(aed_proc_dir == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed proc_mkdir failed\n"); return -ENOMEM; } aed_proc_current_ke_console_file = create_proc_read_entry(CURRENT_KE_CONSOLE, 0444, aed_proc_dir, aed_proc_current_ke_console, NULL); if (aed_proc_current_ke_console_file == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed create_proc_read_entry failed at %s\n", CURRENT_KE_CONSOLE); return -ENOMEM; } aed_proc_current_ke_userspaceInfo_file = create_proc_read_entry(CURRENT_KE_USERSPACE_INFO, 0444, aed_proc_dir, aed_proc_current_ke_userspaceInfo, NULL); if (aed_proc_current_ke_userspaceInfo_file == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed aed_proc_current_ke_userspaceInfo_file failed at %s\n", CURRENT_KE_USERSPACE_INFO); return -ENOMEM; } aed_proc_current_ke_android_main_file = create_proc_read_entry(CURRENT_KE_ANDROID_MAIN, 0444, aed_proc_dir, aed_proc_current_ke_android_main, NULL); if (aed_proc_current_ke_android_main_file == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed create_proc_read_entry failed at %s\n", CURRENT_KE_ANDROID_MAIN); return -ENOMEM; } aed_proc_current_ke_android_radio_file = create_proc_read_entry(CURRENT_KE_ANDROID_RADIO, 0444, aed_proc_dir, aed_proc_current_ke_android_radio, NULL); if (aed_proc_current_ke_android_radio_file == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed create_proc_read_entry failed at %s\n", CURRENT_KE_ANDROID_RADIO); return -ENOMEM; } aed_proc_current_ke_android_system_file = create_proc_read_entry(CURRENT_KE_ANDROID_SYSTEM, 0444, aed_proc_dir, aed_proc_current_ke_android_system, NULL); if (aed_proc_current_ke_android_system_file == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed create_proc_read_entry failed at %s\n", CURRENT_KE_ANDROID_SYSTEM); return -ENOMEM; } aed_proc_current_ke_mmprofile_file = create_proc_read_entry(CURRENT_KE_MMPROFILE, 0444, aed_proc_dir, aed_proc_current_ke_mmprofile, NULL); if (aed_proc_current_ke_mmprofile_file == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed create_proc_read_entry failed at %s\n", CURRENT_KE_MMPROFILE); return -ENOMEM; } aed_proc_current_ee_coredump_file = create_proc_read_entry(CURRENT_EE_COREDUMP, 0444, aed_proc_dir, aed_proc_current_ee_coredump, NULL); if (aed_proc_current_ee_coredump_file == NULL) { xlog_printk(ANDROID_LOG_ERROR, AEK_LOG_TAG, "aed create_proc_read_entry failed at %s\n", CURRENT_EE_COREDUMP); return -ENOMEM; } aee_rr_proc_init(aed_proc_dir); aed_proc_debug_init(aed_proc_dir); return 0; }