}
837
838 if (mach_info->default_display >= mach_info->num_displays) {
839 dev_err(&pdev->dev, "default is %d but only %d displays\n",
840 mach_info->default_display, mach_info->num_displays);
841 return -EINVAL;
842 }
843
844 display = mach_info->displays + mach_info->default_display;
845
846 irq = platform_get_irq(pdev, 0);
847 if (irq < 0) {
848 dev_err(&pdev->dev, "no irq for device\n");
849 return -ENOENT;
850 }
851
852 fbinfo = framebuffer_alloc(sizeof(struct s3c2410fb_info), &pdev->dev);
853 if (!fbinfo)
854 return -ENOMEM;
855
856 platform_set_drvdata(pdev, fbinfo);
857
858 info = fbinfo->par;
859 info->dev = &pdev->dev;
860 info->drv_type = drv_type;
861
862 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
863 if (res == NULL) {
864 dev_err(&pdev->dev, "failed to get memory registers\n");
865 ret = -ENXIO;
866 goto dealloc_fb;
867 }
868
869 size = (res->end - res->start) + 1;
870 info->mem = request_mem_region(res->start, size, pdev->name);
871 if (info->mem == NULL) {
872 dev_err(&pdev->dev, "failed to get memory region\n");
873 ret = -ENOENT;
874 goto dealloc_fb;
875 }
876
877 info->io = ioremap(res->start, size);
878 if (info->io == NULL) {
879 dev_err(&pdev->dev, "ioremap() of registers failed\n");
880 ret = -ENXIO;
881 goto release_mem;
882 }
883
884 info->irq_base = info->io + ((drv_type == DRV_S3C2412) S3C2412_LCDINTBASE : S3C2410_LCDINTBAS E);
885
886 dprintk("devinit\n");
887
888 strcpy(fbinfo->fix.id, driver_name);
889
890 /* Stop the video */
891 lcdcon1 = readl(info->io + S3C2410_LCDCON1);
892 writel(lcdcon1 & ~S3C2410_LCDCON1_ENVID, info->io + S3C2410_LCDCON1);
893
894 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
895 fbinfo->fix.type_aux = 0;
896 fbinfo->fix.xpanstep = 0;
897 fbinfo->fix.ypanstep = 0;
898 fbinfo->fix.ywrapstep = 0;
899 fbinfo->fix.accel = FB_ACCEL_NONE;
900
901 fbinfo->var.nonstd = 0;
902 fbinfo->var.activate = FB_ACTIVATE_NOW;
903 fbinfo->var.accel_flags = 0;
904 fbinfo->var.vmode = FB_VMODE_NONINTERLACED;
905
906 fbinfo->fbops = &s3c2410fb_ops;
907 fbinfo->flags = FBINFO_FLAG_DEFAULT;
908 fbinfo->pseudo_palette = &info->pseudo_pal;
909
910 for (i = 0; i < 256; i++)
911 info->palette_buffer[i] = PALETTE_BUFF_CLEAR;
912
913 ret = request_irq(irq, s3c2410fb_irq, IRQF_DISABLED, pdev->name, info);
914 if (ret) {
915 dev_err(&pdev->dev, "cann