static int sprdfb_probe(struct platform_device *pdev) { struct fb_info *fb = NULL; struct sprdfb_device *dev = NULL; int ret = 0; #ifdef CONFIG_OF struct resource r; #ifdef CONFIG_FB_LOW_RES_SIMU uint32_t display_size_array[2]; #endif pr_debug(KERN_INFO "sprdfb: [%s]\n", __FUNCTION__); #else pr_debug(KERN_INFO "sprdfb: [%s], id = %d\n", __FUNCTION__, pdev->id); #endif fb = framebuffer_alloc(sizeof(struct sprdfb_device), &pdev->dev); if (!fb) { printk(KERN_ERR "sprdfb: sprdfb_probe allocate buffer fail.\n"); ret = -ENOMEM; goto err0; } dev = fb->par; dev->fb = fb; #ifdef CONFIG_OF dev->of_dev = &(pdev->dev); dev->dev_id = of_alias_get_id(pdev->dev.of_node, "lcd"); printk("sprdfb: [%s] id = %d\n", __FUNCTION__, dev->dev_id); #else dev->dev_id = pdev->id; #endif if((SPRDFB_MAINLCD_ID != dev->dev_id) &&(SPRDFB_SUBLCD_ID != dev->dev_id)){ printk(KERN_ERR "sprdfb: sprdfb_probe fail. (unsupported device id)\n"); goto err0; } switch(SPRDFB_IN_DATA_TYPE){ case SPRD_IN_DATA_TYPE_ABGR888: dev->bpp = 32; break; case SPRD_IN_DATA_TYPE_BGR565: dev->bpp = 16; break; default: dev->bpp = 32; break; } if(SPRDFB_MAINLCD_ID == dev->dev_id){ dev->ctrl = &sprdfb_dispc_ctrl; #ifdef CONFIG_OF if(0 != of_address_to_resource(pdev->dev.of_node, 0, &r)){ printk(KERN_ERR "sprdfb: sprdfb_probe fail. (can't get register base address)\n"); goto err0; } g_dispc_base_addr = (unsigned long)ioremap_nocache(r.start, resource_size(&r)); if(!g_dispc_base_addr) BUG(); printk("sprdfb: set g_dispc_base_addr = %ld\n", g_dispc_base_addr); #endif } dev->frame_count = 0; dev->logo_buffer_addr_v = 0; dev->capability = sprdfb_config_capability(); if(sprdfb_panel_get(dev)){ dev->panel_ready = true; #ifdef CONFIG_OF #ifdef CONFIG_FB_LOW_RES_SIMU ret = of_property_read_u32_array(pdev->dev.of_node, "sprd,fb_display_size", display_size_array, 2); if (0 != ret) { printk("sprdfb: read display_size from dts fail (%d)\n", ret); dev->display_width = dev->panel->width; dev->display_height = dev->panel->height; } else { dev->display_width = display_size_array[0]; dev->display_height = display_size_array[1]; } #endif #endif dev->ctrl->logo_proc(dev); }else{ dev->panel_ready = false; } dev->ctrl->early_init(dev); if(!dev->panel_ready){ if (!sprdfb_panel_probe(dev)) { ret = -EIO; goto cleanup; } } ret = setup_fb_mem(dev, pdev); if (ret) { goto cleanup; } setup_fb_info(dev); /* register framebuffer device */ ret = register_framebuffer(fb); if (ret) { printk(KERN_ERR "sprdfb: sprdfb_probe register framebuffer fail.\n"); goto cleanup; } platform_set_drvdata(pdev, dev); sprdfb_create_sysfs(dev); dev->ctrl->init(dev); #ifdef CONFIG_HAS_EARLYSUSPEND dev->early_suspend.suspend = sprdfb_early_suspend; dev->early_suspend.resume = sprdfb_late_resume; dev->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; register_early_suspend(&dev->early_suspend); #endif #ifdef CONFIG_FB_ESD_SUPPORT pr_debug("sprdfb: Init ESD work queue!\n"); INIT_DELAYED_WORK(&dev->ESD_work, ESD_work_func); // sema_init(&dev->ESD_lock, 1); if(SPRDFB_PANEL_IF_DPI == dev->panel_if_type){ dev->ESD_timeout_val = SPRDFB_ESD_TIME_OUT_VIDEO; }else{ dev->ESD_timeout_val = SPRDFB_ESD_TIME_OUT_CMD; } dev->ESD_work_start = false; dev->check_esd_time = 0; dev->reset_dsi_time = 0; dev->panel_reset_time = 0; #endif return 0; cleanup: sprdfb_panel_remove(dev); dev->ctrl->uninit(dev); fb_free_resources(dev); err0: dev_err(&pdev->dev, "failed to probe sprdfb\n"); return ret; }
static int sprdfb_probe(struct platform_device *pdev) { struct fb_info *fb = NULL; struct sprdfb_device *dev = NULL; int ret = 0; pr_debug(KERN_INFO "sprdfb:[%s], id = %d\n", __FUNCTION__, pdev->id); fb = framebuffer_alloc(sizeof(struct sprdfb_device), &pdev->dev); if (!fb) { printk(KERN_ERR "sprdfb: sprdfb_probe allocate buffer fail.\n"); ret = -ENOMEM; goto err0; } dev = fb->par; dev->fb = fb; dev->dev_id = pdev->id; if((SPRDFB_MAINLCD_ID != dev->dev_id) &&(SPRDFB_SUBLCD_ID != dev->dev_id)){ printk(KERN_ERR "sprdfb: sprdfb_probe fail. (unsupported device id)\n"); goto err0; } switch(SPRDFB_IN_DATA_TYPE){ case SPRD_IN_DATA_TYPE_ABGR888: dev->bpp = 32; break; case SPRD_IN_DATA_TYPE_BGR565: dev->bpp = 16; break; default: dev->bpp = 32; break; } if(SPRDFB_MAINLCD_ID == dev->dev_id){ dev->ctrl = &sprdfb_dispc_ctrl; }else{ dev->ctrl = &sprdfb_lcdc_ctrl; } if(sprdfb_panel_get(dev)){ dev->panel_ready = true; }else{ dev->panel_ready = false; } dev->ctrl->early_init(dev); if(!dev->panel_ready){ if (!sprdfb_panel_probe(dev)) { ret = -EIO; goto cleanup; } } ret = setup_fb_mem(dev, pdev); if (ret) { goto cleanup; } setup_fb_info(dev); dev->ctrl->init(dev); /* register framebuffer device */ ret = register_framebuffer(fb); if (ret) { printk(KERN_ERR "sprdfb: sprdfb_probe register framebuffer fail.\n"); goto cleanup; } platform_set_drvdata(pdev, dev); #ifdef CONFIG_HAS_EARLYSUSPEND dev->early_suspend.suspend = sprdfb_early_suspend; dev->early_suspend.resume = sprdfb_late_resume; dev->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; register_early_suspend(&dev->early_suspend); #endif return 0; cleanup: sprdfb_panel_remove(dev); dev->ctrl->uninit(dev); fb_free_resources(dev); err0: dev_err(&pdev->dev, "failed to probe sprdfb\n"); return ret; }