diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c index 5e569bc..c866043 100644 --- a/arch/arm/boards/chumby_falconwing/falconwing.c +++ b/arch/arm/boards/chumby_falconwing/falconwing.c @@ -83,7 +83,7 @@ .mode_list = &falconwing_vmode, .mode_cnt = 1, /* the NMA35 is a 24 bit display, but only 18 bits are connected */ - .ld_intf_width = STMLCDIF_18BIT, + .ld_intf_width = 18, .enable = chumby_fb_enable, .fixed_screen = (void *)(0x40000000 + SZ_64M - MAX_FB_SIZE), .fixed_screen_size = MAX_FB_SIZE, diff --git a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c index d77a6c7..fc12375 100644 --- a/arch/arm/boards/freescale-mx28-evk/mx28-evk.c +++ b/arch/arm/boards/freescale-mx28-evk/mx28-evk.c @@ -226,7 +226,7 @@ .mode_list = mx28_evk_vmodes, .mode_cnt = ARRAY_SIZE(mx28_evk_vmodes), .dotclk_delay = 0, /* no adaption required */ - .ld_intf_width = STMLCDIF_24BIT, /* full 24 bit */ + .ld_intf_width = 24, .bits_per_pixel = 32, .fixed_screen = NULL, .enable = mx28_evk_fb_enable, diff --git a/arch/arm/boards/karo-tx28/tx28-stk5.c b/arch/arm/boards/karo-tx28/tx28-stk5.c index 9b86d1c..d67607b 100644 --- a/arch/arm/boards/karo-tx28/tx28-stk5.c +++ b/arch/arm/boards/karo-tx28/tx28-stk5.c @@ -195,7 +195,7 @@ .mode_list = tx28evk_vmodes, .mode_cnt = ARRAY_SIZE(tx28evk_vmodes), .dotclk_delay = 0, /* no adaption required */ - .ld_intf_width = STMLCDIF_24BIT, /* full 24 bit */ + .ld_intf_width = 24, .fixed_screen = (void *)(0x40000000 + SZ_128M - MAX_FB_SIZE), .fixed_screen_size = MAX_FB_SIZE, .enable = tx28_fb_enable, diff --git a/arch/arm/mach-mxs/include/mach/fb.h b/arch/arm/mach-mxs/include/mach/fb.h index 2b6825f..ad28f79 100644 --- a/arch/arm/mach-mxs/include/mach/fb.h +++ b/arch/arm/mach-mxs/include/mach/fb.h @@ -15,11 +15,6 @@ #include -#define STMLCDIF_8BIT 1 /** pixel data bus to the display is of 8 bit width */ -#define STMLCDIF_16BIT 0 /** pixel data bus to the display is of 16 bit width */ -#define STMLCDIF_18BIT 2 /** pixel data bus to the display is of 18 bit width */ -#define STMLCDIF_24BIT 3 /** pixel data bus to the display is of 24 bit width */ - /** LC display uses active high data enable signal */ #define FB_SYNC_DE_HIGH_ACT (1 << 27) /** LC display will latch its data at clock's rising edge */ @@ -38,7 +33,7 @@ unsigned mode_cnt; unsigned dotclk_delay; /**< refer manual HW_LCDIF_VDCTRL4 register */ - unsigned ld_intf_width; /**< refer STMLCDIF_* macros */ + unsigned ld_intf_width; /* interface width in bits */ unsigned bits_per_pixel; void *fixed_screen; /**< if != NULL use this as framebuffer memory */ diff --git a/drivers/video/fb.c b/drivers/video/fb.c index a4f1734..29b4c71 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -122,6 +122,27 @@ return 0; } +static int fb_of_reserve_fixup(struct device_node *root, void *context) +{ + struct fb_info *info = context; + + if (!info->enabled) + return 0; + + of_add_reserve_entry((unsigned long)info->screen_base, + (unsigned long)info->screen_base + info->screen_size); + + return 0; +} + +void fb_of_reserve_add_fixup(struct fb_info *info) +{ + if (!IS_ENABLED(CONFIG_OFDEVICE)) + return; + + of_register_fixup(fb_of_reserve_fixup, info); +} + static int fb_set_modename(struct param_d *param, void *priv) { struct fb_info *info = priv; diff --git a/drivers/video/stm.c b/drivers/video/stm.c index bf913f1..1b42a18 100644 --- a/drivers/video/stm.c +++ b/drivers/video/stm.c @@ -24,6 +24,8 @@ #include #include #include +#include +#include #include #include #include @@ -36,7 +38,10 @@ # define CTRL_VSYNC_MODE (1 << 18) # define CTRL_DOTCLK_MODE (1 << 17) # define CTRL_DATA_SELECT (1 << 16) -# define SET_BUS_WIDTH(x) (((x) & 0x3) << 10) +# define CTRL_BUS_WIDTH_8 (1 << 10) +# define CTRL_BUS_WIDTH_16 (0 << 10) +# define CTRL_BUS_WIDTH_18 (2 << 10) +# define CTRL_BUS_WIDTH_24 (3 << 10) # define SET_WORD_LENGTH(x) (((x) & 0x3) << 8) # define GET_WORD_LENGTH(x) (((x) >> 8) & 0x3) # define CTRL_MASTER (1 << 5) @@ -144,8 +149,13 @@ unsigned memory_size; struct fb_info info; struct device_d *hw_dev; - struct imx_fb_platformdata *pdata; struct clk *clk; + void *fixed_screen; + unsigned fixed_screen_size; + unsigned flags; + unsigned ld_intf_width; + void (*enable)(int enable); + unsigned dotclk_delay; }; /* the RGB565 true colour mode */ @@ -258,14 +268,14 @@ writel(CTRL1_FIFO_CLEAR, fbi->base + HW_LCDIF_CTRL1 + STMP_OFFSET_REG_CLR); /* enable LCD using LCD_RESET signal*/ - if (fbi->pdata->flags & USE_LCD_RESET) + if (fbi->flags & USE_LCD_RESET) writel(CTRL1_RESET, fbi->base + HW_LCDIF_CTRL1 + STMP_OFFSET_REG_SET); /* start the engine right now */ writel(CTRL_RUN, fbi->base + HW_LCDIF_CTRL + STMP_OFFSET_REG_SET); - if (fbi->pdata->enable) - fbi->pdata->enable(1); + if (fbi->enable) + fbi->enable(1); } static void stmfb_disable_controller(struct fb_info *fb_info) @@ -276,11 +286,11 @@ /* disable LCD using LCD_RESET signal*/ - if (fbi->pdata->flags & USE_LCD_RESET) + if (fbi->flags & USE_LCD_RESET) writel(CTRL1_RESET, fbi->base + HW_LCDIF_CTRL1 + STMP_OFFSET_REG_CLR); - if (fbi->pdata->enable) - fbi->pdata->enable(0); + if (fbi->enable) + fbi->enable(0); /* * Even if we disable the controller here, it will still continue @@ -306,7 +316,6 @@ static int stmfb_activate_var(struct fb_info *fb_info) { struct imxfb_info *fbi = fb_info->priv; - struct imx_fb_platformdata *pdata = fbi->pdata; struct fb_videomode *mode = fb_info->mode; uint32_t reg; unsigned size; @@ -317,13 +326,18 @@ size = calc_line_length(mode->xres, fb_info->bits_per_pixel) * mode->yres; - if (pdata && pdata->fixed_screen) { - if (pdata->fixed_screen_size < size) + if (fbi->fixed_screen) { + if (fbi->fixed_screen_size < size) return -ENOMEM; - fb_info->screen_base = pdata->fixed_screen; - fbi->memory_size = pdata->fixed_screen_size; + fb_info->screen_base = fbi->fixed_screen; + fbi->memory_size = fbi->fixed_screen_size; + remap_range(fbi->fixed_screen, + fbi->fixed_screen_size, + mmu_get_pte_uncached_flags()); } else { - fb_info->screen_base = xrealloc(fb_info->screen_base, size); + fb_info->screen_base = dma_alloc_coherent(size, NULL); + if (!fb_info->screen_base) + return -ENOMEM; fbi->memory_size = size; } @@ -349,7 +363,25 @@ /* * Configure videomode and interface mode */ - reg |= SET_BUS_WIDTH(pdata->ld_intf_width); + switch (fbi->ld_intf_width) { + case 8: + reg |= CTRL_BUS_WIDTH_8; + break; + case 16: + reg |= CTRL_BUS_WIDTH_16; + break; + case 18: + reg |= CTRL_BUS_WIDTH_18; + break; + case 24: + reg |= CTRL_BUS_WIDTH_24; + break; + default: + dev_err(fbi->hw_dev, "Unsupported interface width %d\n", + fbi->ld_intf_width); + return -EINVAL; + } + switch (fb_info->bits_per_pixel) { case 8: reg |= SET_WORD_LENGTH(1); @@ -370,13 +402,14 @@ case 32: pr_debug("Setting up an RGB888/666 mode\n"); reg |= SET_WORD_LENGTH(3); - switch (pdata->ld_intf_width) { - case STMLCDIF_8BIT: + + switch (fbi->ld_intf_width) { + case 8: dev_dbg(fbi->hw_dev, "Unsupported LCD bus width mapping\n"); break; - case STMLCDIF_16BIT: - case STMLCDIF_18BIT: + case 16: + case 18: /* 24 bit to 18 bit mapping * which means: ignore the upper 2 bits in * each colour component @@ -387,7 +420,7 @@ fb_info->blue = def_rgb666[BLUE]; fb_info->transp = def_rgb666[TRANSP]; break; - case STMLCDIF_24BIT: + case 24: /* real 24 bit */ fb_info->red = def_rgb888[RED]; fb_info->green = def_rgb888[GREEN]; @@ -416,9 +449,11 @@ reg |= VDCTRL0_HSYNC_POL; if (mode->sync & FB_SYNC_VERT_HIGH_ACT) reg |= VDCTRL0_VSYNC_POL; - if (mode->sync & FB_SYNC_DE_HIGH_ACT) + if (mode->sync & FB_SYNC_DE_HIGH_ACT || + mode->display_flags & DISPLAY_FLAGS_DE_LOW) reg |= VDCTRL0_ENABLE_POL; - if (mode->sync & FB_SYNC_CLK_INVERT) + if (mode->sync & FB_SYNC_CLK_INVERT || + mode->display_flags & DISPLAY_FLAGS_PIXDATA_NEGEDGE) reg |= VDCTRL0_DOTCLK_POL; reg |= SET_VSYNC_PULSE_WIDTH(mode->vsync_len); @@ -442,7 +477,7 @@ writel( #ifdef CONFIG_ARCH_IMX28 - SET_DOTCLK_DLY(pdata->dotclk_delay) | + SET_DOTCLK_DLY(fbi->dotclk_delay) | #endif SET_DOTCLK_H_VALID_DATA_CNT(mode->xres), fbi->base + HW_LCDIF_VDCTRL4); @@ -453,17 +488,6 @@ return 0; } -static void stmfb_info(struct device_d *hw_dev) -{ - struct imx_fb_platformdata *pdata = hw_dev->platform_data; - unsigned u; - - printf(" Supported video modes:\n"); - for (u = 0; u < pdata->mode_cnt; u++) - printf(" - '%s': %u x %u\n", pdata->mode_list[u].name, - pdata->mode_list[u].xres, pdata->mode_list[u].yres); -} - /* * There is only one video hardware instance available. * It makes no sense to dynamically allocate this data @@ -491,7 +515,6 @@ /* add runtime hardware info */ fbi.hw_dev = hw_dev; fbi.base = dev_request_mem_region(hw_dev, 0); - fbi.pdata = pdata; fbi.clk = clk_get(hw_dev, NULL); if (IS_ERR(fbi.clk)) return PTR_ERR(fbi.clk); @@ -504,6 +527,11 @@ fbi.info.modes.modes = pdata->mode_list; fbi.info.modes.num_modes = pdata->mode_cnt; fbi.info.mode = &fbi.info.modes.modes[0]; + fbi.flags = pdata->flags; + fbi.enable = pdata->enable; + fbi.fixed_screen = pdata->fixed_screen; + fbi.fixed_screen_size = pdata->fixed_screen_size; + fbi.ld_intf_width = pdata->ld_intf_width; if (pdata->bits_per_pixel) fbi.info.bits_per_pixel = pdata->bits_per_pixel; } else { @@ -527,9 +555,18 @@ fbi.info.modes.modes = modes->modes; fbi.info.modes.num_modes = modes->num_modes; + + ret = of_property_read_u32(display, "bus-width", &fbi.ld_intf_width); + if (ret < 0) { + dev_err(hw_dev, "failed to get bus-width property\n"); + return -EINVAL; + } + + of_property_read_u32(display, "bits-per-pixel", + &fbi.info.bits_per_pixel); } - hw_dev->info = stmfb_info; + fb_of_reserve_add_fixup(&fbi.info); ret = register_framebuffer(&fbi.info); if (ret != 0) { diff --git a/include/fb.h b/include/fb.h index 27894db..d0bab48 100644 --- a/include/fb.h +++ b/include/fb.h @@ -162,6 +162,7 @@ int edid_to_display_timings(struct display_timings *, unsigned char *edid); void *edid_read_i2c(struct i2c_adapter *adapter); void fb_edid_add_modes(struct fb_info *info); +void fb_of_reserve_add_fixup(struct fb_info *info); int register_fbconsole(struct fb_info *fb);