Exemplo n.º 1
0
static int rk32_lvds_probe(struct platform_device *pdev)
{
	struct rk32_lvds *lvds;
	struct resource *res;
	struct device_node *np = pdev->dev.of_node;

	if (!np) {
		dev_err(&pdev->dev, "Missing device tree node.\n");
		return -EINVAL;
	}

	lvds = devm_kzalloc(&pdev->dev, sizeof(struct rk32_lvds), GFP_KERNEL);
	if (!lvds) {
		dev_err(&pdev->dev, "no memory for state\n");
		return -ENOMEM;
	}
	lvds->dev = &pdev->dev;
	rk_fb_get_prmry_screen(&lvds->screen);
	if ((lvds->screen.type != SCREEN_RGB) && 
		(lvds->screen.type != SCREEN_LVDS) &&
		(lvds->screen.type != SCREEN_DUAL_LVDS)) {
		dev_err(&pdev->dev, "screen is not lvds/rgb!\n");		
		writel_relaxed(0xffff8000, RK_GRF_VIRT + RK3288_GRF_SOC_CON7);
		return -EINVAL;
	}
	platform_set_drvdata(pdev, lvds);
	dev_set_name(lvds->dev, "rk32-lvds");
	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	lvds->regs = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(lvds->regs)) {
		dev_err(&pdev->dev, "ioremap reg failed\n");
		return PTR_ERR(lvds->regs);
	}
	lvds->pclk = devm_clk_get(&pdev->dev,"pclk_lvds");
	if (IS_ERR(lvds->pclk)) {
		dev_err(&pdev->dev, "get clk failed\n");
		return PTR_ERR(lvds->pclk);
	}
	lvds->pd = devm_clk_get(&pdev->dev,"pd_lvds");
	if (IS_ERR(lvds->pd)) {
		dev_err(&pdev->dev, "get clk failed\n");
		return PTR_ERR(lvds->pd);
	}	
	if (support_uboot_display()) {
		rk32_lvds_clk_enable(lvds);
	}

	rk32_lvds = lvds;
	rk_fb_trsm_ops_register(&trsm_lvds_ops,SCREEN_LVDS);
	dev_info(&pdev->dev, "rk32 lvds driver probe success\n");

	return 0;
}
Exemplo n.º 2
0
static int rk3026_lvds_probe(struct platform_device *pdev)
{
	rk_screen *screen = NULL;
	screen = rk_fb_get_prmry_screen();
	if(!screen)
	{
		dev_err(&pdev->dev,"the fb prmry screen is null!\n");
		return -ENODEV;
	}
	
	rk3026_lvds_set_param(screen,OUT_ENABLE);

	return 0;
	
}
Exemplo n.º 3
0
static int rk616_lvds_probe(struct platform_device *pdev)
{
	struct rk616_lvds *lvds = NULL; 
	struct mfd_rk616 *rk616 = NULL;
	rk_screen *screen = NULL;
	lvds = kzalloc(sizeof(struct rk616_lvds),GFP_KERNEL);
	if(!lvds)
	{
		printk(KERN_ALERT "alloc for struct rk616_lvds fail\n");
		return  -ENOMEM;
	}

	rk616 = dev_get_drvdata(pdev->dev.parent);
	if(!rk616)
	{
		dev_err(&pdev->dev,"null mfd device rk616!\n");
		return -ENODEV;
	}
	else
		g_lvds = lvds;
	lvds->rk616 = rk616;
	
	screen = rk_fb_get_prmry_screen();
	if(!screen)
	{
		dev_err(&pdev->dev,"the fb prmry screen is null!\n");
		return -ENODEV;
	}
	lvds->screen = screen;
#if defined(CONFIG_ONE_LCDC_DUAL_OUTPUT_INF)
	screen->sscreen_set = rk616_scaler_set_param;
#endif
 	rk616_lvds_init_cfg(rk616,screen);
#ifdef CONFIG_HAS_EARLYSUSPEND
	lvds->early_suspend.suspend = rk616_lvds_early_suspend;
	lvds->early_suspend.resume = rk616_lvds_late_resume;
    	lvds->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1;
	register_early_suspend(&lvds->early_suspend);
#endif
	

	dev_info(&pdev->dev,"rk616 lvds probe success!\n");

	return 0;
	
}
Exemplo n.º 4
0
static int rk32_edp_probe(struct platform_device *pdev)
{
	struct rk32_edp *edp;
	struct resource *res;
	struct device_node *np = pdev->dev.of_node;
	int ret;

	if (!np) {
		dev_err(&pdev->dev, "Missing device tree node.\n");
		return -EINVAL;
	}

	edp = devm_kzalloc(&pdev->dev, sizeof(struct rk32_edp), GFP_KERNEL);
	if (!edp) {
		dev_err(&pdev->dev, "no memory for state\n");
		return -ENOMEM;
	}
	edp->dev = &pdev->dev;
	edp->video_info.h_sync_polarity	= 0;
	edp->video_info.v_sync_polarity	= 0;
	edp->video_info.interlaced	= 0;
	edp->video_info.color_space	= CS_RGB;
	edp->video_info.dynamic_range	= VESA;
	edp->video_info.ycbcr_coeff	= COLOR_YCBCR601;
	edp->video_info.color_depth	= COLOR_8;

	edp->video_info.link_rate	= LINK_RATE_1_62GBPS;
	edp->video_info.lane_count	= LANE_CNT4;
	rk_fb_get_prmry_screen(&edp->screen);
	if (edp->screen.type != SCREEN_EDP) {
		dev_err(&pdev->dev, "screen is not edp!\n");
		return -EINVAL;
	}
	platform_set_drvdata(pdev, edp);
	dev_set_name(edp->dev, "rk32-edp");
	
	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	edp->regs = devm_ioremap_resource(&pdev->dev, res);
	if (IS_ERR(edp->regs)) {
		dev_err(&pdev->dev, "ioremap reg failed\n");
		return PTR_ERR(edp->regs);
	}

	edp->clk_edp = devm_clk_get(&pdev->dev,"clk_edp");
	if (IS_ERR(edp->clk_edp)) {
		dev_err(&pdev->dev, "cannot get clk_edp\n");
		return PTR_ERR(edp->clk_edp);
	}

	edp->clk_24m = devm_clk_get(&pdev->dev,"clk_edp_24m");
	if (IS_ERR(edp->clk_24m)) {
		dev_err(&pdev->dev, "cannot get clk_edp_24m\n");
		return PTR_ERR(edp->clk_24m);
	}

	edp->pclk = devm_clk_get(&pdev->dev,"pclk_edp");
	if (IS_ERR(edp->pclk)) {
		dev_err(&pdev->dev, "cannot get pclk\n");
		return PTR_ERR(edp->pclk);
	}

	clk_prepare(edp->pclk);
	clk_prepare(edp->clk_edp);
	clk_prepare(edp->clk_24m);
	rk32_edp_clk_enable(edp);
	rk32_edp_pre_init();
	edp->irq = platform_get_irq(pdev, 0);
	if (edp->irq < 0) {
		dev_err(&pdev->dev, "cannot find IRQ\n");
		return edp->irq;
	}
	ret = devm_request_irq(&pdev->dev, edp->irq, rk32_edp_isr, 0,
			dev_name(&pdev->dev), edp);
	if (ret) {
		dev_err(&pdev->dev, "cannot claim IRQ %d\n", edp->irq);
		return ret;
	}
	disable_irq_nosync(edp->irq);
	rk32_edp_clk_disable(edp);
	rk32_edp = edp;
	rk_fb_trsm_ops_register(&trsm_edp_ops, SCREEN_EDP);
	dev_info(&pdev->dev, "rk32 edp driver probe success\n");

	return 0;
}
Exemplo n.º 5
0
static int rk32_lvds_en(void)
{
	struct rk32_lvds *lvds = rk32_lvds;
	struct rk_screen *screen = &lvds->screen;
	u32 h_bp = 0;
	u32 val = 0;

	rk_fb_get_prmry_screen(screen);

	/* enable clk */
	rk32_lvds_clk_enable(lvds);

	/* select lcdc source */
	if (screen->lcdc_id == 1) /*lcdc1 = vop little,lcdc0 = vop big*/
		val = LVDS_SEL_VOP_LIT | (LVDS_SEL_VOP_LIT << 16);
	else
		val = LVDS_SEL_VOP_LIT << 16;
	grf_writel(val, RK3288_GRF_SOC_CON6);

	/* set lvds format */
	val = screen->lvds_format;
	if (screen->type == SCREEN_DUAL_LVDS)
		val |= LVDS_DUAL | LVDS_CH0_EN | LVDS_CH1_EN;
	else if(screen->type == SCREEN_LVDS)
		val |= LVDS_CH0_EN;
	else if (screen->type == SCREEN_RGB)
		val |= LVDS_TTL_EN | LVDS_CH0_EN | LVDS_CH1_EN;

	h_bp = screen->mode.hsync_len + screen->mode.left_margin;
	if (h_bp & 0x01)
		val |= LVDS_START_PHASE_RST_1;

	val |= (screen->pin_dclk << 8) | (screen->pin_hsync << 9) |
		(screen->pin_den << 10);
	val |= (0xffff << 16);
	grf_writel(val, RK3288_GRF_SOC_CON7);

	if (screen->type == SCREEN_RGB) {
		val = 0x007f007f;//0x1<<6 |0x1 <<4;
		grf_writel(val, RK3288_GRF_GPIO1D_IOMUX);

		lvds_writel(lvds, LVDS_CH0_REG_0, 0x7f);
		lvds_writel(lvds, LVDS_CH0_REG_1, 0x40);
		lvds_writel(lvds, LVDS_CH0_REG_2, 0x00);

		lvds_writel(lvds, LVDS_CH0_REG_4, 0x3f);
		lvds_writel(lvds, LVDS_CH0_REG_5, 0x3f);
		lvds_writel(lvds, LVDS_CH0_REG_3, 0x46);
		lvds_writel(lvds, LVDS_CH0_REG_d, 0x0a);
		lvds_writel(lvds, LVDS_CH0_REG_20,0x44);/* 44:LSB  45:MSB*/
		writel_relaxed(0x00, lvds->regs + LVDS_CFG_REG_c); /*eanble pll*/
		writel_relaxed(0x92, lvds->regs + LVDS_CFG_REG_21); /*enable tx*/

		lvds_writel(lvds, 0x100, 0x7f);
		lvds_writel(lvds, 0x104, 0x40);
		lvds_writel(lvds, 0x108, 0x00);
		lvds_writel(lvds, 0x10c, 0x46);
		lvds_writel(lvds, 0x110, 0x3f);
		lvds_writel(lvds, 0x114, 0x3f);
		lvds_writel(lvds, 0x134, 0x0a);
	} else {
		lvds_writel(lvds, LVDS_CH0_REG_0, 0xbf);
		lvds_writel(lvds, LVDS_CH0_REG_1, 0x3f);
		lvds_writel(lvds, LVDS_CH0_REG_2, 0xfe);
		lvds_writel(lvds, LVDS_CH0_REG_3, 0x46);
		lvds_writel(lvds, LVDS_CH0_REG_4, 0x00);
		lvds_writel(lvds, LVDS_CH0_REG_d, 0x0a);
		lvds_writel(lvds, LVDS_CH0_REG_20,0x44);/* 44:LSB  45:MSB*/
		writel_relaxed(0x00, lvds->regs + LVDS_CFG_REG_c); /*eanble pll*/
		writel_relaxed(0x92, lvds->regs + LVDS_CFG_REG_21); /*enable tx*/
	}

	return 0;
}