static int mddi_on(struct platform_device *pdev) { int ret = 0; u32 clk_rate; struct msm_fb_data_type *mfd; #ifdef ENABLE_FWD_LINK_SKEW_CALIBRATION mddi_host_type host_idx = MDDI_HOST_PRIM; u32 stat_reg; #endif mfd = platform_get_drvdata(pdev); pmdh_clk_enable(); pm_runtime_get(&pdev->dev); if (mddi_pdata && mddi_pdata->mddi_power_save) mddi_pdata->mddi_power_save(1); pmdh_clk_enable(); #ifdef ENABLE_FWD_LINK_SKEW_CALIBRATION if (mddi_client_type < 2) { /* For skew calibration, clock should be less than 50MHz */ if (!clk_set_min_rate(mddi_clk, 49000000)) { stat_reg = mddi_host_reg_in(STAT); printk(KERN_DEBUG "\n stat_reg = 0x%x", stat_reg); mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE); if (stat_reg & (0x1 << 4)) mddi_host_reg_out(CMD, MDDI_CMD_LINK_ACTIVE); mddi_host_reg_out(CMD, MDDI_CMD_SEND_RTD); mddi_send_fw_link_skew_cal(host_idx); mddi_host_reg_out(CMD, MDDI_CMD_SEND_RTD); mddi_host_reg_out(CMD, MDDI_CMD_HIBERNATE | 1); } else { printk(KERN_ERR "%s: clk_set_min_rate failed\n", __func__); } } #endif clk_rate = mfd->fbi->var.pixclock; clk_rate = min(clk_rate, mfd->panel_info.clk_max); if (mddi_pdata && mddi_pdata->mddi_sel_clk && mddi_pdata->mddi_sel_clk(&clk_rate)) printk(KERN_ERR "%s: can't select mddi io clk targate rate = %d\n", __func__, clk_rate); if (clk_set_min_rate(mddi_clk, clk_rate) < 0) printk(KERN_ERR "%s: clk_set_min_rate failed\n", __func__); ret = panel_next_on(pdev); return ret; }
static int mddi_off(struct platform_device *pdev) { struct msm_fb_data_type *mfd; boolean dma_pending, dma_update_flag; int ret, i; mfd = platform_get_drvdata(pdev); for (i = 0; i < 6; i++) { dma_update_flag = mfd->dma_update_flag; dma_pending = mfd->dma->busy; if (dma_update_flag && !dma_pending) break; msleep(5); } pmdh_clk_enable(); ret = panel_next_off(pdev); pmdh_clk_disable(); if (mddi_pdata && mddi_pdata->mddi_power_save) mddi_pdata->mddi_power_save(0); #ifdef CONFIG_MSM_BUS_SCALING mdp_bus_scale_update_request(0); #else if (mfd->ebi1_clk) clk_disable_unprepare(mfd->ebi1_clk); #endif pm_runtime_put(&pdev->dev); return ret; }
static int __init mddi_driver_init(void) { int ret; pmdh_clk_status = 0; mddi_clk = clk_get(NULL, "mddi_clk"); if (IS_ERR(mddi_clk)) { printk(KERN_ERR "can't find mddi_clk\n"); return PTR_ERR(mddi_clk); } ret = clk_set_min_rate(mddi_clk, 49000000); if (ret) printk(KERN_ERR "Can't set mddi_clk min rate to 49000000\n"); printk(KERN_INFO "mddi_clk init rate is %lu\n", clk_get_rate(mddi_clk)); mddi_pclk = clk_get(NULL, "mddi_pclk"); if (IS_ERR(mddi_pclk)) mddi_pclk = NULL; pmdh_clk_enable(); ret = mddi_register_driver(); if (ret) { pmdh_clk_disable(); clk_put(mddi_clk); if (mddi_pclk) clk_put(mddi_pclk); printk(KERN_ERR "mddi_register_driver() failed!\n"); return ret; } mddi_init(); return ret; }
static int mddi_off(struct platform_device *pdev) { struct msm_fb_data_type *mfd; boolean dma_pending, dma_update_flag; int ret, i; mfd = platform_get_drvdata(pdev); for (i = 0; i < 6; i++) { dma_update_flag = mfd->dma_update_flag; dma_pending = mfd->dma->busy; if (dma_update_flag && !dma_pending) break; msleep(5); } pmdh_clk_enable(); ret = panel_next_off(pdev); pmdh_clk_disable(); if (mddi_pdata && mddi_pdata->mddi_power_save) mddi_pdata->mddi_power_save(0); pm_runtime_put(&pdev->dev); return ret; }
static int __init mddi_driver_init(void) { int ret; mddi_clk = clk_get(NULL, "mddi_clk"); if (IS_ERR(mddi_clk)) { printk(KERN_ERR "can't find mddi_clk \n"); return PTR_ERR(mddi_clk); } mddi_pclk = clk_get(NULL, "mddi_pclk"); if (IS_ERR(mddi_pclk)) mddi_pclk = NULL; pmdh_clk_enable(); ret = mddi_register_driver(); if (ret) { pmdh_clk_disable(); clk_put(mddi_clk); if (mddi_pclk) { clk_put(mddi_pclk); } printk(KERN_ERR "mddi_register_driver() failed!\n"); return ret; } mddi_init(); return ret; }
static int mddi_resume(struct platform_device *pdev) { mddi_host_type host_idx = MDDI_HOST_PRIM; if (!mddi_is_in_suspend) return 0; mddi_is_in_suspend = 0; if (mddi_power_locked) return 0; enable_irq(INT_MDDI_PRI); pmdh_clk_enable(); mddi_host_reg_out(PAD_CTL, mddi_pad_ctrl); return 0; }
void mddi_disable(int lock) { mddi_host_type host_idx = MDDI_HOST_PRIM; if (mddi_power_locked) return; if (lock) mddi_power_locked = 1; pmdh_clk_enable(); mddi_pad_ctrl = mddi_host_reg_in(PAD_CTL); mddi_host_reg_out(PAD_CTL, 0x0); pmdh_clk_disable(); if (mddi_pdata && mddi_pdata->mddi_power_save) mddi_pdata->mddi_power_save(0); }
static int mddi_suspend(struct platform_device *pdev, pm_message_t state) { mddi_host_type host_idx = MDDI_HOST_PRIM; if (mddi_is_in_suspend) return 0; mddi_is_in_suspend = 1; if (mddi_power_locked) return 0; pmdh_clk_enable(); mddi_pad_ctrl = mddi_host_reg_in(PAD_CTL); mddi_host_reg_out(PAD_CTL, 0x0); pmdh_clk_disable(); return 0; }
int pmdh_clk_func(int value) { int ret = 0; switch (value) { case 0: pmdh_clk_disable(); break; case 1: pmdh_clk_enable(); break; case 2: default: mutex_lock(&pmdh_clk_lock); ret = pmdh_clk_status; mutex_unlock(&pmdh_clk_lock); break; } return ret; }
void mddi_disable(int lock) { mddi_host_type host_idx = MDDI_HOST_PRIM; if (mddi_power_locked) return; if (lock) mddi_power_locked = 1; pmdh_clk_enable(); mddi_pad_ctrl = mddi_host_reg_in(PAD_CTL); mddi_host_reg_out(PAD_CTL, 0x0); if (clk_set_min_rate(mddi_clk, 0) < 0) printk(KERN_ERR "%s: clk_set_min_rate failed\n", __func__); pmdh_clk_disable(); if (mddi_pdata && mddi_pdata->mddi_power_save) mddi_pdata->mddi_power_save(0); }
static int mddi_suspend(struct platform_device *pdev, pm_message_t state) { mddi_host_type host_idx = MDDI_HOST_PRIM; if (mddi_is_in_suspend) return 0; mddi_is_in_suspend = 1; if (mddi_power_locked) return 0; pmdh_clk_enable(); mddi_pad_ctrl = mddi_host_reg_in(PAD_CTL); mddi_host_reg_out(PAD_CTL, 0x0); if (clk_set_min_rate(mddi_clk, 0) < 0) printk(KERN_ERR "%s: clk_set_min_rate failed\n", __func__); pmdh_clk_disable(); return 0; }
static int mddi_probe(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct platform_device *mdp_dev = NULL; struct msm_fb_panel_data *pdata = NULL; int rc; resource_size_t size ; u32 clk_rate; unsigned long rate; int ret; struct clk *ebi1_clk = NULL; if ((pdev->id == 0) && (pdev->num_resources >= 0)) { mddi_pdata = pdev->dev.platform_data; pmdh_clk_status = 0; mddi_clk = clk_get(&pdev->dev, "core_clk"); if (IS_ERR(mddi_clk)) { pr_err("can't find mddi_clk\n"); return PTR_ERR(mddi_clk); } rate = clk_round_rate(mddi_clk, 49000000); ret = clk_set_rate(mddi_clk, rate); if (ret) pr_err("Can't set mddi_clk min rate to %lu\n", rate); pr_info("mddi_clk init rate is %lu\n", clk_get_rate(mddi_clk)); mddi_pclk = clk_get(&pdev->dev, "iface_clk"); if (IS_ERR(mddi_pclk)) mddi_pclk = NULL; pmdh_clk_enable(); #ifndef CONFIG_MSM_BUS_SCALING ebi1_clk = clk_get(&pdev->dev, "mem_clk"); if (IS_ERR(ebi1_clk)) return PTR_ERR(ebi1_clk); clk_set_rate(ebi1_clk, 65000000); #endif size = resource_size(&pdev->resource[0]); msm_pmdh_base = ioremap(pdev->resource[0].start, size); MSM_FB_INFO("primary mddi base phy_addr = 0x%x virt = 0x%x\n", pdev->resource[0].start, (int) msm_pmdh_base); if (unlikely(!msm_pmdh_base)) return -ENOMEM; if (mddi_pdata && mddi_pdata->mddi_power_save) mddi_pdata->mddi_power_save(1); mddi_resource_initialized = 1; return 0; } if (!mddi_resource_initialized) return -EPERM; mfd = platform_get_drvdata(pdev); mfd->ebi1_clk = ebi1_clk; if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; if (pdev_list_cnt >= MSM_FB_MAX_DEV_LIST) return -ENOMEM; mdp_dev = platform_device_alloc("mdp", pdev->id); if (!mdp_dev) return -ENOMEM; /* * link to the latest pdev */ mfd->pdev = mdp_dev; mfd->dest = DISPLAY_LCD; /* * alloc panel device data */ if (platform_device_add_data (mdp_dev, pdev->dev.platform_data, sizeof(struct msm_fb_panel_data))) { printk(KERN_ERR "mddi_probe: platform_device_add_data failed!\n"); platform_device_put(mdp_dev); return -ENOMEM; } /* * data chain */ pdata = mdp_dev->dev.platform_data; pdata->on = mddi_on; pdata->off = mddi_off; pdata->next = pdev; pdata->clk_func = pmdh_clk_func; /* * get/set panel specific fb info */ mfd->panel_info = pdata->panel_info; if (mfd->index == 0) mfd->fb_imgType = MSMFB_DEFAULT_TYPE; else mfd->fb_imgType = MDP_RGB_565; clk_rate = mfd->panel_info.clk_max; if (mddi_pdata && mddi_pdata->mddi_sel_clk && mddi_pdata->mddi_sel_clk(&clk_rate)) printk(KERN_ERR "%s: can't select mddi io clk targate rate = %d\n", __func__, clk_rate); if (clk_set_max_rate(mddi_clk, clk_rate) < 0) printk(KERN_ERR "%s: clk_set_max_rate failed\n", __func__); mfd->panel_info.clk_rate = mfd->panel_info.clk_min; if (!mddi_client_type) mddi_client_type = mfd->panel_info.lcd.rev; else if (!mfd->panel_info.lcd.rev) printk(KERN_ERR "%s: mddi client is trying to revert back to type 1 !!!\n", __func__); /* * set driver data */ platform_set_drvdata(mdp_dev, mfd); rc = pm_runtime_set_active(&pdev->dev); if (rc < 0) printk(KERN_ERR "pm_runtime: fail to set active\n"); rc = 0; pm_runtime_enable(&pdev->dev); /* * register in mdp driver */ rc = platform_device_add(mdp_dev); if (rc) goto mddi_probe_err; pdev_list[pdev_list_cnt++] = pdev; #ifdef CONFIG_HAS_EARLYSUSPEND mfd->mddi_early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; mfd->mddi_early_suspend.suspend = mddi_early_suspend; mfd->mddi_early_suspend.resume = mddi_early_resume; register_early_suspend(&mfd->mddi_early_suspend); #endif return 0; mddi_probe_err: platform_device_put(mdp_dev); return rc; }