2007-05-09 17:35:31 +08:00
|
|
|
/*
|
|
|
|
* linux/drivers/video/vt8623fb.c - fbdev driver for
|
|
|
|
* integrated graphic core in VIA VT8623 [CLE266] chipset
|
|
|
|
*
|
|
|
|
* Copyright (c) 2006-2007 Ondrej Zajicek <santiago@crfreenet.org>
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file COPYING in the main directory of this archive for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* Code is based on s3fb, some parts are from David Boucher's viafb
|
|
|
|
* (http://davesdomain.org.uk/viafb/)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/fb.h>
|
|
|
|
#include <linux/svga.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/pci.h>
|
2011-01-26 07:07:35 +08:00
|
|
|
#include <linux/console.h> /* Why should fb driver call console functions? because console_lock() */
|
2007-05-09 17:35:31 +08:00
|
|
|
#include <video/vga.h>
|
|
|
|
|
|
|
|
struct vt8623fb_info {
|
|
|
|
char __iomem *mmio_base;
|
drivers/video/fbdev/vt8623fb: Use arch_phys_wc_add() and pci_iomap_wc()
This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86-specific MTRR code to the
architecture-agnostic arch_phys_wc_add(). It will avoid MTRRs if
write-combining is available. In order to take advantage of that
also ensure the ioremapped area is requested as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available.
b) Help bury MTRR code away, MTRR is architecture-specific and on
x86 it is being replaced by PAT.
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()").
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the ifdeffery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get an
MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: airlied@linux.ie
Cc: benh@kernel.crashing.org
Cc: bhelgaas@google.com
Cc: dan.j.williams@intel.com
Cc: konrad.wilk@oracle.com
Cc: linux-fbdev@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: mst@redhat.com
Cc: toshi.kani@hp.com
Cc: vinod.koul@intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1440443613-13696-9-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-08-25 03:13:30 +08:00
|
|
|
int wc_cookie;
|
2007-05-09 17:35:31 +08:00
|
|
|
struct vgastate state;
|
|
|
|
struct mutex open_lock;
|
|
|
|
unsigned int ref_count;
|
|
|
|
u32 pseudo_palette[16];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static const struct svga_fb_format vt8623fb_formats[] = {
|
|
|
|
{ 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
|
|
|
|
FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP8, FB_VISUAL_PSEUDOCOLOR, 16, 16},
|
|
|
|
{ 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
|
|
|
|
FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 16, 16},
|
|
|
|
{ 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1,
|
|
|
|
FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 16, 16},
|
|
|
|
{ 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
|
|
|
|
FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 8},
|
|
|
|
/* {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0,
|
|
|
|
FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4}, */
|
|
|
|
{16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0,
|
|
|
|
FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4},
|
|
|
|
{32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
|
|
|
|
FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 2},
|
|
|
|
SVGA_FORMAT_END
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct svga_pll vt8623_pll = {2, 127, 2, 7, 0, 3,
|
|
|
|
60000, 300000, 14318};
|
|
|
|
|
|
|
|
/* CRT timing register sets */
|
|
|
|
|
2020-07-02 05:02:48 +08:00
|
|
|
static const struct vga_regset vt8623_h_total_regs[] = {{0x00, 0, 7}, {0x36, 3, 3}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_h_display_regs[] = {{0x01, 0, 7}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_h_blank_start_regs[] = {{0x02, 0, 7}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7}, {0x33, 5, 5}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_h_sync_start_regs[] = {{0x04, 0, 7}, {0x33, 4, 4}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END};
|
2007-07-17 19:05:47 +08:00
|
|
|
|
2020-07-02 05:02:48 +08:00
|
|
|
static const struct vga_regset vt8623_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x35, 0, 0}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x35, 2, 2}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x35, 3, 3}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x35, 1, 1}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END};
|
2007-07-17 19:05:47 +08:00
|
|
|
|
2020-07-02 05:02:48 +08:00
|
|
|
static const struct vga_regset vt8623_offset_regs[] = {{0x13, 0, 7}, {0x35, 5, 7}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, {0x33, 0, 2}, {0x35, 4, 4}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_fetch_count_regs[] = {{0x1C, 0, 7}, {0x1D, 0, 1}, VGA_REGSET_END};
|
|
|
|
static const struct vga_regset vt8623_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x34, 0, 7}, {0x48, 0, 1}, VGA_REGSET_END};
|
2007-07-17 19:05:47 +08:00
|
|
|
|
2017-08-19 01:56:40 +08:00
|
|
|
static const struct svga_timing_regs vt8623_timing_regs = {
|
2007-05-09 17:35:31 +08:00
|
|
|
vt8623_h_total_regs, vt8623_h_display_regs, vt8623_h_blank_start_regs,
|
|
|
|
vt8623_h_blank_end_regs, vt8623_h_sync_start_regs, vt8623_h_sync_end_regs,
|
|
|
|
vt8623_v_total_regs, vt8623_v_display_regs, vt8623_v_blank_start_regs,
|
|
|
|
vt8623_v_blank_end_regs, vt8623_v_sync_start_regs, vt8623_v_sync_end_regs,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/* Module parameters */
|
|
|
|
|
2008-04-28 17:15:08 +08:00
|
|
|
static char *mode_option = "640x480-8@60";
|
2007-05-09 17:35:31 +08:00
|
|
|
static int mtrr = 1;
|
|
|
|
|
|
|
|
MODULE_AUTHOR("(c) 2006 Ondrej Zajicek <santiago@crfreenet.org>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("fbdev driver for integrated graphics core in VIA VT8623 [CLE266]");
|
|
|
|
|
2008-04-28 17:15:08 +08:00
|
|
|
module_param(mode_option, charp, 0644);
|
|
|
|
MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
|
2008-04-28 17:15:10 +08:00
|
|
|
module_param_named(mode, mode_option, charp, 0);
|
|
|
|
MODULE_PARM_DESC(mode, "Default video mode e.g. '648x480-8@60' (deprecated)");
|
2007-05-09 17:35:31 +08:00
|
|
|
module_param(mtrr, int, 0444);
|
|
|
|
MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)");
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2011-01-12 07:52:11 +08:00
|
|
|
static void vt8623fb_tilecursor(struct fb_info *info, struct fb_tilecursor *cursor)
|
|
|
|
{
|
|
|
|
struct vt8623fb_info *par = info->par;
|
|
|
|
|
|
|
|
svga_tilecursor(par->state.vgabase, info, cursor);
|
|
|
|
}
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
static struct fb_tile_ops vt8623fb_tile_ops = {
|
|
|
|
.fb_settile = svga_settile,
|
|
|
|
.fb_tilecopy = svga_tilecopy,
|
|
|
|
.fb_tilefill = svga_tilefill,
|
|
|
|
.fb_tileblit = svga_tileblit,
|
2011-01-12 07:52:11 +08:00
|
|
|
.fb_tilecursor = vt8623fb_tilecursor,
|
2007-05-09 17:35:31 +08:00
|
|
|
.fb_get_tilemax = svga_get_tilemax,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/* image data is MSB-first, fb structure is MSB-first too */
|
|
|
|
static inline u32 expand_color(u32 c)
|
|
|
|
{
|
|
|
|
return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vt8623fb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */
|
|
|
|
static void vt8623fb_iplan_imageblit(struct fb_info *info, const struct fb_image *image)
|
|
|
|
{
|
|
|
|
u32 fg = expand_color(image->fg_color);
|
|
|
|
u32 bg = expand_color(image->bg_color);
|
|
|
|
const u8 *src1, *src;
|
|
|
|
u8 __iomem *dst1;
|
|
|
|
u32 __iomem *dst;
|
|
|
|
u32 val;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
src1 = image->data;
|
|
|
|
dst1 = info->screen_base + (image->dy * info->fix.line_length)
|
|
|
|
+ ((image->dx / 8) * 4);
|
|
|
|
|
|
|
|
for (y = 0; y < image->height; y++) {
|
|
|
|
src = src1;
|
|
|
|
dst = (u32 __iomem *) dst1;
|
|
|
|
for (x = 0; x < image->width; x += 8) {
|
|
|
|
val = *(src++) * 0x01010101;
|
|
|
|
val = (val & fg) | (~val & bg);
|
|
|
|
fb_writel(val, dst++);
|
|
|
|
}
|
|
|
|
src1 += image->width / 8;
|
|
|
|
dst1 += info->fix.line_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vt8623fb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */
|
|
|
|
static void vt8623fb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
|
|
|
|
{
|
|
|
|
u32 fg = expand_color(rect->color);
|
|
|
|
u8 __iomem *dst1;
|
|
|
|
u32 __iomem *dst;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
dst1 = info->screen_base + (rect->dy * info->fix.line_length)
|
|
|
|
+ ((rect->dx / 8) * 4);
|
|
|
|
|
|
|
|
for (y = 0; y < rect->height; y++) {
|
|
|
|
dst = (u32 __iomem *) dst1;
|
|
|
|
for (x = 0; x < rect->width; x += 8) {
|
|
|
|
fb_writel(fg, dst++);
|
|
|
|
}
|
|
|
|
dst1 += info->fix.line_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */
|
|
|
|
static inline u32 expand_pixel(u32 c)
|
|
|
|
{
|
|
|
|
return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) |
|
|
|
|
((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vt8623fb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */
|
|
|
|
static void vt8623fb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image)
|
|
|
|
{
|
|
|
|
u32 fg = image->fg_color * 0x11111111;
|
|
|
|
u32 bg = image->bg_color * 0x11111111;
|
|
|
|
const u8 *src1, *src;
|
|
|
|
u8 __iomem *dst1;
|
|
|
|
u32 __iomem *dst;
|
|
|
|
u32 val;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
src1 = image->data;
|
|
|
|
dst1 = info->screen_base + (image->dy * info->fix.line_length)
|
|
|
|
+ ((image->dx / 8) * 4);
|
|
|
|
|
|
|
|
for (y = 0; y < image->height; y++) {
|
|
|
|
src = src1;
|
|
|
|
dst = (u32 __iomem *) dst1;
|
|
|
|
for (x = 0; x < image->width; x += 8) {
|
|
|
|
val = expand_pixel(*(src++));
|
|
|
|
val = (val & fg) | (~val & bg);
|
|
|
|
fb_writel(val, dst++);
|
|
|
|
}
|
|
|
|
src1 += image->width / 8;
|
|
|
|
dst1 += info->fix.line_length;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vt8623fb_imageblit(struct fb_info *info, const struct fb_image *image)
|
|
|
|
{
|
|
|
|
if ((info->var.bits_per_pixel == 4) && (image->depth == 1)
|
|
|
|
&& ((image->width % 8) == 0) && ((image->dx % 8) == 0)) {
|
|
|
|
if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)
|
|
|
|
vt8623fb_iplan_imageblit(info, image);
|
|
|
|
else
|
|
|
|
vt8623fb_cfb4_imageblit(info, image);
|
|
|
|
} else
|
|
|
|
cfb_imageblit(info, image);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void vt8623fb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
|
|
|
|
{
|
|
|
|
if ((info->var.bits_per_pixel == 4)
|
|
|
|
&& ((rect->width % 8) == 0) && ((rect->dx % 8) == 0)
|
|
|
|
&& (info->fix.type == FB_TYPE_INTERLEAVED_PLANES))
|
|
|
|
vt8623fb_iplan_fillrect(info, rect);
|
|
|
|
else
|
|
|
|
cfb_fillrect(info, rect);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
static void vt8623_set_pixclock(struct fb_info *info, u32 pixclock)
|
|
|
|
{
|
2011-01-12 07:51:08 +08:00
|
|
|
struct vt8623fb_info *par = info->par;
|
2007-05-09 17:35:31 +08:00
|
|
|
u16 m, n, r;
|
|
|
|
u8 regval;
|
|
|
|
int rv;
|
|
|
|
|
|
|
|
rv = svga_compute_pll(&vt8623_pll, 1000000000 / pixclock, &m, &n, &r, info->node);
|
|
|
|
if (rv < 0) {
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_err(info, "cannot set requested pixclock, keeping old value\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set VGA misc register */
|
2011-01-12 07:53:11 +08:00
|
|
|
regval = vga_r(par->state.vgabase, VGA_MIS_R);
|
|
|
|
vga_w(par->state.vgabase, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
/* Set clock registers */
|
2011-01-12 07:53:11 +08:00
|
|
|
vga_wseq(par->state.vgabase, 0x46, (n | (r << 6)));
|
|
|
|
vga_wseq(par->state.vgabase, 0x47, m);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
udelay(1000);
|
|
|
|
|
|
|
|
/* PLL reset */
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x40, 0x02, 0x02);
|
|
|
|
svga_wseq_mask(par->state.vgabase, 0x40, 0x00, 0x02);
|
2007-05-09 17:35:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int vt8623fb_open(struct fb_info *info, int user)
|
|
|
|
{
|
|
|
|
struct vt8623fb_info *par = info->par;
|
|
|
|
|
|
|
|
mutex_lock(&(par->open_lock));
|
|
|
|
if (par->ref_count == 0) {
|
2011-01-12 07:54:07 +08:00
|
|
|
void __iomem *vgabase = par->state.vgabase;
|
|
|
|
|
2007-05-09 17:35:31 +08:00
|
|
|
memset(&(par->state), 0, sizeof(struct vgastate));
|
2011-01-12 07:54:07 +08:00
|
|
|
par->state.vgabase = vgabase;
|
2007-05-09 17:35:31 +08:00
|
|
|
par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP;
|
|
|
|
par->state.num_crtc = 0xA2;
|
|
|
|
par->state.num_seq = 0x50;
|
|
|
|
save_vga(&(par->state));
|
|
|
|
}
|
|
|
|
|
|
|
|
par->ref_count++;
|
|
|
|
mutex_unlock(&(par->open_lock));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vt8623fb_release(struct fb_info *info, int user)
|
|
|
|
{
|
|
|
|
struct vt8623fb_info *par = info->par;
|
|
|
|
|
|
|
|
mutex_lock(&(par->open_lock));
|
|
|
|
if (par->ref_count == 0) {
|
|
|
|
mutex_unlock(&(par->open_lock));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (par->ref_count == 1)
|
|
|
|
restore_vga(&(par->state));
|
|
|
|
|
|
|
|
par->ref_count--;
|
|
|
|
mutex_unlock(&(par->open_lock));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int vt8623fb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
|
|
|
|
{
|
|
|
|
int rv, mem, step;
|
|
|
|
|
|
|
|
/* Find appropriate format */
|
|
|
|
rv = svga_match_format (vt8623fb_formats, var, NULL);
|
|
|
|
if (rv < 0)
|
|
|
|
{
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_err(info, "unsupported mode requested\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Do not allow to have real resoulution larger than virtual */
|
|
|
|
if (var->xres > var->xres_virtual)
|
|
|
|
var->xres_virtual = var->xres;
|
|
|
|
|
|
|
|
if (var->yres > var->yres_virtual)
|
|
|
|
var->yres_virtual = var->yres;
|
|
|
|
|
|
|
|
/* Round up xres_virtual to have proper alignment of lines */
|
|
|
|
step = vt8623fb_formats[rv].xresstep - 1;
|
|
|
|
var->xres_virtual = (var->xres_virtual+step) & ~step;
|
|
|
|
|
|
|
|
/* Check whether have enough memory */
|
|
|
|
mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual;
|
|
|
|
if (mem > info->screen_size)
|
|
|
|
{
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_err(info, "not enough framebuffer memory (%d kB requested, %d kB available)\n",
|
|
|
|
mem >> 10, (unsigned int) (info->screen_size >> 10));
|
2007-05-09 17:35:31 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Text mode is limited to 256 kB of memory */
|
|
|
|
if ((var->bits_per_pixel == 0) && (mem > (256*1024)))
|
|
|
|
{
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_err(info, "text framebuffer size too large (%d kB requested, 256 kB possible)\n",
|
|
|
|
mem >> 10);
|
2007-05-09 17:35:31 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = svga_check_timings (&vt8623_timing_regs, var, info->node);
|
|
|
|
if (rv < 0)
|
|
|
|
{
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_err(info, "invalid timings requested\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Interlaced mode not supported */
|
|
|
|
if (var->vmode & FB_VMODE_INTERLACED)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int vt8623fb_set_par(struct fb_info *info)
|
|
|
|
{
|
|
|
|
u32 mode, offset_value, fetch_value, screen_size;
|
2011-01-12 07:49:34 +08:00
|
|
|
struct vt8623fb_info *par = info->par;
|
2007-05-09 17:35:31 +08:00
|
|
|
u32 bpp = info->var.bits_per_pixel;
|
|
|
|
|
|
|
|
if (bpp != 0) {
|
|
|
|
info->fix.ypanstep = 1;
|
|
|
|
info->fix.line_length = (info->var.xres_virtual * bpp) / 8;
|
|
|
|
|
|
|
|
info->flags &= ~FBINFO_MISC_TILEBLITTING;
|
|
|
|
info->tileops = NULL;
|
|
|
|
|
|
|
|
/* in 4bpp supports 8p wide tiles only, any tiles otherwise */
|
|
|
|
info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0);
|
|
|
|
info->pixmap.blit_y = ~(u32)0;
|
|
|
|
|
|
|
|
offset_value = (info->var.xres_virtual * bpp) / 64;
|
|
|
|
fetch_value = ((info->var.xres * bpp) / 128) + 4;
|
|
|
|
|
|
|
|
if (bpp == 4)
|
|
|
|
fetch_value = (info->var.xres / 8) + 8; /* + 0 is OK */
|
|
|
|
|
|
|
|
screen_size = info->var.yres_virtual * info->fix.line_length;
|
|
|
|
} else {
|
|
|
|
info->fix.ypanstep = 16;
|
|
|
|
info->fix.line_length = 0;
|
|
|
|
|
|
|
|
info->flags |= FBINFO_MISC_TILEBLITTING;
|
|
|
|
info->tileops = &vt8623fb_tile_ops;
|
|
|
|
|
|
|
|
/* supports 8x16 tiles only */
|
|
|
|
info->pixmap.blit_x = 1 << (8 - 1);
|
|
|
|
info->pixmap.blit_y = 1 << (16 - 1);
|
|
|
|
|
|
|
|
offset_value = info->var.xres_virtual / 16;
|
|
|
|
fetch_value = (info->var.xres / 8) + 8;
|
|
|
|
screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->var.xoffset = 0;
|
|
|
|
info->var.yoffset = 0;
|
|
|
|
info->var.activate = FB_ACTIVATE_NOW;
|
|
|
|
|
|
|
|
/* Unlock registers */
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x10, 0x01, 0x01);
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x11, 0x00, 0x80);
|
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x47, 0x00, 0x01);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
/* Device, screen and sync off */
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x36, 0x30, 0x30);
|
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x17, 0x00, 0x80);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
/* Set default values */
|
2011-01-12 07:50:04 +08:00
|
|
|
svga_set_default_gfx_regs(par->state.vgabase);
|
2011-01-12 07:50:36 +08:00
|
|
|
svga_set_default_atc_regs(par->state.vgabase);
|
2011-01-12 07:50:54 +08:00
|
|
|
svga_set_default_seq_regs(par->state.vgabase);
|
2011-01-12 07:51:41 +08:00
|
|
|
svga_set_default_crt_regs(par->state.vgabase);
|
2011-01-12 07:49:34 +08:00
|
|
|
svga_wcrt_multi(par->state.vgabase, vt8623_line_compare_regs, 0xFFFFFFFF);
|
|
|
|
svga_wcrt_multi(par->state.vgabase, vt8623_start_address_regs, 0);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
2011-01-12 07:49:34 +08:00
|
|
|
svga_wcrt_multi(par->state.vgabase, vt8623_offset_regs, offset_value);
|
2011-01-12 07:49:49 +08:00
|
|
|
svga_wseq_multi(par->state.vgabase, vt8623_fetch_count_regs, fetch_value);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
2008-04-28 17:15:17 +08:00
|
|
|
/* Clear H/V Skew */
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x03, 0x00, 0x60);
|
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x05, 0x00, 0x60);
|
2008-04-28 17:15:17 +08:00
|
|
|
|
2007-05-09 17:35:31 +08:00
|
|
|
if (info->var.vmode & FB_VMODE_DOUBLE)
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x09, 0x80, 0x80);
|
2007-05-09 17:35:31 +08:00
|
|
|
else
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x09, 0x00, 0x80);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x1E, 0xF0, 0xF0); // DI/DVP bus
|
|
|
|
svga_wseq_mask(par->state.vgabase, 0x2A, 0x0F, 0x0F); // DI/DVP bus
|
|
|
|
svga_wseq_mask(par->state.vgabase, 0x16, 0x08, 0xBF); // FIFO read threshold
|
2011-01-12 07:53:11 +08:00
|
|
|
vga_wseq(par->state.vgabase, 0x17, 0x1F); // FIFO depth
|
|
|
|
vga_wseq(par->state.vgabase, 0x18, 0x4E);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x1A, 0x08, 0x08); // enable MMIO ?
|
2007-05-09 17:35:31 +08:00
|
|
|
|
2011-01-12 07:53:11 +08:00
|
|
|
vga_wcrt(par->state.vgabase, 0x32, 0x00);
|
|
|
|
vga_wcrt(par->state.vgabase, 0x34, 0x00);
|
|
|
|
vga_wcrt(par->state.vgabase, 0x6A, 0x80);
|
|
|
|
vga_wcrt(par->state.vgabase, 0x6A, 0xC0);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
2011-01-12 07:53:11 +08:00
|
|
|
vga_wgfx(par->state.vgabase, 0x20, 0x00);
|
|
|
|
vga_wgfx(par->state.vgabase, 0x21, 0x00);
|
|
|
|
vga_wgfx(par->state.vgabase, 0x22, 0x00);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
/* Set SR15 according to number of bits per pixel */
|
|
|
|
mode = svga_match_format(vt8623fb_formats, &(info->var), &(info->fix));
|
|
|
|
switch (mode) {
|
|
|
|
case 0:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "text mode\n");
|
2011-01-12 07:51:56 +08:00
|
|
|
svga_set_textmode_vga_regs(par->state.vgabase);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x15, 0x00, 0xFE);
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x11, 0x60, 0x70);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case 1:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "4 bit pseudocolor\n");
|
2011-01-12 07:53:11 +08:00
|
|
|
vga_wgfx(par->state.vgabase, VGA_GFX_MODE, 0x40);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x15, 0x20, 0xFE);
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x11, 0x00, 0x70);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "4 bit pseudocolor, planar\n");
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x15, 0x00, 0xFE);
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x11, 0x00, 0x70);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case 3:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "8 bit pseudocolor\n");
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x15, 0x22, 0xFE);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case 4:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "5/6/5 truecolor\n");
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x15, 0xB6, 0xFE);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case 5:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "8/8/8 truecolor\n");
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x15, 0xAE, 0xFE);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printk(KERN_ERR "vt8623fb: unsupported mode - bug\n");
|
|
|
|
return (-EINVAL);
|
|
|
|
}
|
|
|
|
|
|
|
|
vt8623_set_pixclock(info, info->var.pixclock);
|
2011-01-12 07:52:25 +08:00
|
|
|
svga_set_timings(par->state.vgabase, &vt8623_timing_regs, &(info->var), 1, 1,
|
2007-05-09 17:35:31 +08:00
|
|
|
(info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, 1,
|
|
|
|
1, info->node);
|
|
|
|
|
|
|
|
memset_io(info->screen_base, 0x00, screen_size);
|
|
|
|
|
|
|
|
/* Device and screen back on */
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80);
|
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x36, 0x00, 0x30);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x01, 0x00, 0x20);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int vt8623fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
|
|
|
|
u_int transp, struct fb_info *fb)
|
|
|
|
{
|
|
|
|
switch (fb->var.bits_per_pixel) {
|
|
|
|
case 0:
|
|
|
|
case 4:
|
|
|
|
if (regno >= 16)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
outb(0x0F, VGA_PEL_MSK);
|
|
|
|
outb(regno, VGA_PEL_IW);
|
|
|
|
outb(red >> 10, VGA_PEL_D);
|
|
|
|
outb(green >> 10, VGA_PEL_D);
|
|
|
|
outb(blue >> 10, VGA_PEL_D);
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
if (regno >= 256)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
outb(0xFF, VGA_PEL_MSK);
|
|
|
|
outb(regno, VGA_PEL_IW);
|
|
|
|
outb(red >> 10, VGA_PEL_D);
|
|
|
|
outb(green >> 10, VGA_PEL_D);
|
|
|
|
outb(blue >> 10, VGA_PEL_D);
|
|
|
|
break;
|
|
|
|
case 16:
|
|
|
|
if (regno >= 16)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (fb->var.green.length == 5)
|
|
|
|
((u32*)fb->pseudo_palette)[regno] = ((red & 0xF800) >> 1) |
|
|
|
|
((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11);
|
|
|
|
else if (fb->var.green.length == 6)
|
|
|
|
((u32*)fb->pseudo_palette)[regno] = (red & 0xF800) |
|
|
|
|
((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
break;
|
|
|
|
case 24:
|
|
|
|
case 32:
|
|
|
|
if (regno >= 16)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* ((transp & 0xFF00) << 16) */
|
|
|
|
((u32*)fb->pseudo_palette)[regno] = ((red & 0xFF00) << 8) |
|
|
|
|
(green & 0xFF00) | ((blue & 0xFF00) >> 8);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int vt8623fb_blank(int blank_mode, struct fb_info *info)
|
|
|
|
{
|
2011-01-12 07:51:08 +08:00
|
|
|
struct vt8623fb_info *par = info->par;
|
|
|
|
|
2007-05-09 17:35:31 +08:00
|
|
|
switch (blank_mode) {
|
|
|
|
case FB_BLANK_UNBLANK:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "unblank\n");
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x36, 0x00, 0x30);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x01, 0x00, 0x20);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case FB_BLANK_NORMAL:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "blank\n");
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x36, 0x00, 0x30);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case FB_BLANK_HSYNC_SUSPEND:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "DPMS standby (hsync off)\n");
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x36, 0x10, 0x30);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case FB_BLANK_VSYNC_SUSPEND:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "DPMS suspend (vsync off)\n");
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x36, 0x20, 0x30);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
case FB_BLANK_POWERDOWN:
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_dbg(info, "DPMS off (no sync)\n");
|
2011-01-12 07:51:26 +08:00
|
|
|
svga_wcrt_mask(par->state.vgabase, 0x36, 0x30, 0x30);
|
2011-01-12 07:51:08 +08:00
|
|
|
svga_wseq_mask(par->state.vgabase, 0x01, 0x20, 0x20);
|
2007-05-09 17:35:31 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int vt8623fb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
|
|
|
|
{
|
2011-01-12 07:49:34 +08:00
|
|
|
struct vt8623fb_info *par = info->par;
|
2007-05-09 17:35:31 +08:00
|
|
|
unsigned int offset;
|
|
|
|
|
|
|
|
/* Calculate the offset */
|
2011-05-25 17:34:52 +08:00
|
|
|
if (info->var.bits_per_pixel == 0) {
|
|
|
|
offset = (var->yoffset / 16) * info->var.xres_virtual
|
|
|
|
+ var->xoffset;
|
2007-05-09 17:35:31 +08:00
|
|
|
offset = offset >> 3;
|
|
|
|
} else {
|
|
|
|
offset = (var->yoffset * info->fix.line_length) +
|
2011-05-25 17:34:52 +08:00
|
|
|
(var->xoffset * info->var.bits_per_pixel / 8);
|
|
|
|
offset = offset >> ((info->var.bits_per_pixel == 4) ? 2 : 1);
|
2007-05-09 17:35:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the offset */
|
2011-01-12 07:49:34 +08:00
|
|
|
svga_wcrt_multi(par->state.vgabase, vt8623_start_address_regs, offset);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/* Frame buffer operations */
|
|
|
|
|
2019-12-04 00:38:50 +08:00
|
|
|
static const struct fb_ops vt8623fb_ops = {
|
2007-05-09 17:35:31 +08:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.fb_open = vt8623fb_open,
|
|
|
|
.fb_release = vt8623fb_release,
|
|
|
|
.fb_check_var = vt8623fb_check_var,
|
|
|
|
.fb_set_par = vt8623fb_set_par,
|
|
|
|
.fb_setcolreg = vt8623fb_setcolreg,
|
|
|
|
.fb_blank = vt8623fb_blank,
|
|
|
|
.fb_pan_display = vt8623fb_pan_display,
|
|
|
|
.fb_fillrect = vt8623fb_fillrect,
|
|
|
|
.fb_copyarea = cfb_copyarea,
|
|
|
|
.fb_imageblit = vt8623fb_imageblit,
|
2007-05-09 17:35:32 +08:00
|
|
|
.fb_get_caps = svga_get_caps,
|
2007-05-09 17:35:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* PCI probe */
|
|
|
|
|
2012-12-22 05:07:39 +08:00
|
|
|
static int vt8623_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
2007-05-09 17:35:31 +08:00
|
|
|
{
|
2011-01-12 07:55:17 +08:00
|
|
|
struct pci_bus_region bus_reg;
|
|
|
|
struct resource vga_res;
|
2007-05-09 17:35:31 +08:00
|
|
|
struct fb_info *info;
|
|
|
|
struct vt8623fb_info *par;
|
|
|
|
unsigned int memsize1, memsize2;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* Ignore secondary VGA device because there is no VGA arbitration */
|
|
|
|
if (! svga_primary_device(dev)) {
|
|
|
|
dev_info(&(dev->dev), "ignoring secondary device\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Allocate and fill driver data structure */
|
2008-04-28 17:15:18 +08:00
|
|
|
info = framebuffer_alloc(sizeof(struct vt8623fb_info), &(dev->dev));
|
2019-06-28 18:30:08 +08:00
|
|
|
if (!info)
|
2007-05-09 17:35:31 +08:00
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
par = info->par;
|
|
|
|
mutex_init(&par->open_lock);
|
|
|
|
|
|
|
|
info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN;
|
|
|
|
info->fbops = &vt8623fb_ops;
|
|
|
|
|
|
|
|
/* Prepare PCI device */
|
|
|
|
|
|
|
|
rc = pci_enable_device(dev);
|
|
|
|
if (rc < 0) {
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_err(info->device, "cannot enable PCI device\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
goto err_enable_device;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = pci_request_regions(dev, "vt8623fb");
|
|
|
|
if (rc < 0) {
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_err(info->device, "cannot reserve framebuffer region\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
goto err_request_regions;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->fix.smem_start = pci_resource_start(dev, 0);
|
|
|
|
info->fix.smem_len = pci_resource_len(dev, 0);
|
|
|
|
info->fix.mmio_start = pci_resource_start(dev, 1);
|
|
|
|
info->fix.mmio_len = pci_resource_len(dev, 1);
|
|
|
|
|
|
|
|
/* Map physical IO memory address into kernel space */
|
drivers/video/fbdev/vt8623fb: Use arch_phys_wc_add() and pci_iomap_wc()
This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86-specific MTRR code to the
architecture-agnostic arch_phys_wc_add(). It will avoid MTRRs if
write-combining is available. In order to take advantage of that
also ensure the ioremapped area is requested as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available.
b) Help bury MTRR code away, MTRR is architecture-specific and on
x86 it is being replaced by PAT.
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()").
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the ifdeffery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get an
MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: airlied@linux.ie
Cc: benh@kernel.crashing.org
Cc: bhelgaas@google.com
Cc: dan.j.williams@intel.com
Cc: konrad.wilk@oracle.com
Cc: linux-fbdev@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: mst@redhat.com
Cc: toshi.kani@hp.com
Cc: vinod.koul@intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1440443613-13696-9-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-08-25 03:13:30 +08:00
|
|
|
info->screen_base = pci_iomap_wc(dev, 0, 0);
|
2007-05-09 17:35:31 +08:00
|
|
|
if (! info->screen_base) {
|
|
|
|
rc = -ENOMEM;
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_err(info->device, "iomap for framebuffer failed\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
goto err_iomap_1;
|
|
|
|
}
|
|
|
|
|
|
|
|
par->mmio_base = pci_iomap(dev, 1, 0);
|
|
|
|
if (! par->mmio_base) {
|
|
|
|
rc = -ENOMEM;
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_err(info->device, "iomap for MMIO failed\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
goto err_iomap_2;
|
|
|
|
}
|
|
|
|
|
2011-01-12 07:55:17 +08:00
|
|
|
bus_reg.start = 0;
|
|
|
|
bus_reg.end = 64 * 1024;
|
|
|
|
|
|
|
|
vga_res.flags = IORESOURCE_IO;
|
|
|
|
|
PCI: Convert pcibios_resource_to_bus() to take a pci_bus, not a pci_dev
These interfaces:
pcibios_resource_to_bus(struct pci_dev *dev, *bus_region, *resource)
pcibios_bus_to_resource(struct pci_dev *dev, *resource, *bus_region)
took a pci_dev, but they really depend only on the pci_bus. And we want to
use them in resource allocation paths where we have the bus but not a
device, so this patch converts them to take the pci_bus instead of the
pci_dev:
pcibios_resource_to_bus(struct pci_bus *bus, *bus_region, *resource)
pcibios_bus_to_resource(struct pci_bus *bus, *resource, *bus_region)
In fact, with standard PCI-PCI bridges, they only depend on the host
bridge, because that's the only place address translation occurs, but
we aren't going that far yet.
[bhelgaas: changelog]
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2013-12-10 14:54:40 +08:00
|
|
|
pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
|
2011-01-12 07:55:17 +08:00
|
|
|
|
2014-11-27 06:07:23 +08:00
|
|
|
par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
|
2011-01-12 07:55:17 +08:00
|
|
|
|
2007-05-09 17:35:31 +08:00
|
|
|
/* Find how many physical memory there is on card */
|
2011-01-12 07:53:11 +08:00
|
|
|
memsize1 = (vga_rseq(par->state.vgabase, 0x34) + 1) >> 1;
|
|
|
|
memsize2 = vga_rseq(par->state.vgabase, 0x39) << 2;
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
if ((16 <= memsize1) && (memsize1 <= 64) && (memsize1 == memsize2))
|
|
|
|
info->screen_size = memsize1 << 20;
|
|
|
|
else {
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_err(info->device, "memory size detection failed (%x %x), suppose 16 MB\n", memsize1, memsize2);
|
2007-05-09 17:35:31 +08:00
|
|
|
info->screen_size = 16 << 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->fix.smem_len = info->screen_size;
|
|
|
|
strcpy(info->fix.id, "VIA VT8623");
|
|
|
|
info->fix.type = FB_TYPE_PACKED_PIXELS;
|
|
|
|
info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
|
|
|
|
info->fix.ypanstep = 0;
|
|
|
|
info->fix.accel = FB_ACCEL_NONE;
|
|
|
|
info->pseudo_palette = (void*)par->pseudo_palette;
|
|
|
|
|
|
|
|
/* Prepare startup mode */
|
|
|
|
|
module: add per-module param_lock
Add a "param_lock" mutex to each module, and update params.c to use
the correct built-in or module mutex while locking kernel params.
Remove the kparam_block_sysfs_r/w() macros, replace them with direct
calls to kernel_param_[un]lock(module).
The kernel param code currently uses a single mutex to protect
modification of any and all kernel params. While this generally works,
there is one specific problem with it; a module callback function
cannot safely load another module, i.e. with request_module() or even
with indirect calls such as crypto_has_alg(). If the module to be
loaded has any of its params configured (e.g. with a /etc/modprobe.d/*
config file), then the attempt will result in a deadlock between the
first module param callback waiting for modprobe, and modprobe trying to
lock the single kernel param mutex to set the new module's param.
This fixes that by using per-module mutexes, so that each individual module
is protected against concurrent changes in its own kernel params, but is
not blocked by changes to other module params. All built-in modules
continue to use the built-in mutex, since they will always be loaded at
runtime and references (e.g. request_module(), crypto_has_alg()) to them
will never cause load-time param changing.
This also simplifies the interface used by modules to block sysfs access
to their params; while there are currently functions to block and unblock
sysfs param access which are split up by read and write and expect a single
kernel param to be passed, their actual operation is identical and applies
to all params, not just the one passed to them; they simply lock and unlock
the global param mutex. They are replaced with direct calls to
kernel_param_[un]lock(THIS_MODULE), which locks THIS_MODULE's param_lock, or
if the module is built-in, it locks the built-in mutex.
Suggested-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-17 04:48:52 +08:00
|
|
|
kernel_param_lock(THIS_MODULE);
|
2008-04-28 17:15:08 +08:00
|
|
|
rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
|
module: add per-module param_lock
Add a "param_lock" mutex to each module, and update params.c to use
the correct built-in or module mutex while locking kernel params.
Remove the kparam_block_sysfs_r/w() macros, replace them with direct
calls to kernel_param_[un]lock(module).
The kernel param code currently uses a single mutex to protect
modification of any and all kernel params. While this generally works,
there is one specific problem with it; a module callback function
cannot safely load another module, i.e. with request_module() or even
with indirect calls such as crypto_has_alg(). If the module to be
loaded has any of its params configured (e.g. with a /etc/modprobe.d/*
config file), then the attempt will result in a deadlock between the
first module param callback waiting for modprobe, and modprobe trying to
lock the single kernel param mutex to set the new module's param.
This fixes that by using per-module mutexes, so that each individual module
is protected against concurrent changes in its own kernel params, but is
not blocked by changes to other module params. All built-in modules
continue to use the built-in mutex, since they will always be loaded at
runtime and references (e.g. request_module(), crypto_has_alg()) to them
will never cause load-time param changing.
This also simplifies the interface used by modules to block sysfs access
to their params; while there are currently functions to block and unblock
sysfs param access which are split up by read and write and expect a single
kernel param to be passed, their actual operation is identical and applies
to all params, not just the one passed to them; they simply lock and unlock
the global param mutex. They are replaced with direct calls to
kernel_param_[un]lock(THIS_MODULE), which locks THIS_MODULE's param_lock, or
if the module is built-in, it locks the built-in mutex.
Suggested-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Dan Streetman <ddstreet@ieee.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-17 04:48:52 +08:00
|
|
|
kernel_param_unlock(THIS_MODULE);
|
2007-05-09 17:35:31 +08:00
|
|
|
if (! ((rc == 1) || (rc == 2))) {
|
|
|
|
rc = -EINVAL;
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_err(info->device, "mode %s not found\n", mode_option);
|
2007-05-09 17:35:31 +08:00
|
|
|
goto err_find_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = fb_alloc_cmap(&info->cmap, 256, 0);
|
|
|
|
if (rc < 0) {
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_err(info->device, "cannot allocate colormap\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
goto err_alloc_cmap;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc = register_framebuffer(info);
|
|
|
|
if (rc < 0) {
|
2013-09-20 09:35:55 +08:00
|
|
|
dev_err(info->device, "cannot register framebuffer\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
goto err_reg_fb;
|
|
|
|
}
|
|
|
|
|
2013-09-20 09:35:55 +08:00
|
|
|
fb_info(info, "%s on %s, %d MB RAM\n",
|
|
|
|
info->fix.id, pci_name(dev), info->fix.smem_len >> 20);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
/* Record a reference to the driver data */
|
|
|
|
pci_set_drvdata(dev, info);
|
|
|
|
|
drivers/video/fbdev/vt8623fb: Use arch_phys_wc_add() and pci_iomap_wc()
This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86-specific MTRR code to the
architecture-agnostic arch_phys_wc_add(). It will avoid MTRRs if
write-combining is available. In order to take advantage of that
also ensure the ioremapped area is requested as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available.
b) Help bury MTRR code away, MTRR is architecture-specific and on
x86 it is being replaced by PAT.
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()").
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the ifdeffery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get an
MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: airlied@linux.ie
Cc: benh@kernel.crashing.org
Cc: bhelgaas@google.com
Cc: dan.j.williams@intel.com
Cc: konrad.wilk@oracle.com
Cc: linux-fbdev@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: mst@redhat.com
Cc: toshi.kani@hp.com
Cc: vinod.koul@intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1440443613-13696-9-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-08-25 03:13:30 +08:00
|
|
|
if (mtrr)
|
|
|
|
par->wc_cookie = arch_phys_wc_add(info->fix.smem_start,
|
|
|
|
info->fix.smem_len);
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Error handling */
|
|
|
|
err_reg_fb:
|
|
|
|
fb_dealloc_cmap(&info->cmap);
|
|
|
|
err_alloc_cmap:
|
|
|
|
err_find_mode:
|
|
|
|
pci_iounmap(dev, par->mmio_base);
|
|
|
|
err_iomap_2:
|
|
|
|
pci_iounmap(dev, info->screen_base);
|
|
|
|
err_iomap_1:
|
|
|
|
pci_release_regions(dev);
|
|
|
|
err_request_regions:
|
|
|
|
/* pci_disable_device(dev); */
|
|
|
|
err_enable_device:
|
|
|
|
framebuffer_release(info);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PCI remove */
|
|
|
|
|
2012-12-22 05:07:39 +08:00
|
|
|
static void vt8623_pci_remove(struct pci_dev *dev)
|
2007-05-09 17:35:31 +08:00
|
|
|
{
|
|
|
|
struct fb_info *info = pci_get_drvdata(dev);
|
|
|
|
|
|
|
|
if (info) {
|
2007-06-01 15:46:43 +08:00
|
|
|
struct vt8623fb_info *par = info->par;
|
|
|
|
|
drivers/video/fbdev/vt8623fb: Use arch_phys_wc_add() and pci_iomap_wc()
This driver uses the same area for MTRR as for the ioremap().
Convert the driver from using the x86-specific MTRR code to the
architecture-agnostic arch_phys_wc_add(). It will avoid MTRRs if
write-combining is available. In order to take advantage of that
also ensure the ioremapped area is requested as write-combining.
There are a few motivations for this:
a) Take advantage of PAT when available.
b) Help bury MTRR code away, MTRR is architecture-specific and on
x86 it is being replaced by PAT.
c) Help with the goal of eventually using _PAGE_CACHE_UC over
_PAGE_CACHE_UC_MINUS on x86 on ioremap_nocache() (see commit
de33c442e titled "x86 PAT: fix performance drop for glx,
use UC minus for ioremap(), ioremap_nocache() and
pci_mmap_page_range()").
The conversion done is expressed by the following Coccinelle
SmPL patch, it additionally required manual intervention to
address all the ifdeffery and removal of redundant things which
arch_phys_wc_add() already addresses such as verbose message
about when MTRR fails and doing nothing when we didn't get an
MTRR.
@ mtrr_found @
expression index, base, size;
@@
-index = mtrr_add(base, size, MTRR_TYPE_WRCOMB, 1);
+index = arch_phys_wc_add(base, size);
@ mtrr_rm depends on mtrr_found @
expression mtrr_found.index, mtrr_found.base, mtrr_found.size;
@@
-mtrr_del(index, base, size);
+arch_phys_wc_del(index);
@ mtrr_rm_zero_arg depends on mtrr_found @
expression mtrr_found.index;
@@
-mtrr_del(index, 0, 0);
+arch_phys_wc_del(index);
@ mtrr_rm_fb_info depends on mtrr_found @
struct fb_info *info;
expression mtrr_found.index;
@@
-mtrr_del(index, info->fix.smem_start, info->fix.smem_len);
+arch_phys_wc_del(index);
@ ioremap_replace_nocache depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap_nocache(base, size);
+info->screen_base = ioremap_wc(base, size);
@ ioremap_replace_default depends on mtrr_found @
struct fb_info *info;
expression base, size;
@@
-info->screen_base = ioremap(base, size);
+info->screen_base = ioremap_wc(base, size);
Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Antonino Daplas <adaplas@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Dave Airlie <airlied@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Lad, Prabhakar <prabhakar.csengg@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rob Clark <robdclark@gmail.com>
Cc: Suresh Siddha <sbsiddha@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: airlied@linux.ie
Cc: benh@kernel.crashing.org
Cc: bhelgaas@google.com
Cc: dan.j.williams@intel.com
Cc: konrad.wilk@oracle.com
Cc: linux-fbdev@vger.kernel.org
Cc: linux-pci@vger.kernel.org
Cc: mst@redhat.com
Cc: toshi.kani@hp.com
Cc: vinod.koul@intel.com
Cc: xen-devel@lists.xensource.com
Link: http://lkml.kernel.org/r/1440443613-13696-9-git-send-email-mcgrof@do-not-panic.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-08-25 03:13:30 +08:00
|
|
|
arch_phys_wc_del(par->wc_cookie);
|
2007-05-09 17:35:31 +08:00
|
|
|
unregister_framebuffer(info);
|
|
|
|
fb_dealloc_cmap(&info->cmap);
|
|
|
|
|
|
|
|
pci_iounmap(dev, info->screen_base);
|
|
|
|
pci_iounmap(dev, par->mmio_base);
|
|
|
|
pci_release_regions(dev);
|
|
|
|
/* pci_disable_device(dev); */
|
|
|
|
|
|
|
|
framebuffer_release(info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
|
|
|
/* PCI suspend */
|
|
|
|
|
|
|
|
static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
|
|
|
|
{
|
|
|
|
struct fb_info *info = pci_get_drvdata(dev);
|
|
|
|
struct vt8623fb_info *par = info->par;
|
|
|
|
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_info(info->device, "suspend\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
|
2011-01-26 07:07:35 +08:00
|
|
|
console_lock();
|
2007-05-09 17:35:31 +08:00
|
|
|
mutex_lock(&(par->open_lock));
|
|
|
|
|
|
|
|
if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
|
|
|
|
mutex_unlock(&(par->open_lock));
|
2011-01-26 07:07:35 +08:00
|
|
|
console_unlock();
|
2007-05-09 17:35:31 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
fb_set_suspend(info, 1);
|
|
|
|
|
|
|
|
pci_save_state(dev);
|
|
|
|
pci_disable_device(dev);
|
|
|
|
pci_set_power_state(dev, pci_choose_state(dev, state));
|
|
|
|
|
|
|
|
mutex_unlock(&(par->open_lock));
|
2011-01-26 07:07:35 +08:00
|
|
|
console_unlock();
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* PCI resume */
|
|
|
|
|
|
|
|
static int vt8623_pci_resume(struct pci_dev* dev)
|
|
|
|
{
|
|
|
|
struct fb_info *info = pci_get_drvdata(dev);
|
|
|
|
struct vt8623fb_info *par = info->par;
|
|
|
|
|
2008-08-06 04:01:06 +08:00
|
|
|
dev_info(info->device, "resume\n");
|
2007-05-09 17:35:31 +08:00
|
|
|
|
2011-01-26 07:07:35 +08:00
|
|
|
console_lock();
|
2007-05-09 17:35:31 +08:00
|
|
|
mutex_lock(&(par->open_lock));
|
|
|
|
|
2008-07-30 13:33:28 +08:00
|
|
|
if (par->ref_count == 0)
|
|
|
|
goto fail;
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
pci_set_power_state(dev, PCI_D0);
|
|
|
|
pci_restore_state(dev);
|
|
|
|
|
|
|
|
if (pci_enable_device(dev))
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
pci_set_master(dev);
|
|
|
|
|
|
|
|
vt8623fb_set_par(info);
|
|
|
|
fb_set_suspend(info, 0);
|
|
|
|
|
|
|
|
fail:
|
2008-07-30 13:33:28 +08:00
|
|
|
mutex_unlock(&(par->open_lock));
|
2011-01-26 07:07:35 +08:00
|
|
|
console_unlock();
|
2007-05-09 17:35:31 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define vt8623_pci_suspend NULL
|
|
|
|
#define vt8623_pci_resume NULL
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
|
|
|
/* List of boards that we are trying to support */
|
|
|
|
|
2017-08-01 23:20:45 +08:00
|
|
|
static const struct pci_device_id vt8623_devices[] = {
|
2007-05-09 17:35:31 +08:00
|
|
|
{PCI_DEVICE(PCI_VENDOR_ID_VIA, 0x3122)},
|
|
|
|
{0, 0, 0, 0, 0, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, vt8623_devices);
|
|
|
|
|
|
|
|
static struct pci_driver vt8623fb_pci_driver = {
|
|
|
|
.name = "vt8623fb",
|
|
|
|
.id_table = vt8623_devices,
|
|
|
|
.probe = vt8623_pci_probe,
|
2012-12-22 05:07:39 +08:00
|
|
|
.remove = vt8623_pci_remove,
|
2007-05-09 17:35:31 +08:00
|
|
|
.suspend = vt8623_pci_suspend,
|
|
|
|
.resume = vt8623_pci_resume,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Cleanup */
|
|
|
|
|
|
|
|
static void __exit vt8623fb_cleanup(void)
|
|
|
|
{
|
|
|
|
pr_debug("vt8623fb: cleaning up\n");
|
|
|
|
pci_unregister_driver(&vt8623fb_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Driver Initialisation */
|
|
|
|
|
2007-07-17 19:05:47 +08:00
|
|
|
static int __init vt8623fb_init(void)
|
2007-05-09 17:35:31 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
#ifndef MODULE
|
|
|
|
char *option = NULL;
|
|
|
|
|
|
|
|
if (fb_get_options("vt8623fb", &option))
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
if (option && *option)
|
2008-04-28 17:15:08 +08:00
|
|
|
mode_option = option;
|
2007-05-09 17:35:31 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
pr_debug("vt8623fb: initializing\n");
|
|
|
|
return pci_register_driver(&vt8623fb_pci_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Modularization */
|
|
|
|
|
|
|
|
module_init(vt8623fb_init);
|
|
|
|
module_exit(vt8623fb_cleanup);
|