mipi_dsim probe函数

static int s5p_dsim_probe(struct platform_device *pdev)
{
struct resource *res;
int ret = -1;


dsim.pd = to_dsim_plat(&pdev->dev);
dsim.dev = &pdev->dev;
#ifdef CONFIG_EXYNOS4_DEV_PD
/* to use the runtime PM helper functions */
pm_runtime_enable(&pdev->dev);
/* enable the power domain */
pm_runtime_get_sync(&pdev->dev);
#endif
/* set dsim config data, dsim lcd config data and lcd panel data. */
dsim.dsim_info = dsim.pd->dsim_info;
dsim.dsim_lcd_info = dsim.pd->dsim_lcd_info;
dsim.lcd_panel_info =
(struct s3cfb_lcd *)dsim.dsim_lcd_info->lcd_panel_info;
dsim.mipi_ddi_pd =
(struct mipi_ddi_platform_data *)dsim.dsim_lcd_info->mipi_ddi_pd;
dsim.mipi_ddi_pd->te_irq = dsim.pd->te_irq;


dsim.mipi_ddi_pd->resume_complete = 0;


/* reset lcd */
dsim.mipi_ddi_pd->lcd_reset();


/* clock */
dsim.clock = clk_get(&pdev->dev, dsim.pd->clk_name);
if (IS_ERR(dsim.clock)) {
dev_err(&pdev->dev, "failed to get dsim clock source\n");
return -EINVAL;
}


clk_enable(dsim.clock);


/* io memory */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "failed to get io memory region\n");
ret = -EINVAL;
goto err_clk_disable;
}


/* request mem region */
res = request_mem_region(res->start,
res->end - res->start + 1, pdev->name);
if (!res) {
dev_err(&pdev->dev, "failed to request io memory region\n");
ret = -EINVAL;
goto err_clk_disable;
}


/* ioremap for register block */
dsim.reg_base = (unsigned int) ioremap(res->start,
res->end - res->start + 1);
if (!dsim.reg_base) {
dev_err(&pdev->dev, "failed to remap io region\n");
ret = -EINVAL;
goto err_clk_disable;
}


/* find lcd panel driver registered to mipi-dsi driver. */
dsim.mipi_drv = scan_mipi_driver(dsim.pd->lcd_panel_name);
if (dsim.mipi_drv == NULL) {
dev_err(&pdev->dev, "mipi_drv is NULL.\n");
goto mipi_drv_err;
}


/* set lcd panel driver link */
dsim.mipi_drv->set_link((void *) dsim.mipi_ddi_pd, dsim.reg_base,
s5p_dsim_wr_data, NULL);


dsim.mipi_drv->probe(&pdev->dev);
s5p_dsim_init_dsim(dsim.reg_base);
s5p_dsim_init_link(dsim.reg_base);


s5p_dsim_set_hs_enable(dsim.reg_base);
s5p_dsim_set_data_transfer_mode(dsim.reg_base, DSIM_TRANSFER_BYCPU, 1);


/* initialize lcd panel */
if (dsim.mipi_drv->init) {
dsim.mipi_drv->init();
} else {
dev_warn(&pdev->dev, "init func is null.\n");
}


if (dsim.mipi_drv->display_on)
dsim.mipi_drv->display_on(&pdev->dev);
else
dev_warn(&pdev->dev, "display_on func is null.\n");


s5p_dsim_set_display_mode(dsim.reg_base, dsim.dsim_lcd_info, NULL);
s5p_dsim_set_data_transfer_mode(dsim.reg_base, DSIM_TRANSFER_BYLCDC, 1);
msleep(400);
dev_info(&pdev->dev, "mipi-dsi driver has been probed.\n");


#ifdef CONFIG_HAS_WAKELOCK
#ifdef CONFIG_HAS_EARLYSUSPEND
dsim.early_suspend.suspend = s5p_dsim_early_suspend;
dsim.early_suspend.resume = s5p_dsim_late_resume;
dsim.early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB;
register_early_suspend(&dsim.early_suspend);
#endif
#endif


return 0;


mipi_drv_err:
dsim.pd->mipi_power(0);
iounmap((void __iomem *) dsim.reg_base);
err_clk_disable:
clk_disable(dsim.clock);


return ret;
}

你可能感兴趣的:(IO,struct,null,domain)