diff options
Diffstat (limited to 'drivers/video')
43 files changed, 436 insertions, 600 deletions
diff --git a/drivers/video/console/newport_con.c b/drivers/video/console/newport_con.c index a6ab9299813c..bb4e96255974 100644 --- a/drivers/video/console/newport_con.c +++ b/drivers/video/console/newport_con.c @@ -687,7 +687,7 @@ static int newport_scroll(struct vc_data *vc, int t, int b, int dir, static void newport_bmove(struct vc_data *vc, int sy, int sx, int dy, int dx, int h, int w) { - short xs, ys, xe, ye, xoffs, yoffs, tmp; + short xs, ys, xe, ye, xoffs, yoffs; xs = sx << 3; xe = ((sx + w) << 3) - 1; @@ -701,9 +701,7 @@ static void newport_bmove(struct vc_data *vc, int sy, int sx, int dy, yoffs = (dy - sy) << 4; if (xoffs > 0) { /* move to the right, exchange starting points */ - tmp = xe; - xe = xs; - xs = tmp; + swap(xe, xs); } newport_wait(npregs); npregs->set.drawmode0 = (NPORT_DMODE0_S2S | NPORT_DMODE0_BLOCK | diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig index 109462303087..54fb8f86b68d 100644 --- a/drivers/video/fbdev/Kconfig +++ b/drivers/video/fbdev/Kconfig @@ -2478,6 +2478,7 @@ config FB_SSD1307 select FB_SYS_IMAGEBLIT select FB_DEFERRED_IO select PWM + select FB_BACKLIGHT help This driver implements support for the Solomon SSD1307 OLED controller over I2C. diff --git a/drivers/video/fbdev/amifb.c b/drivers/video/fbdev/amifb.c index 35f7900a0573..a171bd93eb6a 100644 --- a/drivers/video/fbdev/amifb.c +++ b/drivers/video/fbdev/amifb.c @@ -2052,7 +2052,7 @@ static void ami_set_sprite(const struct amifb_par *par) { copins *copl, *cops; u_short hs, vs, ve; - u_long pl, ps, pt; + u_long pl, ps; short mx, my; cops = copdisplay.list[currentcop][0]; @@ -2078,7 +2078,7 @@ static void ami_set_sprite(const struct amifb_par *par) if (mod2(vs)) { lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve); shfsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs + 1, hs, ve + 1); - pt = pl; pl = ps; ps = pt; + swap(pl, ps); } else { lofsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs, hs, ve + 1); shfsprite[1 << par->crsr.fmode] = spr2hw_ctl(vs + 1, hs, ve); diff --git a/drivers/video/fbdev/atmel_lcdfb.c b/drivers/video/fbdev/atmel_lcdfb.c index 94a8d04e60f9..abadc490fa1f 100644 --- a/drivers/video/fbdev/atmel_lcdfb.c +++ b/drivers/video/fbdev/atmel_lcdfb.c @@ -1266,7 +1266,8 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) goto stop_clk; } - info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); + info->screen_base = ioremap_wc(info->fix.smem_start, + info->fix.smem_len); if (!info->screen_base) { ret = -ENOMEM; goto release_intmem; diff --git a/drivers/video/fbdev/aty/aty128fb.c b/drivers/video/fbdev/aty/aty128fb.c index 0156954bf340..c42ce2fdfd44 100644 --- a/drivers/video/fbdev/aty/aty128fb.c +++ b/drivers/video/fbdev/aty/aty128fb.c @@ -80,10 +80,6 @@ #include <asm/btext.h> #endif /* CONFIG_BOOTX_TEXT */ -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif - #include <video/aty128.h> /* Debug flag */ @@ -399,10 +395,7 @@ static int default_cmode = CMODE_8; static int default_crt_on = 0; static int default_lcd_on = 1; - -#ifdef CONFIG_MTRR static bool mtrr = true; -#endif #ifdef CONFIG_FB_ATY128_BACKLIGHT #ifdef CONFIG_PMAC_BACKLIGHT @@ -456,9 +449,7 @@ struct aty128fb_par { u32 vram_size; /* onboard video ram */ int chip_gen; const struct aty128_meminfo *mem; /* onboard mem info */ -#ifdef CONFIG_MTRR - struct { int vram; int vram_valid; } mtrr; -#endif + int wc_cookie; int blitter_may_be_busy; int fifo_slots; /* free slots in FIFO (64 max) */ @@ -1725,12 +1716,10 @@ static int aty128fb_setup(char *options) #endif continue; } -#ifdef CONFIG_MTRR if(!strncmp(this_opt, "nomtrr", 6)) { mtrr = 0; continue; } -#endif #ifdef CONFIG_PPC_PMAC /* vmode and cmode deprecated */ if (!strncmp(this_opt, "vmode:", 6)) { @@ -2133,7 +2122,7 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent) par->vram_size = aty_ld_le32(CNFG_MEMSIZE) & 0x03FFFFFF; /* Virtualize the framebuffer */ - info->screen_base = ioremap(fb_addr, par->vram_size); + info->screen_base = ioremap_wc(fb_addr, par->vram_size); if (!info->screen_base) goto err_unmap_out; @@ -2170,15 +2159,9 @@ static int aty128_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (!aty128_init(pdev, ent)) goto err_out; -#ifdef CONFIG_MTRR - if (mtrr) { - par->mtrr.vram = mtrr_add(info->fix.smem_start, - par->vram_size, MTRR_TYPE_WRCOMB, 1); - par->mtrr.vram_valid = 1; - /* let there be speed */ - printk(KERN_INFO "aty128fb: Rage128 MTRR set to ON\n"); - } -#endif /* CONFIG_MTRR */ + if (mtrr) + par->wc_cookie = arch_phys_wc_add(info->fix.smem_start, + par->vram_size); return 0; err_out: @@ -2212,11 +2195,7 @@ static void aty128_remove(struct pci_dev *pdev) aty128_bl_exit(info->bl_dev); #endif -#ifdef CONFIG_MTRR - if (par->mtrr.vram_valid) - mtrr_del(par->mtrr.vram, info->fix.smem_start, - par->vram_size); -#endif /* CONFIG_MTRR */ + arch_phys_wc_del(par->wc_cookie); iounmap(par->regbase); iounmap(info->screen_base); @@ -2625,8 +2604,5 @@ MODULE_DESCRIPTION("FBDev driver for ATI Rage128 / Pro cards"); MODULE_LICENSE("GPL"); module_param(mode_option, charp, 0); MODULE_PARM_DESC(mode_option, "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" "); -#ifdef CONFIG_MTRR module_param_named(nomtrr, mtrr, invbool, 0); MODULE_PARM_DESC(nomtrr, "bool: Disable MTRR support (0 or 1=disabled) (default=0)"); -#endif - diff --git a/drivers/video/fbdev/aty/radeon_base.c b/drivers/video/fbdev/aty/radeon_base.c index 01237c8fcdc6..2bdb070707e4 100644 --- a/drivers/video/fbdev/aty/radeon_base.c +++ b/drivers/video/fbdev/aty/radeon_base.c @@ -85,10 +85,6 @@ #endif /* CONFIG_PPC */ -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif - #include <video/radeon.h> #include <linux/radeonfb.h> @@ -271,9 +267,7 @@ static bool mirror = 0; static int panel_yres = 0; static bool force_dfp = 0; static bool force_measure_pll = 0; -#ifdef CONFIG_MTRR static bool nomtrr = 0; -#endif static bool force_sleep; static bool ignore_devlist; #ifdef CONFIG_PMAC_BACKLIGHT @@ -2260,8 +2254,8 @@ static int radeonfb_pci_register(struct pci_dev *pdev, rinfo->mapped_vram = min_t(unsigned long, MAX_MAPPED_VRAM, rinfo->video_ram); do { - rinfo->fb_base = ioremap (rinfo->fb_base_phys, - rinfo->mapped_vram); + rinfo->fb_base = ioremap_wc(rinfo->fb_base_phys, + rinfo->mapped_vram); } while (rinfo->fb_base == NULL && ((rinfo->mapped_vram /= 2) >= MIN_MAPPED_VRAM)); @@ -2359,11 +2353,9 @@ static int radeonfb_pci_register(struct pci_dev *pdev, goto err_unmap_fb; } -#ifdef CONFIG_MTRR - rinfo->mtrr_hdl = nomtrr ? -1 : mtrr_add(rinfo->fb_base_phys, - rinfo->video_ram, - MTRR_TYPE_WRCOMB, 1); -#endif + if (!nomtrr) + rinfo->wc_cookie = arch_phys_wc_add(rinfo->fb_base_phys, + rinfo->video_ram); if (backlight) radeonfb_bl_init(rinfo); @@ -2428,12 +2420,7 @@ static void radeonfb_pci_unregister(struct pci_dev *pdev) #endif del_timer_sync(&rinfo->lvds_timer); - -#ifdef CONFIG_MTRR - if (rinfo->mtrr_hdl >= 0) - mtrr_del(rinfo->mtrr_hdl, 0, 0); -#endif - + arch_phys_wc_del(rinfo->wc_cookie); unregister_framebuffer(info); radeonfb_bl_exit(rinfo); @@ -2489,10 +2476,8 @@ static int __init radeonfb_setup (char *options) panel_yres = simple_strtoul((this_opt+11), NULL, 0); } else if (!strncmp(this_opt, "backlight:", 10)) { backlight = simple_strtoul(this_opt+10, NULL, 0); -#ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = 1; -#endif } else if (!strncmp(this_opt, "nomodeset", 9)) { nomodeset = 1; } else if (!strncmp(this_opt, "force_measure_pll", 17)) { @@ -2552,10 +2537,8 @@ module_param(monitor_layout, charp, 0); MODULE_PARM_DESC(monitor_layout, "Specify monitor mapping (like XFree86)"); module_param(force_measure_pll, bool, 0); MODULE_PARM_DESC(force_measure_pll, "Force measurement of PLL (debug)"); -#ifdef CONFIG_MTRR module_param(nomtrr, bool, 0); MODULE_PARM_DESC(nomtrr, "bool: disable use of MTRR registers"); -#endif module_param(panel_yres, int, 0); MODULE_PARM_DESC(panel_yres, "int: set panel yres"); module_param(mode_option, charp, 0); diff --git a/drivers/video/fbdev/aty/radeonfb.h b/drivers/video/fbdev/aty/radeonfb.h index 039def41c920..5bc1944ea1a9 100644 --- a/drivers/video/fbdev/aty/radeonfb.h +++ b/drivers/video/fbdev/aty/radeonfb.h @@ -340,7 +340,7 @@ struct radeonfb_info { struct pll_info pll; - int mtrr_hdl; + int wc_cookie; u32 save_regs[100]; int asleep; diff --git a/drivers/video/fbdev/core/Makefile b/drivers/video/fbdev/core/Makefile index 67f28e20a892..23d86a8b7d7b 100644 --- a/drivers/video/fbdev/core/Makefile +++ b/drivers/video/fbdev/core/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_FB_CMDLINE) += fb_cmdline.o obj-$(CONFIG_FB) += fb.o fb-y := fbmem.o fbmon.o fbcmap.o fbsysfs.o \ modedb.o fbcvt.o +fb-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o fb-objs := $(fb-y) obj-$(CONFIG_FB_CFB_FILLRECT) += cfbfillrect.o @@ -14,4 +15,3 @@ obj-$(CONFIG_FB_SYS_IMAGEBLIT) += sysimgblt.o obj-$(CONFIG_FB_SYS_FOPS) += fb_sys_fops.o obj-$(CONFIG_FB_SVGALIB) += svgalib.o obj-$(CONFIG_FB_DDC) += fb_ddc.o -obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index d6cab1fd9a47..3fc63c208d08 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c @@ -242,5 +242,3 @@ void fb_deferred_io_cleanup(struct fb_info *info) mutex_destroy(&fbdefio->lock); } EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup); - -MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index 01ef1b953390..d787533d9c8b 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c @@ -1475,7 +1475,9 @@ int of_get_fb_videomode(struct device_node *np, struct fb_videomode *fb, if (ret) return ret; - fb_videomode_from_videomode(&vm, fb); + ret = fb_videomode_from_videomode(&vm, fb); + if (ret) + return ret; pr_debug("%s: got %dx%d display mode from %s\n", of_node_full_name(np), vm.hactive, vm.vactive, np->name); diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c index 6d9ef39810c8..b63d55f481fa 100644 --- a/drivers/video/fbdev/gbefb.c +++ b/drivers/video/fbdev/gbefb.c @@ -22,9 +22,6 @@ #include <linux/module.h> #include <linux/io.h> -#ifdef CONFIG_X86 -#include <asm/mtrr.h> -#endif #ifdef CONFIG_MIPS #include <asm/addrspace.h> #endif @@ -38,6 +35,7 @@ static struct sgi_gbe *gbe; struct gbefb_par { struct fb_var_screeninfo var; struct gbe_timing_info timing; + int wc_cookie; int valid; }; @@ -1175,8 +1173,8 @@ static int gbefb_probe(struct platform_device *p_dev) if (gbe_mem_phys) { /* memory was allocated at boot time */ - gbe_mem = devm_ioremap_nocache(&p_dev->dev, gbe_mem_phys, - gbe_mem_size); + gbe_mem = devm_ioremap_wc(&p_dev->dev, gbe_mem_phys, + gbe_mem_size); if (!gbe_mem) { printk(KERN_ERR "gbefb: couldn't map framebuffer\n"); ret = -ENOMEM; @@ -1187,8 +1185,8 @@ static int gbefb_probe(struct platform_device *p_dev) } else { /* try to allocate memory with the classical allocator * this has high chance to fail on low memory machines */ - gbe_mem = dma_alloc_coherent(NULL, gbe_mem_size, &gbe_dma_addr, - GFP_KERNEL); + gbe_mem = dma_alloc_writecombine(NULL, gbe_mem_size, + &gbe_dma_addr, GFP_KERNEL); if (!gbe_mem) { printk(KERN_ERR "gbefb: couldn't allocate framebuffer memory\n"); ret = -ENOMEM; @@ -1198,9 +1196,8 @@ static int gbefb_probe(struct platform_device *p_dev) gbe_mem_phys = (unsigned long) gbe_dma_addr; } -#ifdef CONFIG_X86 - mtrr_add(gbe_mem_phys, gbe_mem_size, MTRR_TYPE_WRCOMB, 1); -#endif + par = info->par; + par->wc_cookie = arch_phys_wc_add(gbe_mem_phys, gbe_mem_size); /* map framebuffer memory into tiles table */ for (i = 0; i < (gbe_mem_size >> TILE_SHIFT); i++) @@ -1215,7 +1212,6 @@ static int gbefb_probe(struct platform_device *p_dev) /* reset GBE */ gbe_reset(); - par = info->par; /* turn on default video mode */ if (fb_find_mode(&par->var, info, mode_option, NULL, 0, default_mode, 8) == 0) @@ -1240,8 +1236,9 @@ static int gbefb_probe(struct platform_device *p_dev) return 0; out_gbe_unmap: + arch_phys_wc_del(par->wc_cookie); if (gbe_dma_addr) - dma_free_coherent(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys); + dma_free_writecombine(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys); out_tiles_free: dma_free_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t), (void *)gbe_tiles.cpu, gbe_tiles.dma); @@ -1256,11 +1253,13 @@ out_release_framebuffer: static int gbefb_remove(struct platform_device* p_dev) { struct fb_info *info = platform_get_drvdata(p_dev); + struct gbefb_par *par = info->par; unregister_framebuffer(info); gbe_turn_off(); + arch_phys_wc_del(par->wc_cookie); if (gbe_dma_addr) - dma_free_coherent(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys); + dma_free_writecombine(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys); dma_free_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t), (void *)gbe_tiles.cpu, gbe_tiles.dma); release_mem_region(GBE_BASE, sizeof(struct sgi_gbe)); diff --git a/drivers/video/fbdev/geode/gxfb_core.c b/drivers/video/fbdev/geode/gxfb_core.c index 124d7c7e2d14..ec9fc9ac23de 100644 --- a/drivers/video/fbdev/geode/gxfb_core.c +++ b/drivers/video/fbdev/geode/gxfb_core.c @@ -263,7 +263,8 @@ static int gxfb_map_video_memory(struct fb_info *info, struct pci_dev *dev) info->fix.smem_start = pci_resource_start(dev, 0); info->fix.smem_len = vram ? vram : gx_frame_buffer_size(); - info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); + info->screen_base = ioremap_wc(info->fix.smem_start, + info->fix.smem_len); if (!info->screen_base) return -ENOMEM; diff --git a/drivers/video/fbdev/i810/i810.h b/drivers/video/fbdev/i810/i810.h index 1414b73ac55b..7b1c002bfb08 100644 --- a/drivers/video/fbdev/i810/i810.h +++ b/drivers/video/fbdev/i810/i810.h @@ -199,7 +199,6 @@ #define HAS_FONTCACHE 8 /* driver flags */ -#define HAS_MTRR 1 #define HAS_ACCELERATION 2 #define ALWAYS_SYNC 4 #define LOCKUP 8 @@ -281,7 +280,7 @@ struct i810fb_par { u32 ovract; u32 cur_state; u32 ddc_num; - int mtrr_reg; + int wc_cookie; u16 bltcntl; u8 interlace; }; diff --git a/drivers/video/fbdev/i810/i810_main.c b/drivers/video/fbdev/i810/i810_main.c index bb674e431741..025b882a4826 100644 --- a/drivers/video/fbdev/i810/i810_main.c +++ b/drivers/video/fbdev/i810/i810_main.c @@ -41,6 +41,7 @@ #include <linux/resource.h> #include <linux/unistd.h> #include <linux/console.h> +#include <linux/io.h> #include <asm/io.h> #include <asm/div64.h> @@ -1816,7 +1817,9 @@ static void i810_init_device(struct i810fb_par *par) u8 reg; u8 __iomem *mmio = par->mmio_start_virtual; - if (mtrr) set_mtrr(par); + if (mtrr) + par->wc_cookie= arch_phys_wc_add((u32) par->aperture.physical, + par->aperture.size); i810_init_cursor(par); @@ -1865,8 +1868,8 @@ static int i810_allocate_pci_resource(struct i810fb_par *par, } par->res_flags |= FRAMEBUFFER_REQ; - par->aperture.virtual = ioremap_nocache(par->aperture.physical, - par->aperture.size); + par->aperture.virtual = ioremap_wc(par->aperture.physical, + par->aperture.size); if (!par->aperture.virtual) { printk("i810fb_init: cannot remap framebuffer region\n"); return -ENODEV; @@ -2096,7 +2099,7 @@ static void i810fb_release_resource(struct fb_info *info, struct i810fb_par *par) { struct gtt_data *gtt = &par->i810_gtt; - unset_mtrr(par); + arch_phys_wc_del(par->wc_cookie); i810_delete_i2c_busses(par); diff --git a/drivers/video/fbdev/i810/i810_main.h b/drivers/video/fbdev/i810/i810_main.h index a25afaa534ba..7bfaaad1d0fa 100644 --- a/drivers/video/fbdev/i810/i810_main.h +++ b/drivers/video/fbdev/i810/i810_main.h @@ -60,32 +60,6 @@ static inline void flush_cache(void) #define flush_cache() do { } while(0) #endif -#ifdef CONFIG_MTRR - -#include <asm/mtrr.h> - -static inline void set_mtrr(struct i810fb_par *par) -{ - par->mtrr_reg = mtrr_add((u32) par->aperture.physical, - par->aperture.size, MTRR_TYPE_WRCOMB, 1); - if (par->mtrr_reg < 0) { - printk(KERN_ERR "set_mtrr: unable to set MTRR\n"); - return; - } - par->dev_flags |= HAS_MTRR; -} -static inline void unset_mtrr(struct i810fb_par *par) -{ - if (par->dev_flags & HAS_MTRR) - mtrr_del(par->mtrr_reg, (u32) par->aperture.physical, - par->aperture.size); -} -#else -#define set_mtrr(x) printk("set_mtrr: MTRR is disabled in the kernel\n") - -#define unset_mtrr(x) do { } while (0) -#endif /* CONFIG_MTRR */ - #ifdef CONFIG_FB_I810_GTF #define IS_DVT (0) #else diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index 84d1d29e532c..cee88603efc9 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c @@ -170,7 +170,7 @@ struct imxfb_info { struct regulator *lcd_pwr; }; -static struct platform_device_id imxfb_devtype[] = { +static const struct platform_device_id imxfb_devtype[] = { { .name = "imx1-fb", .driver_data = IMX1_FB, diff --git a/drivers/video/fbdev/intelfb/intelfb.h b/drivers/video/fbdev/intelfb/intelfb.h index 6b51175629c7..37f8339ea88c 100644 --- a/drivers/video/fbdev/intelfb/intelfb.h +++ b/drivers/video/fbdev/intelfb/intelfb.h @@ -285,9 +285,7 @@ struct intelfb_info { /* use a gart reserved fb mem */ u8 fbmem_gart; - /* mtrr support */ - int mtrr_reg; - u32 has_mtrr; + int wc_cookie; /* heap data */ struct intelfb_heap_data aperture; diff --git a/drivers/video/fbdev/intelfb/intelfbdrv.c b/drivers/video/fbdev/intelfb/intelfbdrv.c index b847d530471a..bbec737eef30 100644 --- a/drivers/video/fbdev/intelfb/intelfbdrv.c +++ b/drivers/video/fbdev/intelfb/intelfbdrv.c @@ -124,10 +124,6 @@ #include <asm/io.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif - #include "intelfb.h" #include "intelfbhw.h" #include "../edid.h" @@ -411,33 +407,6 @@ module_init(intelfb_init); module_exit(intelfb_exit); /*************************************************************** - * mtrr support functions * - ***************************************************************/ - -#ifdef CONFIG_MTRR -static inline void set_mtrr(struct intelfb_info *dinfo) -{ - dinfo->mtrr_reg = mtrr_add(dinfo->aperture.physical, - dinfo->aperture.size, MTRR_TYPE_WRCOMB, 1); - if (dinfo->mtrr_reg < 0) { - ERR_MSG("unable to set MTRR\n"); - return; - } - dinfo->has_mtrr = 1; -} -static inline void unset_mtrr(struct intelfb_info *dinfo) -{ - if (dinfo->has_mtrr) - mtrr_del(dinfo->mtrr_reg, dinfo->aperture.physical, - dinfo->aperture.size); -} -#else -#define set_mtrr(x) WRN_MSG("MTRR is disabled in the kernel\n") - -#define unset_mtrr(x) do { } while (0) -#endif /* CONFIG_MTRR */ - -/*************************************************************** * driver init / cleanup * ***************************************************************/ @@ -456,7 +425,7 @@ static void cleanup(struct intelfb_info *dinfo) if (dinfo->registered) unregister_framebuffer(dinfo->info); - unset_mtrr(dinfo); + arch_phys_wc_del(dinfo->wc_cookie); if (dinfo->fbmem_gart && dinfo->gtt_fb_mem) { agp_unbind_memory(dinfo->gtt_fb_mem); @@ -675,7 +644,7 @@ static int intelfb_pci_register(struct pci_dev *pdev, /* Allocate memories (which aren't stolen) */ /* Map the fb and MMIO regions */ /* ioremap only up to the end of used aperture */ - dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache + dinfo->aperture.virtual = (u8 __iomem *)ioremap_wc (dinfo->aperture.physical, ((offset + dinfo->fb.offset) << 12) + dinfo->fb.size); if (!dinfo->aperture.virtual) { @@ -772,7 +741,8 @@ static int intelfb_pci_register(struct pci_dev *pdev, agp_backend_release(bridge); if (mtrr) - set_mtrr(dinfo); + dinfo->wc_cookie = arch_phys_wc_add(dinfo->aperture.physical, + dinfo->aperture.size); DBG_MSG("fb: 0x%x(+ 0x%x)/0x%x (0x%p)\n", dinfo->fb.physical, dinfo->fb.offset, dinfo->fb.size, diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c index 62539ca1cfa9..11eb094396ae 100644 --- a/drivers/video/fbdev/matrox/matroxfb_base.c +++ b/drivers/video/fbdev/matrox/matroxfb_base.c @@ -370,12 +370,9 @@ static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy) matroxfb_unregister_device(minfo); unregister_framebuffer(&minfo->fbcon); matroxfb_g450_shutdown(minfo); -#ifdef CONFIG_MTRR - if (minfo->mtrr.vram_valid) - mtrr_del(minfo->mtrr.vram, minfo->video.base, minfo->video.len); -#endif - mga_iounmap(minfo->mmio.vbase); - mga_iounmap(minfo->video.vbase); + arch_phys_wc_del(minfo->wc_cookie); + iounmap(minfo->mmio.vbase.vaddr); + iounmap(minfo->video.vbase.vaddr); release_mem_region(minfo->video.base, minfo->video.len_maximum); release_mem_region(minfo->mmio.base, 16384); kfree(minfo); @@ -591,12 +588,8 @@ static int matroxfb_decode_var(const struct matrox_fb_info *minfo, unsigned int max_yres; while (m1) { - int t; - while (m2 >= m1) m2 -= m1; - t = m1; - m1 = m2; - m2 = t; + swap(m1, m2); } m2 = linelen * PAGE_SIZE / m2; *ydstorg = m2 = 0x400000 % m2; @@ -1256,9 +1249,7 @@ static int nobios; /* "matroxfb:nobios" */ static int noinit = 1; /* "matroxfb:init" */ static int inverse; /* "matroxfb:inverse" */ static int sgram; /* "matroxfb:sgram" */ -#ifdef CONFIG_MTRR static int mtrr = 1; /* "matroxfb:nomtrr" */ -#endif static int grayscale; /* "matroxfb:grayscale" */ static int dev = -1; /* "matroxfb:dev:xxxxx" */ static unsigned int vesa = ~0; /* "matroxfb:vesa:xxxxx" */ @@ -1717,14 +1708,17 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b) if (mem && (mem < memsize)) memsize = mem; err = -ENOMEM; - if (mga_ioremap(ctrlptr_phys, 16384, MGA_IOREMAP_MMIO, &minfo->mmio.vbase)) { + + minfo->mmio.vbase.vaddr = ioremap_nocache(ctrlptr_phys, 16384); + if (!minfo->mmio.vbase.vaddr) { printk(KERN_ERR "matroxfb: cannot ioremap(%lX, 16384), matroxfb disabled\n", ctrlptr_phys); goto failVideoMR; } minfo->mmio.base = ctrlptr_phys; minfo->mmio.len = 16384; minfo->video.base = video_base_phys; - if (mga_ioremap(video_base_phys, memsize, MGA_IOREMAP_FB, &minfo->video.vbase)) { + minfo->video.vbase.vaddr = ioremap_wc(video_base_phys, memsize); + if (!minfo->video.vbase.vaddr) { printk(KERN_ERR "matroxfb: cannot ioremap(%lX, %d), matroxfb disabled\n", video_base_phys, memsize); goto failCtrlIO; @@ -1772,13 +1766,9 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b) minfo->video.len_usable = minfo->video.len; if (minfo->video.len_usable > b->base->maxdisplayable) minfo->video.len_usable = b->base->maxdisplayable; -#ifdef CONFIG_MTRR - if (mtrr) { - minfo->mtrr.vram = mtrr_add(video_base_phys, minfo->video.len, MTRR_TYPE_WRCOMB, 1); - minfo->mtrr.vram_valid = 1; - printk(KERN_INFO "matroxfb: MTRR's turned on\n"); - } -#endif /* CONFIG_MTRR */ + if (mtrr) + minfo->wc_cookie = arch_phys_wc_add(video_base_phys, + minfo->video.len); if (!minfo->devflags.novga) request_region(0x3C0, 32, "matrox"); @@ -1947,9 +1937,9 @@ static int initMatrox2(struct matrox_fb_info *minfo, struct board *b) return 0; failVideoIO:; matroxfb_g450_shutdown(minfo); - mga_iounmap(minfo->video.vbase); + iounmap(minfo->video.vbase.vaddr); failCtrlIO:; - mga_iounmap(minfo->mmio.vbase); + iounmap(minfo->mmio.vbase.vaddr); failVideoMR:; release_mem_region(video_base_phys, minfo->video.len_maximum); failCtrlMR:; @@ -2443,10 +2433,8 @@ static int __init matroxfb_setup(char *options) { nobios = !value; else if (!strcmp(this_opt, "init")) noinit = !value; -#ifdef CONFIG_MTRR else if (!strcmp(this_opt, "mtrr")) mtrr = value; -#endif else if (!strcmp(this_opt, "inv24")) inv24 = value; else if (!strcmp(this_opt, "cross4MB")) @@ -2515,10 +2503,8 @@ module_param(noinit, int, 0); MODULE_PARM_DESC(noinit, "Disables W/SG/SD-RAM and bus interface initialization (0 or 1=do not initialize) (default=0)"); module_param(memtype, int, 0); MODULE_PARM_DESC(memtype, "Memory type for G200/G400 (see Documentation/fb/matroxfb.txt for explanation) (default=3 for G200, 0 for G400)"); -#ifdef CONFIG_MTRR module_param(mtrr, int, 0); MODULE_PARM_DESC(mtrr, "This speeds up video memory accesses (0=disabled or 1) (default=1)"); -#endif module_param(sgram, int, 0); MODULE_PARM_DESC(sgram, "Indicates that G100/G200/G400 has SGRAM memory (0=SDRAM, 1=SGRAM) (default=0)"); module_param(inv24, int, 0); diff --git a/drivers/video/fbdev/matrox/matroxfb_base.h b/drivers/video/fbdev/matrox/matroxfb_base.h index 89a8a89a5eb2..09b02cd1eb0e 100644 --- a/drivers/video/fbdev/matrox/matroxfb_base.h +++ b/drivers/video/fbdev/matrox/matroxfb_base.h @@ -44,9 +44,6 @@ #include <asm/io.h> #include <asm/unaligned.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif #if defined(CONFIG_PPC_PMAC) #include <asm/prom.h> @@ -187,23 +184,6 @@ static inline void __iomem* vaddr_va(vaddr_t va) { return va.vaddr; } -#define MGA_IOREMAP_NORMAL 0 -#define MGA_IOREMAP_NOCACHE 1 - -#define MGA_IOREMAP_FB MGA_IOREMAP_NOCACHE -#define MGA_IOREMAP_MMIO MGA_IOREMAP_NOCACHE -static inline int mga_ioremap(unsigned long phys, unsigned long size, int flags, vaddr_t* virt) { - if (flags & MGA_IOREMAP_NOCACHE) - virt->vaddr = ioremap_nocache(phys, size); - else - virt->vaddr = ioremap(phys, size); - return (virt->vaddr == NULL); /* 0, !0... 0, error_code in future */ -} - -static inline void mga_iounmap(vaddr_t va) { - iounmap(va.vaddr); -} - struct my_timming { unsigned int pixclock; int mnp; @@ -449,12 +429,7 @@ struct matrox_fb_info { int plnwt; int srcorg; } capable; -#ifdef CONFIG_MTRR - struct { - int vram; - int vram_valid; - } mtrr; -#endif + int wc_cookie; struct { int precise_width; int mga_24bpp_fix; diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index f8ac4a452f26..4e6608ceac09 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -316,6 +316,18 @@ static int mxsfb_check_var(struct fb_var_screeninfo *var, return 0; } +static inline void mxsfb_enable_axi_clk(struct mxsfb_info *host) +{ + if (host->clk_axi) + clk_prepare_enable(host->clk_axi); +} + +static inline void mxsfb_disable_axi_clk(struct mxsfb_info *host) +{ + if (host->clk_axi) + clk_disable_unprepare(host->clk_axi); +} + static void mxsfb_enable_controller(struct fb_info *fb_info) { struct mxsfb_info *host = to_imxfb_host(fb_info); @@ -333,14 +345,13 @@ static void mxsfb_enable_controller(struct fb_info *fb_info) } } - if (host->clk_axi) - clk_prepare_enable(host->clk_axi); - if (host->clk_disp_axi) clk_prepare_enable(host->clk_disp_axi); clk_prepare_enable(host->clk); clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U); + mxsfb_enable_axi_clk(host); + /* if it was disabled, re-enable the mode again */ writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_SET); @@ -380,11 +391,11 @@ static void mxsfb_disable_controller(struct fb_info *fb_info) reg = readl(host->base + LCDC_VDCTRL4); writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4); + mxsfb_disable_axi_clk(host); + clk_disable_unprepare(host->clk); if (host->clk_disp_axi) clk_disable_unprepare(host->clk_disp_axi); - if (host->clk_axi) - clk_disable_unprepare(host->clk_axi); host->enabled = 0; @@ -421,6 +432,8 @@ static int mxsfb_set_par(struct fb_info *fb_info) mxsfb_disable_controller(fb_info); } + mxsfb_enable_axi_clk(host); + /* clear the FIFOs */ writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET); @@ -438,6 +451,7 @@ static int mxsfb_set_par(struct fb_info *fb_info) ctrl |= CTRL_SET_WORD_LENGTH(3); switch (host->ld_intf_width) { case STMLCDIF_8BIT: + mxsfb_disable_axi_clk(host); dev_err(&host->pdev->dev, "Unsupported LCD bus width mapping\n"); return -EINVAL; @@ -451,6 +465,7 @@ static int mxsfb_set_par(struct fb_info *fb_info) writel(CTRL1_SET_BYTE_PACKAGING(0x7), host->base + LCDC_CTRL1); break; default: + mxsfb_disable_axi_clk(host); dev_err(&host->pdev->dev, "Unhandled color depth of %u\n", fb_info->var.bits_per_pixel); return -EINVAL; @@ -504,6 +519,8 @@ static int mxsfb_set_par(struct fb_info *fb_info) fb_info->fix.line_length * fb_info->var.yoffset, host->base + host->devdata->next_buf); + mxsfb_disable_axi_clk(host); + if (reenable) mxsfb_enable_controller(fb_info); @@ -582,10 +599,14 @@ static int mxsfb_pan_display(struct fb_var_screeninfo *var, offset = fb_info->fix.line_length * var->yoffset; + mxsfb_enable_axi_clk(host); + /* update on next VSYNC */ writel(fb_info->fix.smem_start + offset, host->base + host->devdata->next_buf); + mxsfb_disable_axi_clk(host); + return 0; } @@ -608,13 +629,17 @@ static int mxsfb_restore_mode(struct mxsfb_info *host, unsigned line_count; unsigned period; unsigned long pa, fbsize; - int bits_per_pixel, ofs; + int bits_per_pixel, ofs, ret = 0; u32 transfer_count, vdctrl0, vdctrl2, vdctrl3, vdctrl4, ctrl; + mxsfb_enable_axi_clk(host); + /* Only restore the mode when the controller is running */ ctrl = readl(host->base + LCDC_CTRL); - if (!(ctrl & CTRL_RUN)) - return -EINVAL; + if (!(ctrl & CTRL_RUN)) { + ret = -EINVAL; + goto err; + } vdctrl0 = readl(host->base + LCDC_VDCTRL0); vdctrl2 = readl(host->base + LCDC_VDCTRL2); @@ -635,7 +660,8 @@ static int mxsfb_restore_mode(struct mxsfb_info *host, break; case 1: default: - return -EINVAL; + ret = -EINVAL; + goto err; } fb_info->var.bits_per_pixel = bits_per_pixel; @@ -673,10 +699,14 @@ static int mxsfb_restore_mode(struct mxsfb_info *host, pa = readl(host->base + host->devdata->cur_buf); fbsize = fb_info->fix.line_length * vmode->yres; - if (pa < fb_info->fix.smem_start) - return -EINVAL; - if (pa + fbsize > fb_info->fix.smem_start + fb_info->fix.smem_len) - return -EINVAL; + if (pa < fb_info->fix.smem_start) { + ret = -EINVAL; + goto err; + } + if (pa + fbsize > fb_info->fix.smem_start + fb_info->fix.smem_len) { + ret = -EINVAL; + goto err; + } ofs = pa - fb_info->fix.smem_start; if (ofs) { memmove(fb_info->screen_base, fb_info->screen_base + ofs, fbsize); @@ -689,7 +719,11 @@ static int mxsfb_restore_mode(struct mxsfb_info *host, clk_prepare_enable(host->clk); host->enabled = 1; - return 0; +err: + if (ret) + mxsfb_disable_axi_clk(host); + + return ret; } static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host, @@ -814,7 +848,7 @@ static void mxsfb_free_videomem(struct mxsfb_info *host) free_pages_exact(fb_info->screen_base, fb_info->fix.smem_len); } -static struct platform_device_id mxsfb_devtype[] = { +static const struct platform_device_id mxsfb_devtype[] = { { .name = "imx23-fb", .driver_data = MXSFB_V3, @@ -915,7 +949,9 @@ static int mxsfb_probe(struct platform_device *pdev) } if (!host->enabled) { + mxsfb_enable_axi_clk(host); writel(0, host->base + LCDC_CTRL); + mxsfb_disable_axi_clk(host); mxsfb_set_par(fb_info); mxsfb_enable_controller(fb_info); } @@ -954,11 +990,15 @@ static void mxsfb_shutdown(struct platform_device *pdev) struct fb_info *fb_info = platform_get_drvdata(pdev); struct mxsfb_info *host = to_imxfb_host(fb_info); + mxsfb_enable_axi_clk(host); + /* * Force stop the LCD controller as keeping it running during reboot * might interfere with the BootROM's boot mode pads sampling. */ writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR); + + mxsfb_disable_axi_clk(host); } static struct platform_driver mxsfb_driver = { diff --git a/drivers/video/fbdev/neofb.c b/drivers/video/fbdev/neofb.c index 44f99a60bb9b..db023a97d1ea 100644 --- a/drivers/video/fbdev/neofb.c +++ b/drivers/video/fbdev/neofb.c @@ -71,11 +71,6 @@ #include <asm/io.h> #include <asm/irq.h> #include <asm/pgtable.h> - -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif - #include <video/vga.h> #include <video/neomagic.h> @@ -1710,6 +1705,7 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev, int video_len) { //unsigned long addr; + struct neofb_par *par = info->par; DBG("neo_map_video"); @@ -1723,7 +1719,7 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev, } info->screen_base = - ioremap(info->fix.smem_start, info->fix.smem_len); + ioremap_wc(info->fix.smem_start, info->fix.smem_len); if (!info->screen_base) { printk("neofb: unable to map screen memory\n"); release_mem_region(info->fix.smem_start, @@ -1733,11 +1729,8 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev, printk(KERN_INFO "neofb: mapped framebuffer at %p\n", info->screen_base); -#ifdef CONFIG_MTRR - ((struct neofb_par *)(info->par))->mtrr = - mtrr_add(info->fix.smem_start, pci_resource_len(dev, 0), - MTRR_TYPE_WRCOMB, 1); -#endif + par->wc_cookie = arch_phys_wc_add(info->fix.smem_start, + pci_resource_len(dev, 0)); /* Clear framebuffer, it's all white in memory after boot */ memset_io(info->screen_base, 0, info->fix.smem_len); @@ -1754,16 +1747,11 @@ static int neo_map_video(struct fb_info *info, struct pci_dev *dev, static void neo_unmap_video(struct fb_info *info) { - DBG("neo_unmap_video"); + struct neofb_par *par = info->par; -#ifdef CONFIG_MTRR - { - struct neofb_par *par = info->par; + DBG("neo_unmap_video"); - mtrr_del(par->mtrr, info->fix.smem_start, - info->fix.smem_len); - } -#endif + arch_phys_wc_del(par->wc_cookie); iounmap(info->screen_base); info->screen_base = NULL; diff --git a/drivers/video/fbdev/nvidia/nv_type.h b/drivers/video/fbdev/nvidia/nv_type.h index c03f7f55c76d..6ff321a36813 100644 --- a/drivers/video/fbdev/nvidia/nv_type.h +++ b/drivers/video/fbdev/nvidia/nv_type.h @@ -148,12 +148,7 @@ struct nvidia_par { u32 forceCRTC; u32 open_count; u8 DDCBase; -#ifdef CONFIG_MTRR - struct { - int vram; - int vram_valid; - } mtrr; -#endif + int wc_cookie; struct nvidia_i2c_chan chan[3]; volatile u32 __iomem *REGS; diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index 4273c6ee8cf6..ce7dab7299fe 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c @@ -21,9 +21,6 @@ #include <linux/pci.h> #include <linux/console.h> #include <linux/backlight.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif #ifdef CONFIG_BOOTX_TEXT #include <asm/btext.h> #endif @@ -76,9 +73,7 @@ static int paneltweak = 0; static int vram = 0; static int bpp = 8; static int reverse_i2c; -#ifdef CONFIG_MTRR static bool nomtrr = false; -#endif #ifdef CONFIG_PMAC_BACKLIGHT static int backlight = 1; #else @@ -1361,7 +1356,8 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent) par->ScratchBufferStart = par->FbUsableSize - par->ScratchBufferSize; par->CursorStart = par->FbUsableSize + (32 * 1024); - info->screen_base = ioremap(nvidiafb_fix.smem_start, par->FbMapSize); + info->screen_base = ioremap_wc(nvidiafb_fix.smem_start, + par->FbMapSize); info->screen_size = par->FbUsableSize; nvidiafb_fix.smem_len = par->RamAmountKBytes * 1024; @@ -1372,20 +1368,9 @@ static int nvidiafb_probe(struct pci_dev *pd, const struct pci_device_id *ent) par->FbStart = info->screen_base; -#ifdef CONFIG_MTRR - if (!nomtrr) { - par->mtrr.vram = mtrr_add(nvidiafb_fix.smem_start, - par->RamAmountKBytes * 1024, - MTRR_TYPE_WRCOMB, 1); - if (par->mtrr.vram < 0) { - printk(KERN_ERR PFX "unable to setup MTRR\n"); - } else { - par->mtrr.vram_valid = 1; - /* let there be speed */ - printk(KERN_INFO PFX "MTRR set to ON\n"); - } - } -#endif /* CONFIG_MTRR */ + if (!nomtrr) + par->wc_cookie = arch_phys_wc_add(nvidiafb_fix.smem_start, + par->RamAmountKBytes * 1024); info->fbops = &nvidia_fb_ops; info->fix = nvidiafb_fix; @@ -1443,13 +1428,7 @@ static void nvidiafb_remove(struct pci_dev *pd) unregister_framebuffer(info); nvidia_bl_exit(par); - -#ifdef CONFIG_MTRR - if (par->mtrr.vram_valid) - mtrr_del(par->mtrr.vram, info->fix.smem_start, - info->fix.smem_len); -#endif /* CONFIG_MTRR */ - + arch_phys_wc_del(par->wc_cookie); iounmap(info->screen_base); fb_destroy_modedb(info->monspecs.modedb); nvidia_delete_i2c_busses(par); @@ -1501,10 +1480,8 @@ static int nvidiafb_setup(char *options) vram = simple_strtoul(this_opt+5, NULL, 0); } else if (!strncmp(this_opt, "backlight:", 10)) { backlight = simple_strtoul(this_opt+10, NULL, 0); -#ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = true; -#endif } else if (!strncmp(this_opt, "fpdither:", 9)) { fpdither = simple_strtol(this_opt+9, NULL, 0); } else if (!strncmp(this_opt, "bpp:", 4)) { @@ -1592,11 +1569,9 @@ MODULE_PARM_DESC(bpp, "pixel width in bits" "(default=8)"); module_param(reverse_i2c, int, 0); MODULE_PARM_DESC(reverse_i2c, "reverse port assignment of the i2c bus"); -#ifdef CONFIG_MTRR module_param(nomtrr, bool, false); MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) " "(default=0)"); -#endif MODULE_AUTHOR("Antonino Daplas"); MODULE_DESCRIPTION("Framebuffer driver for nVidia graphics chipset"); diff --git a/drivers/video/fbdev/omap/Kconfig b/drivers/video/fbdev/omap/Kconfig index 18c4cb0d5690..29d250da8a3e 100644 --- a/drivers/video/fbdev/omap/Kconfig +++ b/drivers/video/fbdev/omap/Kconfig @@ -42,7 +42,7 @@ config FB_OMAP_LCD_MIPID config FB_OMAP_LCD_H3 bool "TPS65010 LCD controller on OMAP-H3" depends on MACH_OMAP_H3 - depends on TPS65010 + depends on TPS65010=y default y help Say Y here if you want to have support for the LCD on the diff --git a/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c index 84a6b3367124..a14d993f719d 100644 --- a/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c +++ b/drivers/video/fbdev/omap2/displays-new/encoder-opa362.c @@ -201,15 +201,9 @@ static int opa362_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ddata); - gpio = devm_gpiod_get(&pdev->dev, "enable"); - if (IS_ERR(gpio)) { - if (PTR_ERR(gpio) != -ENOENT) - return PTR_ERR(gpio); - - gpio = NULL; - } else { - gpiod_direction_output(gpio, 0); - } + gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); ddata->enable_gpio = gpio; diff --git a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c index eb8fd8140ad0..f7be3489f744 100644 --- a/drivers/video/fbdev/omap2/displays-new/panel-dpi.c +++ b/drivers/video/fbdev/omap2/displays-new/panel-dpi.c @@ -209,16 +209,9 @@ static int panel_dpi_probe_of(struct platform_device *pdev) struct videomode vm; struct gpio_desc *gpio; - gpio = devm_gpiod_get(&pdev->dev, "enable"); - - if (IS_ERR(gpio)) { - if (PTR_ERR(gpio) != -ENOENT) - return PTR_ERR(gpio); - else - gpio = NULL; - } else { - gpiod_direction_output(gpio, 0); - } + gpio = devm_gpiod_get_optional(&pdev->dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(gpio)) + return PTR_ERR(gpio); ddata->enable_gpio = gpio; diff --git a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c index 9974a37a11af..6a1b6a89a928 100644 --- a/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c +++ b/drivers/video/fbdev/omap2/displays-new/panel-lgphilips-lb035q02.c @@ -285,15 +285,14 @@ static int lb035q02_probe_of(struct spi_device *spi) struct omap_dss_device *in; struct gpio_desc *gpio; - gpio = devm_gpiod_get(&spi->dev, "enable"); + gpio = devm_gpiod_get(&spi->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(gpio)) { dev_err(&spi->dev, "failed to parse enable gpio\n"); return PTR_ERR(gpio); - } else { - gpiod_direction_output(gpio, 0); - ddata->enable_gpio = gpio; } + ddata->enable_gpio = gpio; + ddata->backlight_gpio = -ENOENT; in = omapdss_of_find_source_for_first_ep(node); diff --git a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c index eae263702964..abfd1f6e3327 100644 --- a/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c +++ b/drivers/video/fbdev/omap2/displays-new/panel-sharp-ls037v7dw01.c @@ -268,17 +268,12 @@ static int sharp_ls_get_gpio_of(struct device *dev, int index, int val, const char *desc, struct gpio_desc **gpiod) { struct gpio_desc *gd; - int r; *gpiod = NULL; - gd = devm_gpiod_get_index(dev, desc, index); + gd = devm_gpiod_get_index(dev, desc, index, GPIOD_OUT_LOW); if (IS_ERR(gd)) - return PTR_ERR(gd) == -ENOENT ? 0 : PTR_ERR(gd); - - r = gpiod_direction_output(gd, val); - if (r) - return r; + return PTR_ERR(gd); *gpiod = gd; return 0; diff --git a/drivers/video/fbdev/omap2/dss/display-sysfs.c b/drivers/video/fbdev/omap2/dss/display-sysfs.c index 12186557a9d4..6ad0991f8259 100644 --- a/drivers/video/fbdev/omap2/dss/display-sysfs.c +++ b/drivers/video/fbdev/omap2/dss/display-sysfs.c @@ -324,7 +324,7 @@ int display_init_sysfs(struct platform_device *pdev) for_each_dss_dev(dssdev) { r = kobject_init_and_add(&dssdev->kobj, &display_ktype, - &pdev->dev.kobj, dssdev->alias); + &pdev->dev.kobj, "%s", dssdev->alias); if (r) { DSSERR("failed to create sysfs files\n"); omap_dss_put_device(dssdev); diff --git a/drivers/video/fbdev/omap2/dss/hdmi4_core.c b/drivers/video/fbdev/omap2/dss/hdmi4_core.c index 7eafea5b8e19..fa72e735dad2 100644 --- a/drivers/video/fbdev/omap2/dss/hdmi4_core.c +++ b/drivers/video/fbdev/omap2/dss/hdmi4_core.c @@ -654,6 +654,13 @@ static void hdmi_core_audio_infoframe_cfg(struct hdmi_core_data *core, hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(2), info_aud->db3); sum += info_aud->db3; + /* + * The OMAP HDMI IP requires to use the 8-channel channel code when + * transmitting more than two channels. + */ + if (info_aud->db4_ca != 0x00) + info_aud->db4_ca = 0x13; + hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(3), info_aud->db4_ca); sum += info_aud->db4_ca; @@ -795,7 +802,9 @@ int hdmi4_audio_config(struct hdmi_core_data *core, struct hdmi_wp_data *wp, /* * the HDMI IP needs to enable four stereo channels when transmitting - * more than 2 audio channels + * more than 2 audio channels. Similarly, the channel count in the + * Audio InfoFrame has to match the sample_present bits (some channels + * are padded with zeroes) */ if (channel_count == 2) { audio_format.stereo_channels = HDMI_AUDIO_STEREO_ONECHANNEL; @@ -807,6 +816,7 @@ int hdmi4_audio_config(struct hdmi_core_data *core, struct hdmi_wp_data *wp, HDMI_AUDIO_I2S_SD1_EN | HDMI_AUDIO_I2S_SD2_EN | HDMI_AUDIO_I2S_SD3_EN; acore.layout = HDMI_AUDIO_LAYOUT_8CH; + audio->cea->db1_ct_cc = 7; } acore.en_spdif = false; diff --git a/drivers/video/fbdev/omap2/dss/hdmi5_core.c b/drivers/video/fbdev/omap2/dss/hdmi5_core.c index bfc0c4c297d6..8ea531d2652c 100644 --- a/drivers/video/fbdev/omap2/dss/hdmi5_core.c +++ b/drivers/video/fbdev/omap2/dss/hdmi5_core.c @@ -790,7 +790,9 @@ static void hdmi5_core_audio_infoframe_cfg(struct hdmi_core_data *core, hdmi_write_reg(base, HDMI_CORE_FC_AUDICONF1, info_aud->db2_sf_ss); hdmi_write_reg(base, HDMI_CORE_FC_AUDICONF2, info_aud->db4_ca); - hdmi_write_reg(base, HDMI_CORE_FC_AUDICONF3, info_aud->db5_dminh_lsv); + hdmi_write_reg(base, HDMI_CORE_FC_AUDICONF3, + (info_aud->db5_dminh_lsv & CEA861_AUDIO_INFOFRAME_DB5_DM_INH) >> 3 | + (info_aud->db5_dminh_lsv & CEA861_AUDIO_INFOFRAME_DB5_LSV)); } int hdmi5_audio_config(struct hdmi_core_data *core, struct hdmi_wp_data *wp, @@ -870,6 +872,7 @@ int hdmi5_audio_config(struct hdmi_core_data *core, struct hdmi_wp_data *wp, audio_format.samples_per_word = HDMI_AUDIO_ONEWORD_TWOSAMPLES; audio_format.sample_size = HDMI_AUDIO_SAMPLE_16BITS; audio_format.justification = HDMI_AUDIO_JUSTIFY_LEFT; + audio_format.sample_order = HDMI_AUDIO_SAMPLE_LEFT_FIRST; /* only LPCM atm */ audio_format.type = HDMI_AUDIO_TYPE_LPCM; diff --git a/drivers/video/fbdev/pm2fb.c b/drivers/video/fbdev/pm2fb.c index 3b85b647bc10..aa8d28880912 100644 --- a/drivers/video/fbdev/pm2fb.c +++ b/drivers/video/fbdev/pm2fb.c @@ -38,10 +38,6 @@ #include <linux/fb.h> #include <linux/init.h> #include <linux/pci.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif - #include <video/permedia2.h> #include <video/cvisionppc.h> @@ -81,10 +77,7 @@ static char *mode_option; static bool lowhsync; static bool lowvsync; static bool noaccel; -/* mtrr option */ -#ifdef CONFIG_MTRR static bool nomtrr; -#endif /* * The hardware state of the graphics card that isn't part of the @@ -100,7 +93,7 @@ struct pm2fb_par u32 mem_control; /* MemControl reg at probe */ u32 boot_address; /* BootAddress reg at probe */ u32 palette[16]; - int mtrr_handle; + int wc_cookie; }; /* @@ -1637,21 +1630,16 @@ static int pm2fb_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto err_exit_mmio; } info->screen_base = - ioremap_nocache(pm2fb_fix.smem_start, pm2fb_fix.smem_len); + ioremap_wc(pm2fb_fix.smem_start, pm2fb_fix.smem_len); if (!info->screen_base) { printk(KERN_WARNING "pm2fb: Can't ioremap smem area.\n"); release_mem_region(pm2fb_fix.smem_start, pm2fb_fix.smem_len); goto err_exit_mmio; } -#ifdef CONFIG_MTRR - default_par->mtrr_handle = -1; if (!nomtrr) - default_par->mtrr_handle = - mtrr_add(pm2fb_fix.smem_start, - pm2fb_fix.smem_len, - MTRR_TYPE_WRCOMB, 1); -#endif + default_par->wc_cookie = arch_phys_wc_add(pm2fb_fix.smem_start, + pm2fb_fix.smem_len); info->fbops = &pm2fb_ops; info->fix = pm2fb_fix; @@ -1733,12 +1721,7 @@ static void pm2fb_remove(struct pci_dev *pdev) struct pm2fb_par *par = info->par; unregister_framebuffer(info); - -#ifdef CONFIG_MTRR - if (par->mtrr_handle >= 0) - mtrr_del(par->mtrr_handle, info->fix.smem_start, - info->fix.smem_len); -#endif /* CONFIG_MTRR */ + arch_phys_wc_del(par->wc_cookie); iounmap(info->screen_base); release_mem_region(fix->smem_start, fix->smem_len); iounmap(par->v_regs); @@ -1791,10 +1774,8 @@ static int __init pm2fb_setup(char *options) lowvsync = 1; else if (!strncmp(this_opt, "hwcursor=", 9)) hwcursor = simple_strtoul(this_opt + 9, NULL, 0); -#ifdef CONFIG_MTRR else if (!strncmp(this_opt, "nomtrr", 6)) nomtrr = 1; -#endif else if (!strncmp(this_opt, "noaccel", 7)) noaccel = 1; else @@ -1847,10 +1828,8 @@ MODULE_PARM_DESC(noaccel, "Disable acceleration"); module_param(hwcursor, int, 0644); MODULE_PARM_DESC(hwcursor, "Enable hardware cursor " "(1=enable, 0=disable, default=1)"); -#ifdef CONFIG_MTRR module_param(nomtrr, bool, 0); MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)"); -#endif MODULE_AUTHOR("Jim Hague <jim.hague@acm.org>"); MODULE_DESCRIPTION("Permedia2 framebuffer device driver"); diff --git a/drivers/video/fbdev/pm3fb.c b/drivers/video/fbdev/pm3fb.c index 77b99ed39ad0..6ff5077a2e15 100644 --- a/drivers/video/fbdev/pm3fb.c +++ b/drivers/video/fbdev/pm3fb.c @@ -32,9 +32,6 @@ #include <linux/fb.h> #include <linux/init.h> #include <linux/pci.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif #include <video/pm3fb.h> @@ -58,11 +55,7 @@ static int hwcursor = 1; static char *mode_option; static bool noaccel; - -/* mtrr option */ -#ifdef CONFIG_MTRR static bool nomtrr; -#endif /* * This structure defines the hardware state of the graphics card. Normally @@ -76,7 +69,7 @@ struct pm3_par { u32 video; /* video flags before blanking */ u32 base; /* screen base in 128 bits unit */ u32 palette[16]; - int mtrr_handle; + int wc_cookie; }; /* @@ -1374,8 +1367,8 @@ static int pm3fb_probe(struct pci_dev *dev, const struct pci_device_id *ent) printk(KERN_WARNING "pm3fb: Can't reserve smem.\n"); goto err_exit_mmio; } - info->screen_base = - ioremap_nocache(pm3fb_fix.smem_start, pm3fb_fix.smem_len); + info->screen_base = ioremap_wc(pm3fb_fix.smem_start, + pm3fb_fix.smem_len); if (!info->screen_base) { printk(KERN_WARNING "pm3fb: Can't ioremap smem area.\n"); release_mem_region(pm3fb_fix.smem_start, pm3fb_fix.smem_len); @@ -1383,12 +1376,9 @@ static int pm3fb_probe(struct pci_dev *dev, const struct pci_device_id *ent) } info->screen_size = pm3fb_fix.smem_len; -#ifdef CONFIG_MTRR if (!nomtrr) - par->mtrr_handle = mtrr_add(pm3fb_fix.smem_start, - pm3fb_fix.smem_len, - MTRR_TYPE_WRCOMB, 1); -#endif + par->wc_cookie = arch_phys_wc_add(pm3fb_fix.smem_start, + pm3fb_fix.smem_len); info->fbops = &pm3fb_ops; par->video = PM3_READ_REG(par, PM3VideoControl); @@ -1478,11 +1468,7 @@ static void pm3fb_remove(struct pci_dev *dev) unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); -#ifdef CONFIG_MTRR - if (par->mtrr_handle >= 0) - mtrr_del(par->mtrr_handle, info->fix.smem_start, - info->fix.smem_len); -#endif /* CONFIG_MTRR */ + arch_phys_wc_del(par->wc_cookie); iounmap(info->screen_base); release_mem_region(fix->smem_start, fix->smem_len); iounmap(par->v_regs); @@ -1533,10 +1519,8 @@ static int __init pm3fb_setup(char *options) noaccel = 1; else if (!strncmp(this_opt, "hwcursor=", 9)) hwcursor = simple_strtoul(this_opt + 9, NULL, 0); -#ifdef CONFIG_MTRR else if (!strncmp(this_opt, "nomtrr", 6)) nomtrr = 1; -#endif else mode_option = this_opt; } @@ -1577,10 +1561,8 @@ MODULE_PARM_DESC(noaccel, "Disable acceleration"); module_param(hwcursor, int, 0644); MODULE_PARM_DESC(hwcursor, "Enable hardware cursor " "(1=enable, 0=disable, default=1)"); -#ifdef CONFIG_MTRR module_param(nomtrr, bool, 0); MODULE_PARM_DESC(nomtrr, "Disable MTRR support (0 or 1=disabled) (default=0)"); -#endif MODULE_DESCRIPTION("Permedia3 framebuffer device driver"); MODULE_LICENSE("GPL"); diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index 294a80908c8c..f1ad2747064b 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c @@ -41,9 +41,6 @@ #include <linux/pci.h> #include <linux/backlight.h> #include <linux/bitrev.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif #ifdef CONFIG_PMAC_BACKLIGHT #include <asm/machdep.h> #include <asm/backlight.h> @@ -204,9 +201,7 @@ MODULE_DEVICE_TABLE(pci, rivafb_pci_tbl); static int flatpanel = -1; /* Autodetect later */ static int forceCRTC = -1; static bool noaccel = 0; -#ifdef CONFIG_MTRR static bool nomtrr = 0; -#endif #ifdef CONFIG_PMAC_BACKLIGHT static int backlight = 1; #else @@ -2010,28 +2005,18 @@ static int rivafb_probe(struct pci_dev *pd, const struct pci_device_id *ent) rivafb_fix.smem_len = riva_get_memlen(default_par) * 1024; default_par->dclk_max = riva_get_maxdclk(default_par) * 1000; - info->screen_base = ioremap(rivafb_fix.smem_start, - rivafb_fix.smem_len); + info->screen_base = ioremap_wc(rivafb_fix.smem_start, + rivafb_fix.smem_len); if (!info->screen_base) { printk(KERN_ERR PFX "cannot ioremap FB base\n"); ret = -EIO; goto err_iounmap_pramin; } -#ifdef CONFIG_MTRR - if (!nomtrr) { - default_par->mtrr.vram = mtrr_add(rivafb_fix.smem_start, - rivafb_fix.smem_len, - MTRR_TYPE_WRCOMB, 1); - if (default_par->mtrr.vram < 0) { - printk(KERN_ERR PFX "unable to setup MTRR\n"); - } else { - default_par->mtrr.vram_valid = 1; - /* let there be speed */ - printk(KERN_INFO PFX "RIVA MTRR set to ON\n"); - } - } -#endif /* CONFIG_MTRR */ + if (!nomtrr) + default_par->wc_cookie = + arch_phys_wc_add(rivafb_fix.smem_start, + rivafb_fix.smem_len); info->fbops = &riva_fb_ops; info->fix = rivafb_fix; @@ -2105,13 +2090,7 @@ static void rivafb_remove(struct pci_dev *pd) unregister_framebuffer(info); riva_bl_exit(info); - -#ifdef CONFIG_MTRR - if (par->mtrr.vram_valid) - mtrr_del(par->mtrr.vram, info->fix.smem_start, - info->fix.smem_len); -#endif /* CONFIG_MTRR */ - + arch_phys_wc_del(par->wc_cookie); iounmap(par->ctrl_base); iounmap(info->screen_base); if (par->riva.Architecture == NV_ARCH_03) @@ -2150,10 +2129,8 @@ static int rivafb_setup(char *options) flatpanel = 1; } else if (!strncmp(this_opt, "backlight:", 10)) { backlight = simple_strtoul(this_opt+10, NULL, 0); -#ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = 1; -#endif } else if (!strncmp(this_opt, "strictmode", 10)) { strictmode = 1; } else if (!strncmp(this_opt, "noaccel", 7)) { @@ -2209,10 +2186,8 @@ module_param(flatpanel, int, 0); MODULE_PARM_DESC(flatpanel, "Enables experimental flat panel support for some chipsets. (0 or 1=enabled) (default=0)"); module_param(forceCRTC, int, 0); MODULE_PARM_DESC(forceCRTC, "Forces usage of a particular CRTC in case autodetection fails. (0 or 1) (default=autodetect)"); -#ifdef CONFIG_MTRR module_param(nomtrr, bool, 0); MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) (default=0)"); -#endif module_param(strictmode, bool, 0); MODULE_PARM_DESC(strictmode, "Only use video modes from EDID"); diff --git a/drivers/video/fbdev/riva/rivafb.h b/drivers/video/fbdev/riva/rivafb.h index d9f107b704c6..61fd37ca490a 100644 --- a/drivers/video/fbdev/riva/rivafb.h +++ b/drivers/video/fbdev/riva/rivafb.h @@ -61,9 +61,7 @@ struct riva_par { int FlatPanel; struct pci_dev *pdev; int cursor_reset; -#ifdef CONFIG_MTRR - struct { int vram; int vram_valid; } mtrr; -#endif + int wc_cookie; struct riva_i2c_chan chan[3]; }; diff --git a/drivers/video/fbdev/savage/savagefb.h b/drivers/video/fbdev/savage/savagefb.h index 8ff4ab1cb69b..aba04afe712d 100644 --- a/drivers/video/fbdev/savage/savagefb.h +++ b/drivers/video/fbdev/savage/savagefb.h @@ -213,9 +213,7 @@ struct savagefb_par { void __iomem *vbase; u32 pbase; u32 len; -#ifdef CONFIG_MTRR - int mtrr; -#endif + int wc_cookie; } video; struct { diff --git a/drivers/video/fbdev/savage/savagefb_driver.c b/drivers/video/fbdev/savage/savagefb_driver.c index 4dbf45f3b21a..6c77ab09b0b2 100644 --- a/drivers/video/fbdev/savage/savagefb_driver.c +++ b/drivers/video/fbdev/savage/savagefb_driver.c @@ -57,10 +57,6 @@ #include <asm/irq.h> #include <asm/pgtable.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif - #include "savagefb.h" @@ -1775,7 +1771,7 @@ static int savage_map_video(struct fb_info *info, int video_len) par->video.pbase = pci_resource_start(par->pcidev, resource); par->video.len = video_len; - par->video.vbase = ioremap(par->video.pbase, par->video.len); + par->video.vbase = ioremap_wc(par->video.pbase, par->video.len); if (!par->video.vbase) { printk("savagefb: unable to map screen memory\n"); @@ -1787,11 +1783,7 @@ static int savage_map_video(struct fb_info *info, int video_len) info->fix.smem_start = par->video.pbase; info->fix.smem_len = par->video.len - par->cob_size; info->screen_base = par->video.vbase; - -#ifdef CONFIG_MTRR - par->video.mtrr = mtrr_add(par->video.pbase, video_len, - MTRR_TYPE_WRCOMB, 1); -#endif + par->video.wc_cookie = arch_phys_wc_add(par->video.pbase, video_len); /* Clear framebuffer, it's all white in memory after boot */ memset_io(par->video.vbase, 0, par->video.len); @@ -1806,10 +1798,7 @@ static void savage_unmap_video(struct fb_info *info) DBG("savage_unmap_video"); if (par->video.vbase) { -#ifdef CONFIG_MTRR - mtrr_del(par->video.mtrr, par->video.pbase, par->video.len); -#endif - + arch_phys_wc_del(par->video.wc_cookie); iounmap(par->video.vbase); par->video.vbase = NULL; info->screen_base = NULL; diff --git a/drivers/video/fbdev/sis/sis.h b/drivers/video/fbdev/sis/sis.h index 1987f1b7212f..ea1d1c9640bf 100644 --- a/drivers/video/fbdev/sis/sis.h +++ b/drivers/video/fbdev/sis/sis.h @@ -458,7 +458,7 @@ struct sis_video_info { unsigned char *bios_abase; - int mtrr; + int wc_cookie; u32 sisfb_mem; diff --git a/drivers/video/fbdev/sis/sis_main.c b/drivers/video/fbdev/sis/sis_main.c index fcf610edf217..e92303823a4b 100644 --- a/drivers/video/fbdev/sis/sis_main.c +++ b/drivers/video/fbdev/sis/sis_main.c @@ -53,9 +53,6 @@ #include <linux/types.h> #include <linux/uaccess.h> #include <asm/io.h> -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#endif #include "sis.h" #include "sis_main.h" @@ -4130,13 +4127,13 @@ static void sisfb_post_map_vram(struct sis_video_info *ivideo, if (*mapsize < (min << 20)) return; - ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize)); + ivideo->video_vbase = ioremap_wc(ivideo->video_base, (*mapsize)); if(!ivideo->video_vbase) { printk(KERN_ERR "sisfb: Unable to map maximum video RAM for size detection\n"); (*mapsize) >>= 1; - while((!(ivideo->video_vbase = ioremap(ivideo->video_base, (*mapsize))))) { + while((!(ivideo->video_vbase = ioremap_wc(ivideo->video_base, (*mapsize))))) { (*mapsize) >>= 1; if((*mapsize) < (min << 20)) break; @@ -6186,7 +6183,7 @@ static int sisfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto error_2; } - ivideo->video_vbase = ioremap(ivideo->video_base, ivideo->video_size); + ivideo->video_vbase = ioremap_wc(ivideo->video_base, ivideo->video_size); ivideo->SiS_Pr.VideoMemoryAddress = ivideo->video_vbase; if(!ivideo->video_vbase) { printk(KERN_ERR "sisfb: Fatal error: Unable to map framebuffer memory\n"); @@ -6254,8 +6251,6 @@ error_3: vfree(ivideo->bios_abase); ivideo->SiS_Pr.VideoMemoryAddress += ivideo->video_offset; ivideo->SiS_Pr.VideoMemorySize = ivideo->sisfb_mem; - ivideo->mtrr = -1; - ivideo->vbflags = 0; ivideo->lcddefmodeidx = DEFAULT_LCDMODE; ivideo->tvdefmodeidx = DEFAULT_TVMODE; @@ -6443,14 +6438,8 @@ error_3: vfree(ivideo->bios_abase); printk(KERN_DEBUG "sisfb: Initial vbflags 0x%x\n", (int)ivideo->vbflags); -#ifdef CONFIG_MTRR - ivideo->mtrr = mtrr_add(ivideo->video_base, ivideo->video_size, - MTRR_TYPE_WRCOMB, 1); - if(ivideo->mtrr < 0) { - printk(KERN_DEBUG "sisfb: Failed to add MTRRs\n"); - } -#endif - + ivideo->wc_cookie = arch_phys_wc_add(ivideo->video_base, + ivideo->video_size); if(register_framebuffer(sis_fb_info) < 0) { printk(KERN_ERR "sisfb: Fatal error: Failed to register framebuffer\n"); ret = -EINVAL; @@ -6507,11 +6496,7 @@ static void sisfb_remove(struct pci_dev *pdev) pci_dev_put(ivideo->nbridge); -#ifdef CONFIG_MTRR - /* Release MTRR region */ - if(ivideo->mtrr >= 0) - mtrr_del(ivideo->mtrr, ivideo->video_base, ivideo->video_size); -#endif + arch_phys_wc_del(ivideo->wc_cookie); /* If device was disabled when starting, disable * it when quitting. diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index f7ed6d9016f7..3e153c06131a 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -7,6 +7,7 @@ */ #include <linux/module.h> +#include <linux/backlight.h> #include <linux/kernel.h> #include <linux/i2c.h> #include <linux/fb.h> @@ -38,22 +39,43 @@ #define SSD1307FB_SET_COM_PINS_CONFIG 0xda #define SSD1307FB_SET_VCOMH 0xdb +#define MAX_CONTRAST 255 + +#define REFRESHRATE 1 + +static u_int refreshrate = REFRESHRATE; +module_param(refreshrate, uint, 0); + struct ssd1307fb_par; -struct ssd1307fb_ops { - int (*init)(struct ssd1307fb_par *); - int (*remove)(struct ssd1307fb_par *); +struct ssd1307fb_deviceinfo { + u32 default_vcomh; + u32 default_dclk_div; + u32 default_dclk_frq; + int need_pwm; + int need_chargepump; }; struct ssd1307fb_par { + u32 com_invdir; + u32 com_lrremap; + u32 com_offset; + u32 com_seq; + u32 contrast; + u32 dclk_div; + u32 dclk_frq; + struct ssd1307fb_deviceinfo *device_info; struct i2c_client *client; u32 height; struct fb_info *info; - struct ssd1307fb_ops *ops; u32 page_offset; + u32 prechargep1; + u32 prechargep2; struct pwm_device *pwm; u32 pwm_period; int reset; + u32 seg_remap; + u32 vcomh; u32 width; }; @@ -213,6 +235,16 @@ static ssize_t ssd1307fb_write(struct fb_info *info, const char __user *buf, return count; } +static int ssd1307fb_blank(int blank_mode, struct fb_info *info) +{ + struct ssd1307fb_par *par = info->par; + + if (blank_mode != FB_BLANK_UNBLANK) + return ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF); + else + return ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); +} + static void ssd1307fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect) { struct ssd1307fb_par *par = info->par; @@ -238,6 +270,7 @@ static struct fb_ops ssd1307fb_ops = { .owner = THIS_MODULE, .fb_read = fb_sys_read, .fb_write = ssd1307fb_write, + .fb_blank = ssd1307fb_blank, .fb_fillrect = ssd1307fb_fillrect, .fb_copyarea = ssd1307fb_copyarea, .fb_imageblit = ssd1307fb_imageblit, @@ -249,74 +282,46 @@ static void ssd1307fb_deferred_io(struct fb_info *info, ssd1307fb_update_display(info->par); } -static struct fb_deferred_io ssd1307fb_defio = { - .delay = HZ, - .deferred_io = ssd1307fb_deferred_io, -}; - -static int ssd1307fb_ssd1307_init(struct ssd1307fb_par *par) +static int ssd1307fb_init(struct ssd1307fb_par *par) { int ret; + u32 precharge, dclk, com_invdir, compins; - par->pwm = pwm_get(&par->client->dev, NULL); - if (IS_ERR(par->pwm)) { - dev_err(&par->client->dev, "Could not get PWM from device tree!\n"); - return PTR_ERR(par->pwm); - } - - par->pwm_period = pwm_get_period(par->pwm); - /* Enable the PWM */ - pwm_config(par->pwm, par->pwm_period / 2, par->pwm_period); - pwm_enable(par->pwm); - - dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n", - par->pwm->pwm, par->pwm_period); - - /* Map column 127 of the OLED to segment 0 */ - ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON); - if (ret < 0) - return ret; - - /* Turn on the display */ - ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); - if (ret < 0) - return ret; - - return 0; -} - -static int ssd1307fb_ssd1307_remove(struct ssd1307fb_par *par) -{ - pwm_disable(par->pwm); - pwm_put(par->pwm); - return 0; -} + if (par->device_info->need_pwm) { + par->pwm = pwm_get(&par->client->dev, NULL); + if (IS_ERR(par->pwm)) { + dev_err(&par->client->dev, "Could not get PWM from device tree!\n"); + return PTR_ERR(par->pwm); + } -static struct ssd1307fb_ops ssd1307fb_ssd1307_ops = { - .init = ssd1307fb_ssd1307_init, - .remove = ssd1307fb_ssd1307_remove, -}; + par->pwm_period = pwm_get_period(par->pwm); + /* Enable the PWM */ + pwm_config(par->pwm, par->pwm_period / 2, par->pwm_period); + pwm_enable(par->pwm); -static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) -{ - int ret; + dev_dbg(&par->client->dev, "Using PWM%d with a %dns period.\n", + par->pwm->pwm, par->pwm_period); + }; /* Set initial contrast */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0x7f); - if (ret < 0) - return ret; - - /* Set COM direction */ - ret = ssd1307fb_write_cmd(par->client, 0xc8); + ret = ssd1307fb_write_cmd(par->client, par->contrast); if (ret < 0) return ret; /* Set segment re-map */ - ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON); + if (par->seg_remap) { + ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SEG_REMAP_ON); + if (ret < 0) + return ret; + }; + + /* Set COM direction */ + com_invdir = 0xc0 | (par->com_invdir & 0x1) << 3; + ret = ssd1307fb_write_cmd(par->client, com_invdir); if (ret < 0) return ret; @@ -334,7 +339,7 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0x20); + ret = ssd1307fb_write_cmd(par->client, par->com_offset); if (ret < 0) return ret; @@ -343,7 +348,8 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0xf0); + dclk = ((par->dclk_div - 1) & 0xf) | (par->dclk_frq & 0xf) << 4; + ret = ssd1307fb_write_cmd(par->client, dclk); if (ret < 0) return ret; @@ -352,7 +358,8 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0x22); + precharge = (par->prechargep1 & 0xf) | (par->prechargep2 & 0xf) << 4; + ret = ssd1307fb_write_cmd(par->client, precharge); if (ret < 0) return ret; @@ -361,7 +368,9 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0x22); + compins = 0x02 | !(par->com_seq & 0x1) << 4 + | (par->com_lrremap & 0x1) << 5; + ret = ssd1307fb_write_cmd(par->client, compins); if (ret < 0) return ret; @@ -370,7 +379,7 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0x49); + ret = ssd1307fb_write_cmd(par->client, par->vcomh); if (ret < 0) return ret; @@ -379,7 +388,8 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; - ret = ssd1307fb_write_cmd(par->client, 0x14); + ret = ssd1307fb_write_cmd(par->client, + (par->device_info->need_chargepump & 0x1 << 2) & 0x14); if (ret < 0) return ret; @@ -393,6 +403,7 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; + /* Set column range */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_COL_RANGE); if (ret < 0) return ret; @@ -405,6 +416,7 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) if (ret < 0) return ret; + /* Set page range */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PAGE_RANGE); if (ret < 0) return ret; @@ -426,18 +438,75 @@ static int ssd1307fb_ssd1306_init(struct ssd1307fb_par *par) return 0; } -static struct ssd1307fb_ops ssd1307fb_ssd1306_ops = { - .init = ssd1307fb_ssd1306_init, +static int ssd1307fb_update_bl(struct backlight_device *bdev) +{ + struct ssd1307fb_par *par = bl_get_data(bdev); + int ret; + int brightness = bdev->props.brightness; + + par->contrast = brightness; + + ret = ssd1307fb_write_cmd(par->client, SSD1307FB_CONTRAST); + if (ret < 0) + return ret; + ret = ssd1307fb_write_cmd(par->client, par->contrast); + if (ret < 0) + return ret; + return 0; +} + +static int ssd1307fb_get_brightness(struct backlight_device *bdev) +{ + struct ssd1307fb_par *par = bl_get_data(bdev); + + return par->contrast; +} + +static int ssd1307fb_check_fb(struct backlight_device *bdev, + struct fb_info *info) +{ + return (info->bl_dev == bdev); +} + +static const struct backlight_ops ssd1307fb_bl_ops = { + .options = BL_CORE_SUSPENDRESUME, + .update_status = ssd1307fb_update_bl, + .get_brightness = ssd1307fb_get_brightness, + .check_fb = ssd1307fb_check_fb, +}; + +static struct ssd1307fb_deviceinfo ssd1307fb_ssd1305_deviceinfo = { + .default_vcomh = 0x34, + .default_dclk_div = 1, + .default_dclk_frq = 7, +}; + +static struct ssd1307fb_deviceinfo ssd1307fb_ssd1306_deviceinfo = { + .default_vcomh = 0x20, + .default_dclk_div = 1, + .default_dclk_frq = 8, + .need_chargepump = 1, +}; + +static struct ssd1307fb_deviceinfo ssd1307fb_ssd1307_deviceinfo = { + .default_vcomh = 0x20, + .default_dclk_div = 2, + .default_dclk_frq = 12, + .need_pwm = 1, }; static const struct of_device_id ssd1307fb_of_match[] = { { + .compatible = "solomon,ssd1305fb-i2c", + .data = (void *)&ssd1307fb_ssd1305_deviceinfo, + }, + { .compatible = "solomon,ssd1306fb-i2c", - .data = (void *)&ssd1307fb_ssd1306_ops, + .data = (void *)&ssd1307fb_ssd1306_deviceinfo, }, { .compatible = "solomon,ssd1307fb-i2c", - .data = (void *)&ssd1307fb_ssd1307_ops, + .data = (void *)&ssd1307fb_ssd1307_deviceinfo, }, {}, }; @@ -446,8 +515,11 @@ MODULE_DEVICE_TABLE(of, ssd1307fb_of_match); static int ssd1307fb_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct backlight_device *bl; + char bl_name[12]; struct fb_info *info; struct device_node *node = client->dev.of_node; + struct fb_deferred_io *ssd1307fb_defio; u32 vmem_size; struct ssd1307fb_par *par; u8 *vmem; @@ -468,8 +540,8 @@ static int ssd1307fb_probe(struct i2c_client *client, par->info = info; par->client = client; - par->ops = (struct ssd1307fb_ops *)of_match_device(ssd1307fb_of_match, - &client->dev)->data; + par->device_info = (struct ssd1307fb_deviceinfo *)of_match_device( + ssd1307fb_of_match, &client->dev)->data; par->reset = of_get_named_gpio(client->dev.of_node, "reset-gpios", 0); @@ -487,19 +559,51 @@ static int ssd1307fb_probe(struct i2c_client *client, if (of_property_read_u32(node, "solomon,page-offset", &par->page_offset)) par->page_offset = 1; + if (of_property_read_u32(node, "solomon,com-offset", &par->com_offset)) + par->com_offset = 0; + + if (of_property_read_u32(node, "solomon,prechargep1", &par->prechargep1)) + par->prechargep1 = 2; + + if (of_property_read_u32(node, "solomon,prechargep2", &par->prechargep2)) + par->prechargep2 = 2; + + par->seg_remap = !of_property_read_bool(node, "solomon,segment-no-remap"); + par->com_seq = of_property_read_bool(node, "solomon,com-seq"); + par->com_lrremap = of_property_read_bool(node, "solomon,com-lrremap"); + par->com_invdir = of_property_read_bool(node, "solomon,com-invdir"); + + par->contrast = 127; + par->vcomh = par->device_info->default_vcomh; + + /* Setup display timing */ + par->dclk_div = par->device_info->default_dclk_div; + par->dclk_frq = par->device_info->default_dclk_frq; + vmem_size = par->width * par->height / 8; - vmem = devm_kzalloc(&client->dev, vmem_size, GFP_KERNEL); + vmem = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, + get_order(vmem_size)); if (!vmem) { dev_err(&client->dev, "Couldn't allocate graphical memory.\n"); ret = -ENOMEM; goto fb_alloc_error; } + ssd1307fb_defio = devm_kzalloc(&client->dev, sizeof(struct fb_deferred_io), GFP_KERNEL); + if (!ssd1307fb_defio) { + dev_err(&client->dev, "Couldn't allocate deferred io.\n"); + ret = -ENOMEM; + goto fb_alloc_error; + } + + ssd1307fb_defio->delay = HZ / refreshrate; + ssd1307fb_defio->deferred_io = ssd1307fb_deferred_io; + info->fbops = &ssd1307fb_ops; info->fix = ssd1307fb_fix; info->fix.line_length = par->width / 8; - info->fbdefio = &ssd1307fb_defio; + info->fbdefio = ssd1307fb_defio; info->var = ssd1307fb_var; info->var.xres = par->width; @@ -515,7 +619,7 @@ static int ssd1307fb_probe(struct i2c_client *client, info->var.blue.offset = 0; info->screen_base = (u8 __force __iomem *)vmem; - info->fix.smem_start = (unsigned long)vmem; + info->fix.smem_start = __pa(vmem); info->fix.smem_len = vmem_size; fb_deferred_io_init(info); @@ -538,11 +642,9 @@ static int ssd1307fb_probe(struct i2c_client *client, gpio_set_value(par->reset, 1); udelay(4); - if (par->ops->init) { - ret = par->ops->init(par); - if (ret) - goto reset_oled_error; - } + ret = ssd1307fb_init(par); + if (ret) + goto reset_oled_error; ret = register_framebuffer(info); if (ret) { @@ -550,13 +652,30 @@ static int ssd1307fb_probe(struct i2c_client *client, goto panel_init_error; } + snprintf(bl_name, sizeof(bl_name), "ssd1307fb%d", info->node); + bl = backlight_device_register(bl_name, &client->dev, par, + &ssd1307fb_bl_ops, NULL); + if (IS_ERR(bl)) { + dev_err(&client->dev, "unable to register backlight device: %ld\n", + PTR_ERR(bl)); + goto bl_init_error; + } + + bl->props.brightness = par->contrast; + bl->props.max_brightness = MAX_CONTRAST; + info->bl_dev = bl; + dev_info(&client->dev, "fb%d: %s framebuffer device registered, using %d bytes of video memory\n", info->node, info->fix.id, vmem_size); return 0; +bl_init_error: + unregister_framebuffer(info); panel_init_error: - if (par->ops->remove) - par->ops->remove(par); + if (par->device_info->need_pwm) { + pwm_disable(par->pwm); + pwm_put(par->pwm); + }; reset_oled_error: fb_deferred_io_cleanup(info); fb_alloc_error: @@ -569,16 +688,24 @@ static int ssd1307fb_remove(struct i2c_client *client) struct fb_info *info = i2c_get_clientdata(client); struct ssd1307fb_par *par = info->par; + ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_OFF); + + backlight_device_unregister(info->bl_dev); + unregister_framebuffer(info); - if (par->ops->remove) - par->ops->remove(par); + if (par->device_info->need_pwm) { + pwm_disable(par->pwm); + pwm_put(par->pwm); + }; fb_deferred_io_cleanup(info); + __free_pages(__va(info->fix.smem_start), get_order(info->fix.smem_len)); framebuffer_release(info); return 0; } static const struct i2c_device_id ssd1307fb_i2c_id[] = { + { "ssd1305fb", 0 }, { "ssd1306fb", 0 }, { "ssd1307fb", 0 }, { } diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index f761fe375f5b..621fa441a6db 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -78,24 +78,6 @@ #define DPRINTK(a, b...) pr_debug("fb: %s: " a, __func__ , ## b) -#ifdef CONFIG_MTRR -#include <asm/mtrr.h> -#else -/* duplicate asm/mtrr.h defines to work on archs without mtrr */ -#define MTRR_TYPE_WRCOMB 1 - -static inline int mtrr_add(unsigned long base, unsigned long size, - unsigned int type, char increment) -{ - return -ENODEV; -} -static inline int mtrr_del(int reg, unsigned long base, - unsigned long size) -{ - return -ENODEV; -} -#endif - #define BANSHEE_MAX_PIXCLOCK 270000 #define VOODOO3_MAX_PIXCLOCK 300000 #define VOODOO5_MAX_PIXCLOCK 350000 @@ -167,7 +149,6 @@ static int nopan; static int nowrap = 1; /* not implemented (yet) */ static int hwcursor = 1; static char *mode_option; -/* mtrr option */ static bool nomtrr; /* ------------------------------------------------------------------------- @@ -1454,8 +1435,8 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out_err_regbase; } - info->screen_base = ioremap_nocache(info->fix.smem_start, - info->fix.smem_len); + info->screen_base = ioremap_wc(info->fix.smem_start, + info->fix.smem_len); if (!info->screen_base) { printk(KERN_ERR "fb: Can't remap %s framebuffer.\n", info->fix.id); @@ -1473,11 +1454,9 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) printk(KERN_INFO "fb: %s memory = %dK\n", info->fix.id, info->fix.smem_len >> 10); - default_par->mtrr_handle = -1; if (!nomtrr) - default_par->mtrr_handle = - mtrr_add(info->fix.smem_start, info->fix.smem_len, - MTRR_TYPE_WRCOMB, 1); + default_par->wc_cookie= arch_phys_wc_add(info->fix.smem_start, + info->fix.smem_len); info->fix.ypanstep = nopan ? 0 : 1; info->fix.ywrapstep = nowrap ? 0 : 1; @@ -1566,9 +1545,7 @@ out_err_iobase: #ifdef CONFIG_FB_3DFX_I2C tdfxfb_delete_i2c_busses(default_par); #endif - if (default_par->mtrr_handle >= 0) - mtrr_del(default_par->mtrr_handle, info->fix.smem_start, - info->fix.smem_len); + arch_phys_wc_del(default_par->wc_cookie); release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); out_err_screenbase: @@ -1604,10 +1581,8 @@ static void __init tdfxfb_setup(char *options) nowrap = 1; } else if (!strncmp(this_opt, "hwcursor=", 9)) { hwcursor = simple_strtoul(this_opt + 9, NULL, 0); -#ifdef CONFIG_MTRR } else if (!strncmp(this_opt, "nomtrr", 6)) { nomtrr = 1; -#endif } else { mode_option = this_opt; } @@ -1633,9 +1608,7 @@ static void tdfxfb_remove(struct pci_dev *pdev) #ifdef CONFIG_FB_3DFX_I2C tdfxfb_delete_i2c_busses(par); #endif - if (par->mtrr_handle >= 0) - mtrr_del(par->mtrr_handle, info->fix.smem_start, - info->fix.smem_len); + arch_phys_wc_del(par->wc_cookie); iounmap(par->regbase_virt); iounmap(info->screen_base); @@ -1677,10 +1650,8 @@ MODULE_PARM_DESC(hwcursor, "Enable hardware cursor " "(1=enable, 0=disable, default=1)"); module_param(mode_option, charp, 0); MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'"); -#ifdef CONFIG_MTRR module_param(nomtrr, bool, 0); MODULE_PARM_DESC(nomtrr, "Disable MTRR support (default: enabled)"); -#endif module_init(tdfxfb_init); module_exit(tdfxfb_exit); diff --git a/drivers/video/fbdev/vesafb.c b/drivers/video/fbdev/vesafb.c index d79a0ac49fc7..528fe917dd49 100644 --- a/drivers/video/fbdev/vesafb.c +++ b/drivers/video/fbdev/vesafb.c @@ -19,16 +19,20 @@ #include <linux/init.h> #include <linux/platform_device.h> #include <linux/screen_info.h> +#include <linux/io.h> #include <video/vga.h> -#include <asm/io.h> -#include <asm/mtrr.h> #define dac_reg (0x3c8) #define dac_val (0x3c9) /* --------------------------------------------------------------------- */ +struct vesafb_par { + u32 pseudo_palette[256]; + int wc_cookie; +}; + static struct fb_var_screeninfo vesafb_defined = { .activate = FB_ACTIVATE_NOW, .height = -1, @@ -175,7 +179,10 @@ static int vesafb_setcolreg(unsigned regno, unsigned red, unsigned green, static void vesafb_destroy(struct fb_info *info) { + struct vesafb_par *par = info->par; + fb_dealloc_cmap(&info->cmap); + arch_phys_wc_del(par->wc_cookie); if (info->screen_base) iounmap(info->screen_base); release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size); @@ -228,6 +235,7 @@ static int vesafb_setup(char *options) static int vesafb_probe(struct platform_device *dev) { struct fb_info *info; + struct vesafb_par *par; int i, err; unsigned int size_vmode; unsigned int size_remap; @@ -291,14 +299,14 @@ static int vesafb_probe(struct platform_device *dev) spaces our resource handlers simply don't know about */ } - info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev); + info = framebuffer_alloc(sizeof(struct vesafb_par), &dev->dev); if (!info) { release_mem_region(vesafb_fix.smem_start, size_total); return -ENOMEM; } platform_set_drvdata(dev, info); - info->pseudo_palette = info->par; - info->par = NULL; + par = info->par; + info->pseudo_palette = par->pseudo_palette; /* set vesafb aperture size for generic probing */ info->apertures = alloc_apertures(1); @@ -404,60 +412,27 @@ static int vesafb_probe(struct platform_device *dev) * region already (FIXME) */ request_region(0x3c0, 32, "vesafb"); -#ifdef CONFIG_MTRR - if (mtrr) { + if (mtrr == 3) { unsigned int temp_size = size_total; - unsigned int type = 0; - - switch (mtrr) { - case 1: - type = MTRR_TYPE_UNCACHABLE; - break; - case 2: - type = MTRR_TYPE_WRBACK; - break; - case 3: - type = MTRR_TYPE_WRCOMB; - break; - case 4: - type = MTRR_TYPE_WRTHROUGH; - break; - default: - type = 0; - break; - } - if (type) { - int rc; + /* Find the largest power-of-two */ + temp_size = roundup_pow_of_two(temp_size); - /* Find the largest power-of-two */ - temp_size = roundup_pow_of_two(temp_size); + /* Try and find a power of two to add */ + do { + par->wc_cookie = + arch_phys_wc_add(vesafb_fix.smem_start, + temp_size); + temp_size >>= 1; + } while (temp_size >= PAGE_SIZE && par->wc_cookie < 0); - /* Try and find a power of two to add */ - do { - rc = mtrr_add(vesafb_fix.smem_start, temp_size, - type, 1); - temp_size >>= 1; - } while (temp_size >= PAGE_SIZE && rc == -EINVAL); - } - } -#endif - - switch (mtrr) { - case 1: /* uncachable */ - info->screen_base = ioremap_nocache(vesafb_fix.smem_start, vesafb_fix.smem_len); - break; - case 2: /* write-back */ - info->screen_base = ioremap_cache(vesafb_fix.smem_start, vesafb_fix.smem_len); - break; - case 3: /* write-combining */ info->screen_base = ioremap_wc(vesafb_fix.smem_start, vesafb_fix.smem_len); - break; - case 4: /* write-through */ - default: + } else { + if (mtrr && mtrr != 3) + WARN_ONCE(1, "Only MTRR_TYPE_WRCOMB (3) make sense\n"); info->screen_base = ioremap(vesafb_fix.smem_start, vesafb_fix.smem_len); - break; } + if (!info->screen_base) { printk(KERN_ERR "vesafb: abort, cannot ioremap video memory 0x%x @ 0x%lx\n", @@ -492,6 +467,7 @@ static int vesafb_probe(struct platform_device *dev) fb_info(info, "%s frame buffer device\n", info->fix.id); return 0; err: + arch_phys_wc_del(par->wc_cookie); if (info->screen_base) iounmap(info->screen_base); framebuffer_release(info); |