aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/Kconfig73
-rw-r--r--drivers/video/Makefile2
-rw-r--r--drivers/video/am200epd.c295
-rw-r--r--drivers/video/amifb.c2
-rw-r--r--drivers/video/arkfb.c32
-rw-r--r--drivers/video/atafb.c2
-rw-r--r--drivers/video/atmel_lcdfb.c74
-rw-r--r--drivers/video/aty/aty128fb.c4
-rw-r--r--drivers/video/aty/atyfb_base.c7
-rw-r--r--drivers/video/aty/mach64_ct.c16
-rw-r--r--drivers/video/aty/radeon_base.c51
-rw-r--r--drivers/video/aty/radeon_i2c.c13
-rw-r--r--drivers/video/aty/radeon_monitor.c56
-rw-r--r--drivers/video/aty/radeonfb.h20
-rw-r--r--drivers/video/bf54x-lq043fb.c8
-rw-r--r--drivers/video/bw2.c5
-rw-r--r--drivers/video/cfbcopyarea.c23
-rw-r--r--drivers/video/cfbfillrect.c48
-rw-r--r--drivers/video/cfbimgblt.c54
-rw-r--r--drivers/video/cg14.c6
-rw-r--r--drivers/video/cg3.c2
-rw-r--r--drivers/video/cg6.c2
-rw-r--r--drivers/video/cirrusfb.c6
-rw-r--r--drivers/video/console/fbcon.c5
-rw-r--r--drivers/video/console/fbcon.h12
-rw-r--r--drivers/video/fb_draw.h31
-rw-r--r--drivers/video/fbmem.c95
-rw-r--r--drivers/video/ffb.c7
-rw-r--r--drivers/video/fsl-diu-fb.c1721
-rw-r--r--drivers/video/fsl-diu-fb.h223
-rw-r--r--drivers/video/geode/Kconfig20
-rw-r--r--drivers/video/geode/Makefile2
-rw-r--r--drivers/video/geode/display_gx.c125
-rw-r--r--drivers/video/geode/display_gx.h101
-rw-r--r--drivers/video/geode/gxfb.h358
-rw-r--r--drivers/video/geode/gxfb_core.c160
-rw-r--r--drivers/video/geode/lxfb.h527
-rw-r--r--drivers/video/geode/lxfb_core.c118
-rw-r--r--drivers/video/geode/lxfb_ops.c699
-rw-r--r--drivers/video/geode/suspend_gx.c267
-rw-r--r--drivers/video/geode/video_gx.c162
-rw-r--r--drivers/video/geode/video_gx.h72
-rw-r--r--drivers/video/gxt4500.c2
-rw-r--r--drivers/video/hecubafb.c302
-rw-r--r--drivers/video/imsttfb.c8
-rw-r--r--drivers/video/imxfb.c6
-rw-r--r--drivers/video/intelfb/intelfb.h12
-rw-r--r--drivers/video/intelfb/intelfb_i2c.c2
-rw-r--r--drivers/video/intelfb/intelfbdrv.c12
-rw-r--r--drivers/video/intelfb/intelfbhw.c16
-rw-r--r--drivers/video/leo.c2
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.c36
-rw-r--r--drivers/video/matrox/matroxfb_Ti3026.c16
-rw-r--r--drivers/video/matrox/matroxfb_accel.c14
-rw-r--r--drivers/video/matrox/matroxfb_base.c42
-rw-r--r--drivers/video/matrox/matroxfb_crtc2.c2
-rw-r--r--drivers/video/matrox/matroxfb_maven.c2
-rw-r--r--drivers/video/matrox/matroxfb_misc.c12
-rw-r--r--drivers/video/metronomefb.c328
-rw-r--r--drivers/video/modedb.c26
-rw-r--r--drivers/video/n411.c202
-rw-r--r--drivers/video/nvidia/nv_hw.c4
-rw-r--r--drivers/video/nvidia/nv_setup.c4
-rw-r--r--drivers/video/nvidia/nvidia.c9
-rw-r--r--drivers/video/offb.c15
-rw-r--r--drivers/video/p9100.c2
-rw-r--r--drivers/video/pm2fb.c24
-rw-r--r--drivers/video/pm3fb.c4
-rw-r--r--drivers/video/riva/fbdev.c12
-rw-r--r--drivers/video/riva/nv_driver.c7
-rw-r--r--drivers/video/riva/riva_hw.c4
-rw-r--r--drivers/video/s3c2410fb.c6
-rw-r--r--drivers/video/s3fb.c34
-rw-r--r--drivers/video/sa1100fb.h2
-rw-r--r--drivers/video/savage/savagefb-i2c.c2
-rw-r--r--drivers/video/sis/sis.h2
-rw-r--r--drivers/video/sstfb.c10
-rw-r--r--drivers/video/stifb.c4
-rw-r--r--drivers/video/syscopyarea.c20
-rw-r--r--drivers/video/sysfillrect.c49
-rw-r--r--drivers/video/sysimgblt.c49
-rw-r--r--drivers/video/tcx.c10
-rw-r--r--drivers/video/tdfxfb.c2
-rw-r--r--drivers/video/tridentfb.c14
-rw-r--r--drivers/video/uvesafb.c9
-rw-r--r--drivers/video/vermilion/vermilion.c5
-rw-r--r--drivers/video/vt8623fb.c38
-rw-r--r--drivers/video/w100fb.c6
88 files changed, 5169 insertions, 1726 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index e3dc8f8d0c3e..a576dc261732 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -139,6 +139,30 @@ config FB_SYS_IMAGEBLIT
139 blitting. This is used by drivers that don't provide their own 139 blitting. This is used by drivers that don't provide their own
140 (accelerated) version and the framebuffer is in system RAM. 140 (accelerated) version and the framebuffer is in system RAM.
141 141
142menuconfig FB_FOREIGN_ENDIAN
143 bool "Framebuffer foreign endianness support"
144 depends on FB
145 ---help---
146 This menu will let you enable support for the framebuffers with
147 non-native endianness (e.g. Little-Endian framebuffer on a
148 Big-Endian machine). Most probably you don't have such hardware,
149 so it's safe to say "n" here.
150
151choice
152 prompt "Choice endianness support"
153 depends on FB_FOREIGN_ENDIAN
154
155config FB_BOTH_ENDIAN
156 bool "Support for Big- and Little-Endian framebuffers"
157
158config FB_BIG_ENDIAN
159 bool "Support for Big-Endian framebuffers only"
160
161config FB_LITTLE_ENDIAN
162 bool "Support for Little-Endian framebuffers only"
163
164endchoice
165
142config FB_SYS_FOPS 166config FB_SYS_FOPS
143 tristate 167 tristate
144 depends on FB 168 depends on FB
@@ -149,6 +173,16 @@ config FB_DEFERRED_IO
149 depends on FB 173 depends on FB
150 default y 174 default y
151 175
176config FB_METRONOME
177 tristate
178 depends on FB
179 depends on FB_DEFERRED_IO
180
181config FB_HECUBA
182 tristate
183 depends on FB
184 depends on FB_DEFERRED_IO
185
152config FB_SVGALIB 186config FB_SVGALIB
153 tristate 187 tristate
154 depends on FB 188 depends on FB
@@ -546,7 +580,7 @@ config FB_VGA16
546 580
547config FB_BF54X_LQ043 581config FB_BF54X_LQ043
548 tristate "SHARP LQ043 TFT LCD (BF548 EZKIT)" 582 tristate "SHARP LQ043 TFT LCD (BF548 EZKIT)"
549 depends on FB && (BF54x) 583 depends on FB && (BF54x) && !BF542
550 select FB_CFB_FILLRECT 584 select FB_CFB_FILLRECT
551 select FB_CFB_COPYAREA 585 select FB_CFB_COPYAREA
552 select FB_CFB_IMAGEBLIT 586 select FB_CFB_IMAGEBLIT
@@ -674,20 +708,18 @@ config FB_IMAC
674 help 708 help
675 This is the frame buffer device driver for the Intel-based Macintosh 709 This is the frame buffer device driver for the Intel-based Macintosh
676 710
677config FB_HECUBA 711config FB_N411
678 tristate "Hecuba board support" 712 tristate "N411 Apollo/Hecuba devkit support"
679 depends on FB && X86 && MMU 713 depends on FB && X86 && MMU
680 select FB_SYS_FILLRECT 714 select FB_SYS_FILLRECT
681 select FB_SYS_COPYAREA 715 select FB_SYS_COPYAREA
682 select FB_SYS_IMAGEBLIT 716 select FB_SYS_IMAGEBLIT
683 select FB_SYS_FOPS 717 select FB_SYS_FOPS
684 select FB_DEFERRED_IO 718 select FB_DEFERRED_IO
719 select FB_HECUBA
685 help 720 help
686 This enables support for the Hecuba board. This driver was tested 721 This enables support for the Apollo display controller in its
687 with an E-Ink 800x600 display and x86 SBCs through a 16 bit GPIO 722 Hecuba form using the n411 devkit.
688 interface (8 bit data, 4 bit control). If you anticipate using
689 this driver, say Y or M; otherwise say N. You must specify the
690 GPIO IO address to be used for setting control and data.
691 723
692config FB_HGA 724config FB_HGA
693 tristate "Hercules mono graphics support" 725 tristate "Hercules mono graphics support"
@@ -1087,7 +1119,7 @@ config FB_CARILLO_RANCH
1087 This driver supports the LE80578 (Carillo Ranch) board 1119 This driver supports the LE80578 (Carillo Ranch) board
1088 1120
1089config FB_INTEL 1121config FB_INTEL
1090 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G support (EXPERIMENTAL)" 1122 tristate "Intel 830M/845G/852GM/855GM/865G/915G/945G/945GM/965G/965GM support (EXPERIMENTAL)"
1091 depends on FB && EXPERIMENTAL && PCI && X86 1123 depends on FB && EXPERIMENTAL && PCI && X86
1092 select AGP 1124 select AGP
1093 select AGP_INTEL 1125 select AGP_INTEL
@@ -1097,7 +1129,7 @@ config FB_INTEL
1097 select FB_CFB_IMAGEBLIT 1129 select FB_CFB_IMAGEBLIT
1098 help 1130 help
1099 This driver supports the on-board graphics built in to the Intel 1131 This driver supports the on-board graphics built in to the Intel
1100 830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM chipsets. 1132 830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM chipsets.
1101 Say Y if you have and plan to use such a board. 1133 Say Y if you have and plan to use such a board.
1102 1134
1103 If you say Y here and want DDC/I2C support you must first say Y to 1135 If you say Y here and want DDC/I2C support you must first say Y to
@@ -1779,6 +1811,16 @@ config FB_MBX_DEBUG
1779 1811
1780 If unsure, say N. 1812 If unsure, say N.
1781 1813
1814config FB_FSL_DIU
1815 tristate "Freescale DIU framebuffer support"
1816 depends on FB && FSL_SOC
1817 select FB_CFB_FILLRECT
1818 select FB_CFB_COPYAREA
1819 select FB_CFB_IMAGEBLIT
1820 select PPC_LIB_RHEAP
1821 ---help---
1822 Framebuffer driver for the Freescale SoC DIU
1823
1782config FB_W100 1824config FB_W100
1783 tristate "W100 frame buffer support" 1825 tristate "W100 frame buffer support"
1784 depends on FB && PXA_SHARPSL 1826 depends on FB && PXA_SHARPSL
@@ -1893,19 +1935,18 @@ config FB_XILINX
1893 framebuffer. ML300 carries a 640*480 LCD display on the board, 1935 framebuffer. ML300 carries a 640*480 LCD display on the board,
1894 ML403 uses a standard DB15 VGA connector. 1936 ML403 uses a standard DB15 VGA connector.
1895 1937
1896config FB_METRONOME 1938config FB_AM200EPD
1897 tristate "Metronome display controller support" 1939 tristate "AM-200 E-Ink EPD devkit support"
1898 depends on FB && ARCH_PXA && MMU 1940 depends on FB && ARCH_PXA && MMU
1899 select FB_SYS_FILLRECT 1941 select FB_SYS_FILLRECT
1900 select FB_SYS_COPYAREA 1942 select FB_SYS_COPYAREA
1901 select FB_SYS_IMAGEBLIT 1943 select FB_SYS_IMAGEBLIT
1902 select FB_SYS_FOPS 1944 select FB_SYS_FOPS
1903 select FB_DEFERRED_IO 1945 select FB_DEFERRED_IO
1946 select FB_METRONOME
1904 help 1947 help
1905 This enables support for the Metronome display controller. Tested 1948 This enables support for the Metronome display controller used on
1906 with an E-Ink 800x600 display and Gumstix Connex through an AMLCD 1949 the E-Ink AM-200 EPD devkit.
1907 interface. Please read <file:Documentation/fb/metronomefb.txt>
1908 for more information.
1909 1950
1910config FB_VIRTUAL 1951config FB_VIRTUAL
1911 tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)" 1952 tristate "Virtual Frame Buffer support (ONLY FOR TESTING!)"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index f172b9b73314..04bca35403ff 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o
29 29
30# Hardware specific drivers go first 30# Hardware specific drivers go first
31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o 31obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o
32obj-$(CONFIG_FB_AM200EPD) += am200epd.o
32obj-$(CONFIG_FB_ARC) += arcfb.o 33obj-$(CONFIG_FB_ARC) += arcfb.o
33obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o 34obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o
34obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o 35obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o
@@ -107,6 +108,7 @@ obj-$(CONFIG_FB_METRONOME) += metronomefb.o
107obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o 108obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o
108obj-$(CONFIG_FB_IMX) += imxfb.o 109obj-$(CONFIG_FB_IMX) += imxfb.o
109obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o 110obj-$(CONFIG_FB_S3C2410) += s3c2410fb.o
111obj-$(CONFIG_FB_FSL_DIU) += fsl-diu-fb.o
110obj-$(CONFIG_FB_PNX4008_DUM) += pnx4008/ 112obj-$(CONFIG_FB_PNX4008_DUM) += pnx4008/
111obj-$(CONFIG_FB_PNX4008_DUM_RGB) += pnx4008/ 113obj-$(CONFIG_FB_PNX4008_DUM_RGB) += pnx4008/
112obj-$(CONFIG_FB_IBM_GXT4500) += gxt4500.o 114obj-$(CONFIG_FB_IBM_GXT4500) += gxt4500.o
diff --git a/drivers/video/am200epd.c b/drivers/video/am200epd.c
new file mode 100644
index 000000000000..51e26c1f5e8b
--- /dev/null
+++ b/drivers/video/am200epd.c
@@ -0,0 +1,295 @@
1/*
2 * linux/drivers/video/am200epd.c -- Platform device for AM200 EPD kit
3 *
4 * Copyright (C) 2008, Jaya Kumar
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
8 * more details.
9 *
10 * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
11 *
12 * This work was made possible by help and equipment support from E-Ink
13 * Corporation. http://support.eink.com/community
14 *
15 * This driver is written to be used with the Metronome display controller.
16 * on the AM200 EPD prototype kit/development kit with an E-Ink 800x600
17 * Vizplex EPD on a Gumstix board using the Lyre interface board.
18 *
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/errno.h>
24#include <linux/string.h>
25#include <linux/delay.h>
26#include <linux/interrupt.h>
27#include <linux/fb.h>
28#include <linux/init.h>
29#include <linux/platform_device.h>
30#include <linux/list.h>
31#include <linux/uaccess.h>
32#include <linux/irq.h>
33
34#include <video/metronomefb.h>
35
36#include <asm/arch/pxa-regs.h>
37
38/* register offsets for gpio control */
39#define LED_GPIO_PIN 51
40#define STDBY_GPIO_PIN 48
41#define RST_GPIO_PIN 49
42#define RDY_GPIO_PIN 32
43#define ERR_GPIO_PIN 17
44#define PCBPWR_GPIO_PIN 16
45
46#define AF_SEL_GPIO_N 0x3
47#define GAFR0_U_OFFSET(pin) ((pin - 16) * 2)
48#define GAFR1_L_OFFSET(pin) ((pin - 32) * 2)
49#define GAFR1_U_OFFSET(pin) ((pin - 48) * 2)
50#define GPDR1_OFFSET(pin) (pin - 32)
51#define GPCR1_OFFSET(pin) (pin - 32)
52#define GPSR1_OFFSET(pin) (pin - 32)
53#define GPCR0_OFFSET(pin) (pin)
54#define GPSR0_OFFSET(pin) (pin)
55
56static void am200_set_gpio_output(int pin, int val)
57{
58 u8 index;
59
60 index = pin >> 4;
61
62 switch (index) {
63 case 1:
64 if (val)
65 GPSR0 |= (1 << GPSR0_OFFSET(pin));
66 else
67 GPCR0 |= (1 << GPCR0_OFFSET(pin));
68 break;
69 case 2:
70 break;
71 case 3:
72 if (val)
73 GPSR1 |= (1 << GPSR1_OFFSET(pin));
74 else
75 GPCR1 |= (1 << GPCR1_OFFSET(pin));
76 break;
77 default:
78 printk(KERN_ERR "unimplemented\n");
79 }
80}
81
82static void __devinit am200_init_gpio_pin(int pin, int dir)
83{
84 u8 index;
85 /* dir 0 is output, 1 is input
86 - do 2 things here:
87 - set gpio alternate function to standard gpio
88 - set gpio direction to input or output */
89
90 index = pin >> 4;
91 switch (index) {
92 case 1:
93 GAFR0_U &= ~(AF_SEL_GPIO_N << GAFR0_U_OFFSET(pin));
94
95 if (dir)
96 GPDR0 &= ~(1 << pin);
97 else
98 GPDR0 |= (1 << pin);
99 break;
100 case 2:
101 GAFR1_L &= ~(AF_SEL_GPIO_N << GAFR1_L_OFFSET(pin));
102
103 if (dir)
104 GPDR1 &= ~(1 << GPDR1_OFFSET(pin));
105 else
106 GPDR1 |= (1 << GPDR1_OFFSET(pin));
107 break;
108 case 3:
109 GAFR1_U &= ~(AF_SEL_GPIO_N << GAFR1_U_OFFSET(pin));
110
111 if (dir)
112 GPDR1 &= ~(1 << GPDR1_OFFSET(pin));
113 else
114 GPDR1 |= (1 << GPDR1_OFFSET(pin));
115 break;
116 default:
117 printk(KERN_ERR "unimplemented\n");
118 }
119}
120
121static void am200_init_gpio_regs(struct metronomefb_par *par)
122{
123 am200_init_gpio_pin(LED_GPIO_PIN, 0);
124 am200_set_gpio_output(LED_GPIO_PIN, 0);
125
126 am200_init_gpio_pin(STDBY_GPIO_PIN, 0);
127 am200_set_gpio_output(STDBY_GPIO_PIN, 0);
128
129 am200_init_gpio_pin(RST_GPIO_PIN, 0);
130 am200_set_gpio_output(RST_GPIO_PIN, 0);
131
132 am200_init_gpio_pin(RDY_GPIO_PIN, 1);
133
134 am200_init_gpio_pin(ERR_GPIO_PIN, 1);
135
136 am200_init_gpio_pin(PCBPWR_GPIO_PIN, 0);
137 am200_set_gpio_output(PCBPWR_GPIO_PIN, 0);
138}
139
140static void am200_disable_lcd_controller(struct metronomefb_par *par)
141{
142 LCSR = 0xffffffff; /* Clear LCD Status Register */
143 LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */
144
145 /* we reset and just wait for things to settle */
146 msleep(200);
147}
148
149static void am200_enable_lcd_controller(struct metronomefb_par *par)
150{
151 LCSR = 0xffffffff;
152 FDADR0 = par->metromem_desc_dma;
153 LCCR0 |= LCCR0_ENB;
154}
155
156static void am200_init_lcdc_regs(struct metronomefb_par *par)
157{
158 /* here we do:
159 - disable the lcd controller
160 - setup lcd control registers
161 - setup dma descriptor
162 - reenable lcd controller
163 */
164
165 /* disable the lcd controller */
166 am200_disable_lcd_controller(par);
167
168 /* setup lcd control registers */
169 LCCR0 = LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM | LCCR0_PAS
170 | LCCR0_QDM | LCCR0_BM | LCCR0_OUM;
171
172 LCCR1 = (par->info->var.xres/2 - 1) /* pixels per line */
173 | (27 << 10) /* hsync pulse width - 1 */
174 | (33 << 16) /* eol pixel count */
175 | (33 << 24); /* bol pixel count */
176
177 LCCR2 = (par->info->var.yres - 1) /* lines per panel */
178 | (24 << 10) /* vsync pulse width - 1 */
179 | (2 << 16) /* eof pixel count */
180 | (0 << 24); /* bof pixel count */
181
182 LCCR3 = 2 /* pixel clock divisor */
183 | (24 << 8) /* AC Bias pin freq */
184 | LCCR3_16BPP /* BPP */
185 | LCCR3_PCP; /* PCP falling edge */
186
187}
188
189static void am200_post_dma_setup(struct metronomefb_par *par)
190{
191 par->metromem_desc->mFDADR0 = par->metromem_desc_dma;
192 par->metromem_desc->mFSADR0 = par->metromem_dma;
193 par->metromem_desc->mFIDR0 = 0;
194 par->metromem_desc->mLDCMD0 = par->info->var.xres
195 * par->info->var.yres;
196 am200_enable_lcd_controller(par);
197}
198
199static void am200_free_irq(struct fb_info *info)
200{
201 free_irq(IRQ_GPIO(RDY_GPIO_PIN), info);
202}
203
204static irqreturn_t am200_handle_irq(int irq, void *dev_id)
205{
206 struct fb_info *info = dev_id;
207 struct metronomefb_par *par = info->par;
208
209 wake_up_interruptible(&par->waitq);
210 return IRQ_HANDLED;
211}
212
213static int am200_setup_irq(struct fb_info *info)
214{
215 int retval;
216
217 retval = request_irq(IRQ_GPIO(RDY_GPIO_PIN), am200_handle_irq,
218 IRQF_DISABLED, "AM200", info);
219 if (retval) {
220 printk(KERN_ERR "am200epd: request_irq failed: %d\n", retval);
221 return retval;
222 }
223
224 return set_irq_type(IRQ_GPIO(RDY_GPIO_PIN), IRQT_FALLING);
225}
226
227static void am200_set_rst(struct metronomefb_par *par, int state)
228{
229 am200_set_gpio_output(RST_GPIO_PIN, state);
230}
231
232static void am200_set_stdby(struct metronomefb_par *par, int state)
233{
234 am200_set_gpio_output(STDBY_GPIO_PIN, state);
235}
236
237static int am200_wait_event(struct metronomefb_par *par)
238{
239 return wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ);
240}
241
242static int am200_wait_event_intr(struct metronomefb_par *par)
243{
244 return wait_event_interruptible_timeout(par->waitq, (GPLR1 & 0x01), HZ);
245}
246
247static struct metronome_board am200_board = {
248 .owner = THIS_MODULE,
249 .free_irq = am200_free_irq,
250 .setup_irq = am200_setup_irq,
251 .init_gpio_regs = am200_init_gpio_regs,
252 .init_lcdc_regs = am200_init_lcdc_regs,
253 .post_dma_setup = am200_post_dma_setup,
254 .set_rst = am200_set_rst,
255 .set_stdby = am200_set_stdby,
256 .met_wait_event = am200_wait_event,
257 .met_wait_event_intr = am200_wait_event_intr,
258};
259
260static struct platform_device *am200_device;
261
262static int __init am200_init(void)
263{
264 int ret;
265
266 /* request our platform independent driver */
267 request_module("metronomefb");
268
269 am200_device = platform_device_alloc("metronomefb", -1);
270 if (!am200_device)
271 return -ENOMEM;
272
273 platform_device_add_data(am200_device, &am200_board,
274 sizeof(am200_board));
275
276 /* this _add binds metronomefb to am200. metronomefb refcounts am200 */
277 ret = platform_device_add(am200_device);
278
279 if (ret)
280 platform_device_put(am200_device);
281
282 return ret;
283}
284
285static void __exit am200_exit(void)
286{
287 platform_device_unregister(am200_device);
288}
289
290module_init(am200_init);
291module_exit(am200_exit);
292
293MODULE_DESCRIPTION("board driver for am200 metronome epd kit");
294MODULE_AUTHOR("Jaya Kumar");
295MODULE_LICENSE("GPL");
diff --git a/drivers/video/amifb.c b/drivers/video/amifb.c
index 4c9ec3f58c52..e6492c1048bf 100644
--- a/drivers/video/amifb.c
+++ b/drivers/video/amifb.c
@@ -96,7 +96,7 @@
96#endif 96#endif
97 97
98#ifdef DEBUG 98#ifdef DEBUG
99# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) 99# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
100#else 100#else
101# define DPRINTK(fmt, args...) 101# define DPRINTK(fmt, args...)
102#endif 102#endif
diff --git a/drivers/video/arkfb.c b/drivers/video/arkfb.c
index 8a1b07c74394..5001bd4ef466 100644
--- a/drivers/video/arkfb.c
+++ b/drivers/video/arkfb.c
@@ -101,7 +101,7 @@ static const struct svga_timing_regs ark_timing_regs = {
101 101
102/* Module parameters */ 102/* Module parameters */
103 103
104static char *mode = "640x480-8@60"; 104static char *mode_option __devinitdata = "640x480-8@60";
105 105
106#ifdef CONFIG_MTRR 106#ifdef CONFIG_MTRR
107static int mtrr = 1; 107static int mtrr = 1;
@@ -111,8 +111,10 @@ MODULE_AUTHOR("(c) 2007 Ondrej Zajicek <santiago@crfreenet.org>");
111MODULE_LICENSE("GPL"); 111MODULE_LICENSE("GPL");
112MODULE_DESCRIPTION("fbdev driver for ARK 2000PV"); 112MODULE_DESCRIPTION("fbdev driver for ARK 2000PV");
113 113
114module_param(mode, charp, 0444); 114module_param(mode_option, charp, 0444);
115MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc)"); 115MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
116module_param_named(mode, mode_option, charp, 0444);
117MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) (deprecated)");
116 118
117#ifdef CONFIG_MTRR 119#ifdef CONFIG_MTRR
118module_param(mtrr, int, 0444); 120module_param(mtrr, int, 0444);
@@ -941,7 +943,7 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
941 } 943 }
942 944
943 /* Allocate and fill driver data structure */ 945 /* Allocate and fill driver data structure */
944 info = framebuffer_alloc(sizeof(struct arkfb_info), NULL); 946 info = framebuffer_alloc(sizeof(struct arkfb_info), &(dev->dev));
945 if (! info) { 947 if (! info) {
946 dev_err(&(dev->dev), "cannot allocate memory\n"); 948 dev_err(&(dev->dev), "cannot allocate memory\n");
947 return -ENOMEM; 949 return -ENOMEM;
@@ -956,20 +958,20 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
956 /* Prepare PCI device */ 958 /* Prepare PCI device */
957 rc = pci_enable_device(dev); 959 rc = pci_enable_device(dev);
958 if (rc < 0) { 960 if (rc < 0) {
959 dev_err(&(dev->dev), "cannot enable PCI device\n"); 961 dev_err(info->dev, "cannot enable PCI device\n");
960 goto err_enable_device; 962 goto err_enable_device;
961 } 963 }
962 964
963 rc = pci_request_regions(dev, "arkfb"); 965 rc = pci_request_regions(dev, "arkfb");
964 if (rc < 0) { 966 if (rc < 0) {
965 dev_err(&(dev->dev), "cannot reserve framebuffer region\n"); 967 dev_err(info->dev, "cannot reserve framebuffer region\n");
966 goto err_request_regions; 968 goto err_request_regions;
967 } 969 }
968 970
969 par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info); 971 par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info);
970 if (! par->dac) { 972 if (! par->dac) {
971 rc = -ENOMEM; 973 rc = -ENOMEM;
972 dev_err(&(dev->dev), "RAMDAC initialization failed\n"); 974 dev_err(info->dev, "RAMDAC initialization failed\n");
973 goto err_dac; 975 goto err_dac;
974 } 976 }
975 977
@@ -980,7 +982,7 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
980 info->screen_base = pci_iomap(dev, 0, 0); 982 info->screen_base = pci_iomap(dev, 0, 0);
981 if (! info->screen_base) { 983 if (! info->screen_base) {
982 rc = -ENOMEM; 984 rc = -ENOMEM;
983 dev_err(&(dev->dev), "iomap for framebuffer failed\n"); 985 dev_err(info->dev, "iomap for framebuffer failed\n");
984 goto err_iomap; 986 goto err_iomap;
985 } 987 }
986 988
@@ -999,22 +1001,22 @@ static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_
999 info->pseudo_palette = (void*) (par->pseudo_palette); 1001 info->pseudo_palette = (void*) (par->pseudo_palette);
1000 1002
1001 /* Prepare startup mode */ 1003 /* Prepare startup mode */
1002 rc = fb_find_mode(&(info->var), info, mode, NULL, 0, NULL, 8); 1004 rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
1003 if (! ((rc == 1) || (rc == 2))) { 1005 if (! ((rc == 1) || (rc == 2))) {
1004 rc = -EINVAL; 1006 rc = -EINVAL;
1005 dev_err(&(dev->dev), "mode %s not found\n", mode); 1007 dev_err(info->dev, "mode %s not found\n", mode_option);
1006 goto err_find_mode; 1008 goto err_find_mode;
1007 } 1009 }
1008 1010
1009 rc = fb_alloc_cmap(&info->cmap, 256, 0); 1011 rc = fb_alloc_cmap(&info->cmap, 256, 0);
1010 if (rc < 0) { 1012 if (rc < 0) {
1011 dev_err(&(dev->dev), "cannot allocate colormap\n"); 1013 dev_err(info->dev, "cannot allocate colormap\n");
1012 goto err_alloc_cmap; 1014 goto err_alloc_cmap;
1013 } 1015 }
1014 1016
1015 rc = register_framebuffer(info); 1017 rc = register_framebuffer(info);
1016 if (rc < 0) { 1018 if (rc < 0) {
1017 dev_err(&(dev->dev), "cannot register framebugger\n"); 1019 dev_err(info->dev, "cannot register framebugger\n");
1018 goto err_reg_fb; 1020 goto err_reg_fb;
1019 } 1021 }
1020 1022
@@ -1088,7 +1090,7 @@ static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
1088 struct fb_info *info = pci_get_drvdata(dev); 1090 struct fb_info *info = pci_get_drvdata(dev);
1089 struct arkfb_info *par = info->par; 1091 struct arkfb_info *par = info->par;
1090 1092
1091 dev_info(&(dev->dev), "suspend\n"); 1093 dev_info(info->dev, "suspend\n");
1092 1094
1093 acquire_console_sem(); 1095 acquire_console_sem();
1094 mutex_lock(&(par->open_lock)); 1096 mutex_lock(&(par->open_lock));
@@ -1119,7 +1121,7 @@ static int ark_pci_resume (struct pci_dev* dev)
1119 struct fb_info *info = pci_get_drvdata(dev); 1121 struct fb_info *info = pci_get_drvdata(dev);
1120 struct arkfb_info *par = info->par; 1122 struct arkfb_info *par = info->par;
1121 1123
1122 dev_info(&(dev->dev), "resume\n"); 1124 dev_info(info->dev, "resume\n");
1123 1125
1124 acquire_console_sem(); 1126 acquire_console_sem();
1125 mutex_lock(&(par->open_lock)); 1127 mutex_lock(&(par->open_lock));
@@ -1190,7 +1192,7 @@ static int __init arkfb_init(void)
1190 return -ENODEV; 1192 return -ENODEV;
1191 1193
1192 if (option && *option) 1194 if (option && *option)
1193 mode = option; 1195 mode_option = option;
1194#endif 1196#endif
1195 1197
1196 pr_debug("arkfb: initializing\n"); 1198 pr_debug("arkfb: initializing\n");
diff --git a/drivers/video/atafb.c b/drivers/video/atafb.c
index 5d4fbaa53a6c..dff35474b854 100644
--- a/drivers/video/atafb.c
+++ b/drivers/video/atafb.c
@@ -1270,7 +1270,7 @@ again:
1270 1270
1271 gstart = (prescale / 2 + plen * left_margin) / prescale; 1271 gstart = (prescale / 2 + plen * left_margin) / prescale;
1272 /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */ 1272 /* gend1 is for hde (gend-gstart multiple of align), shifter's xres */
1273 gend1 = gstart + ((xres + align - 1) / align) * align * plen / prescale; 1273 gend1 = gstart + roundup(xres, align) * plen / prescale;
1274 /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */ 1274 /* gend2 is for hbb, visible xres (rest to gend1 is cut off by hblank) */
1275 gend2 = gstart + xres * plen / prescale; 1275 gend2 = gstart + xres * plen / prescale;
1276 par->HHT = plen * (left_margin + xres + right_margin) / 1276 par->HHT = plen * (left_margin + xres + right_margin) /
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index fc65c02306dd..8ffdf3578768 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -31,7 +31,8 @@
31#define ATMEL_LCDC_CVAL_DEFAULT 0xc8 31#define ATMEL_LCDC_CVAL_DEFAULT 0xc8
32#define ATMEL_LCDC_DMA_BURST_LEN 8 32#define ATMEL_LCDC_DMA_BURST_LEN 8
33 33
34#if defined(CONFIG_ARCH_AT91SAM9263) || defined(CONFIG_ARCH_AT91CAP9) 34#if defined(CONFIG_ARCH_AT91SAM9263) || defined(CONFIG_ARCH_AT91CAP9) || \
35 defined(CONFIG_ARCH_AT91SAM9RL)
35#define ATMEL_LCDC_FIFO_SIZE 2048 36#define ATMEL_LCDC_FIFO_SIZE 2048
36#else 37#else
37#define ATMEL_LCDC_FIFO_SIZE 512 38#define ATMEL_LCDC_FIFO_SIZE 512
@@ -250,6 +251,8 @@ static int atmel_lcdfb_alloc_video_memory(struct atmel_lcdfb_info *sinfo)
250 return -ENOMEM; 251 return -ENOMEM;
251 } 252 }
252 253
254 memset(info->screen_base, 0, info->fix.smem_len);
255
253 return 0; 256 return 0;
254} 257}
255 258
@@ -336,19 +339,35 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
336 break; 339 break;
337 case 15: 340 case 15:
338 case 16: 341 case 16:
339 var->red.offset = 0; 342 if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
343 /* RGB:565 mode */
344 var->red.offset = 11;
345 var->blue.offset = 0;
346 var->green.length = 6;
347 } else {
348 /* BGR:555 mode */
349 var->red.offset = 0;
350 var->blue.offset = 10;
351 var->green.length = 5;
352 }
340 var->green.offset = 5; 353 var->green.offset = 5;
341 var->blue.offset = 10; 354 var->red.length = var->blue.length = 5;
342 var->red.length = var->green.length = var->blue.length = 5;
343 break; 355 break;
344 case 32: 356 case 32:
345 var->transp.offset = 24; 357 var->transp.offset = 24;
346 var->transp.length = 8; 358 var->transp.length = 8;
347 /* fall through */ 359 /* fall through */
348 case 24: 360 case 24:
349 var->red.offset = 0; 361 if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB) {
362 /* RGB:888 mode */
363 var->red.offset = 16;
364 var->blue.offset = 0;
365 } else {
366 /* BGR:888 mode */
367 var->red.offset = 0;
368 var->blue.offset = 16;
369 }
350 var->green.offset = 8; 370 var->green.offset = 8;
351 var->blue.offset = 16;
352 var->red.length = var->green.length = var->blue.length = 8; 371 var->red.length = var->green.length = var->blue.length = 8;
353 break; 372 break;
354 default: 373 default:
@@ -634,7 +653,6 @@ static int __init atmel_lcdfb_init_fbinfo(struct atmel_lcdfb_info *sinfo)
634 struct fb_info *info = sinfo->info; 653 struct fb_info *info = sinfo->info;
635 int ret = 0; 654 int ret = 0;
636 655
637 memset_io(info->screen_base, 0, info->fix.smem_len);
638 info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW; 656 info->var.activate |= FB_ACTIVATE_FORCE | FB_ACTIVATE_NOW;
639 657
640 dev_info(info->device, 658 dev_info(info->device,
@@ -696,6 +714,7 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
696 sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control; 714 sinfo->atmel_lcdfb_power_control = pdata_sinfo->atmel_lcdfb_power_control;
697 sinfo->guard_time = pdata_sinfo->guard_time; 715 sinfo->guard_time = pdata_sinfo->guard_time;
698 sinfo->lcdcon_is_backlight = pdata_sinfo->lcdcon_is_backlight; 716 sinfo->lcdcon_is_backlight = pdata_sinfo->lcdcon_is_backlight;
717 sinfo->lcd_wiring_mode = pdata_sinfo->lcd_wiring_mode;
699 } else { 718 } else {
700 dev_err(dev, "cannot get default configuration\n"); 719 dev_err(dev, "cannot get default configuration\n");
701 goto free_info; 720 goto free_info;
@@ -764,6 +783,11 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev)
764 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); 783 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
765 if (!info->screen_base) 784 if (!info->screen_base)
766 goto release_intmem; 785 goto release_intmem;
786
787 /*
788 * Don't clear the framebuffer -- someone may have set
789 * up a splash image.
790 */
767 } else { 791 } else {
768 /* alocate memory buffer */ 792 /* alocate memory buffer */
769 ret = atmel_lcdfb_alloc_video_memory(sinfo); 793 ret = atmel_lcdfb_alloc_video_memory(sinfo);
@@ -903,10 +927,42 @@ static int __exit atmel_lcdfb_remove(struct platform_device *pdev)
903 return 0; 927 return 0;
904} 928}
905 929
930#ifdef CONFIG_PM
931
932static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg)
933{
934 struct fb_info *info = platform_get_drvdata(pdev);
935 struct atmel_lcdfb_info *sinfo = info->par;
936
937 sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL);
938 lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0);
939 if (sinfo->atmel_lcdfb_power_control)
940 sinfo->atmel_lcdfb_power_control(0);
941 atmel_lcdfb_stop_clock(sinfo);
942 return 0;
943}
944
945static int atmel_lcdfb_resume(struct platform_device *pdev)
946{
947 struct fb_info *info = platform_get_drvdata(pdev);
948 struct atmel_lcdfb_info *sinfo = info->par;
949
950 atmel_lcdfb_start_clock(sinfo);
951 if (sinfo->atmel_lcdfb_power_control)
952 sinfo->atmel_lcdfb_power_control(1);
953 lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, sinfo->saved_lcdcon);
954 return 0;
955}
956
957#else
958#define atmel_lcdfb_suspend NULL
959#define atmel_lcdfb_resume NULL
960#endif
961
906static struct platform_driver atmel_lcdfb_driver = { 962static struct platform_driver atmel_lcdfb_driver = {
907 .remove = __exit_p(atmel_lcdfb_remove), 963 .remove = __exit_p(atmel_lcdfb_remove),
908 964 .suspend = atmel_lcdfb_suspend,
909// FIXME need suspend, resume 965 .resume = atmel_lcdfb_resume,
910 966
911 .driver = { 967 .driver = {
912 .name = "atmel_lcdfb", 968 .name = "atmel_lcdfb",
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index cbd3308b6690..24ee96c4e9e9 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -91,7 +91,7 @@
91#undef DEBUG 91#undef DEBUG
92 92
93#ifdef DEBUG 93#ifdef DEBUG
94#define DBG(fmt, args...) printk(KERN_DEBUG "aty128fb: %s " fmt, __FUNCTION__, ##args); 94#define DBG(fmt, args...) printk(KERN_DEBUG "aty128fb: %s " fmt, __func__, ##args);
95#else 95#else
96#define DBG(fmt, args...) 96#define DBG(fmt, args...)
97#endif 97#endif
@@ -1885,7 +1885,7 @@ static int __devinit aty128_init(struct pci_dev *pdev, const struct pci_device_i
1885 1885
1886 /* range check to make sure */ 1886 /* range check to make sure */
1887 if (ent->driver_data < ARRAY_SIZE(r128_family)) 1887 if (ent->driver_data < ARRAY_SIZE(r128_family))
1888 strncat(video_card, r128_family[ent->driver_data], sizeof(video_card)); 1888 strlcat(video_card, r128_family[ent->driver_data], sizeof(video_card));
1889 1889
1890 printk(KERN_INFO "aty128fb: %s [chip rev 0x%x] ", video_card, chip_rev); 1890 printk(KERN_INFO "aty128fb: %s [chip rev 0x%x] ", video_card, chip_rev);
1891 1891
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 62f9c6e387cc..e4bcf5376a99 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2621,10 +2621,13 @@ static int __devinit aty_init(struct fb_info *info)
2621#endif /* CONFIG_FB_ATY_CT */ 2621#endif /* CONFIG_FB_ATY_CT */
2622 info->var = var; 2622 info->var = var;
2623 2623
2624 fb_alloc_cmap(&info->cmap, 256, 0); 2624 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0)
2625 goto aty_init_exit;
2625 2626
2626 if (register_framebuffer(info) < 0) 2627 if (register_framebuffer(info) < 0) {
2628 fb_dealloc_cmap(&info->cmap);
2627 goto aty_init_exit; 2629 goto aty_init_exit;
2630 }
2628 2631
2629 fb_list = info; 2632 fb_list = info;
2630 2633
diff --git a/drivers/video/aty/mach64_ct.c b/drivers/video/aty/mach64_ct.c
index cc9e9779b75f..c50c7cf26fe9 100644
--- a/drivers/video/aty/mach64_ct.c
+++ b/drivers/video/aty/mach64_ct.c
@@ -197,7 +197,7 @@ static int aty_dsp_gt(const struct fb_info *info, u32 bpp, struct pll_ct *pll)
197 pll->dsp_config = (dsp_precision << 20) | (pll->dsp_loop_latency << 16) | dsp_xclks; 197 pll->dsp_config = (dsp_precision << 20) | (pll->dsp_loop_latency << 16) | dsp_xclks;
198#ifdef DEBUG 198#ifdef DEBUG
199 printk("atyfb(%s): dsp_config 0x%08x, dsp_on_off 0x%08x\n", 199 printk("atyfb(%s): dsp_config 0x%08x, dsp_on_off 0x%08x\n",
200 __FUNCTION__, pll->dsp_config, pll->dsp_on_off); 200 __func__, pll->dsp_config, pll->dsp_on_off);
201#endif 201#endif
202 return 0; 202 return 0;
203} 203}
@@ -225,7 +225,7 @@ static int aty_valid_pll_ct(const struct fb_info *info, u32 vclk_per, struct pll
225 (par->ref_clk_per * pll->pll_ref_div); 225 (par->ref_clk_per * pll->pll_ref_div);
226#ifdef DEBUG 226#ifdef DEBUG
227 printk("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n", 227 printk("atyfb(%s): pllvclk=%d MHz, vclk=%d MHz\n",
228 __FUNCTION__, pllvclk, pllvclk / pll->vclk_post_div_real); 228 __func__, pllvclk, pllvclk / pll->vclk_post_div_real);
229#endif 229#endif
230 pll->pll_vclk_cntl = 0x03; /* VCLK = PLL_VCLK/VCLKx_POST */ 230 pll->pll_vclk_cntl = 0x03; /* VCLK = PLL_VCLK/VCLKx_POST */
231 231
@@ -269,7 +269,7 @@ static u32 aty_pll_to_var_ct(const struct fb_info *info, const union aty_pll *pl
269 } 269 }
270#endif 270#endif
271#ifdef DEBUG 271#ifdef DEBUG
272 printk("atyfb(%s): calculated 0x%08X(%i)\n", __FUNCTION__, ret, ret); 272 printk("atyfb(%s): calculated 0x%08X(%i)\n", __func__, ret, ret);
273#endif 273#endif
274 return ret; 274 return ret;
275} 275}
@@ -284,11 +284,11 @@ void aty_set_pll_ct(const struct fb_info *info, const union aty_pll *pll)
284#ifdef DEBUG 284#ifdef DEBUG
285 printk("atyfb(%s): about to program:\n" 285 printk("atyfb(%s): about to program:\n"
286 "pll_ext_cntl=0x%02x pll_gen_cntl=0x%02x pll_vclk_cntl=0x%02x\n", 286 "pll_ext_cntl=0x%02x pll_gen_cntl=0x%02x pll_vclk_cntl=0x%02x\n",
287 __FUNCTION__, 287 __func__,
288 pll->ct.pll_ext_cntl, pll->ct.pll_gen_cntl, pll->ct.pll_vclk_cntl); 288 pll->ct.pll_ext_cntl, pll->ct.pll_gen_cntl, pll->ct.pll_vclk_cntl);
289 289
290 printk("atyfb(%s): setting clock %lu for FeedBackDivider %i, ReferenceDivider %i, PostDivider %i(%i)\n", 290 printk("atyfb(%s): setting clock %lu for FeedBackDivider %i, ReferenceDivider %i, PostDivider %i(%i)\n",
291 __FUNCTION__, 291 __func__,
292 par->clk_wr_offset, pll->ct.vclk_fb_div, 292 par->clk_wr_offset, pll->ct.vclk_fb_div,
293 pll->ct.pll_ref_div, pll->ct.vclk_post_div, pll->ct.vclk_post_div_real); 293 pll->ct.pll_ref_div, pll->ct.vclk_post_div, pll->ct.vclk_post_div_real);
294#endif 294#endif
@@ -428,7 +428,7 @@ static int __devinit aty_init_pll_ct(const struct fb_info *info,
428 428
429#ifdef DEBUG 429#ifdef DEBUG
430 printk("atyfb(%s): mclk_fb_mult=%d, xclk_post_div=%d\n", 430 printk("atyfb(%s): mclk_fb_mult=%d, xclk_post_div=%d\n",
431 __FUNCTION__, pll->ct.mclk_fb_mult, pll->ct.xclk_post_div); 431 __func__, pll->ct.mclk_fb_mult, pll->ct.xclk_post_div);
432#endif 432#endif
433 433
434 memcntl = aty_ld_le32(MEM_CNTL, par); 434 memcntl = aty_ld_le32(MEM_CNTL, par);
@@ -540,7 +540,7 @@ static int __devinit aty_init_pll_ct(const struct fb_info *info,
540 pllmclk = (1000000 * pll->ct.mclk_fb_mult * pll->ct.mclk_fb_div) / 540 pllmclk = (1000000 * pll->ct.mclk_fb_mult * pll->ct.mclk_fb_div) /
541 (par->ref_clk_per * pll->ct.pll_ref_div); 541 (par->ref_clk_per * pll->ct.pll_ref_div);
542 printk("atyfb(%s): pllmclk=%d MHz, xclk=%d MHz\n", 542 printk("atyfb(%s): pllmclk=%d MHz, xclk=%d MHz\n",
543 __FUNCTION__, pllmclk, pllmclk / pll->ct.xclk_post_div_real); 543 __func__, pllmclk, pllmclk / pll->ct.xclk_post_div_real);
544#endif 544#endif
545 545
546 if (M64_HAS(SDRAM_MAGIC_PLL) && (par->ram_type >= SDRAM)) 546 if (M64_HAS(SDRAM_MAGIC_PLL) && (par->ram_type >= SDRAM))
@@ -581,7 +581,7 @@ static int __devinit aty_init_pll_ct(const struct fb_info *info,
581 pllsclk = (1000000 * 2 * pll->ct.sclk_fb_div) / 581 pllsclk = (1000000 * 2 * pll->ct.sclk_fb_div) /
582 (par->ref_clk_per * pll->ct.pll_ref_div); 582 (par->ref_clk_per * pll->ct.pll_ref_div);
583 printk("atyfb(%s): use sclk, pllsclk=%d MHz, sclk=mclk=%d MHz\n", 583 printk("atyfb(%s): use sclk, pllsclk=%d MHz, sclk=mclk=%d MHz\n",
584 __FUNCTION__, pllsclk, pllsclk / sclk_post_div_real); 584 __func__, pllsclk, pllsclk / sclk_post_div_real);
585#endif 585#endif
586 } 586 }
587 587
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c
index 62867cb63fef..72cd0d2f14ec 100644
--- a/drivers/video/aty/radeon_base.c
+++ b/drivers/video/aty/radeon_base.c
@@ -52,11 +52,14 @@
52 52
53#define RADEON_VERSION "0.2.0" 53#define RADEON_VERSION "0.2.0"
54 54
55#include "radeonfb.h"
56
55#include <linux/module.h> 57#include <linux/module.h>
56#include <linux/moduleparam.h> 58#include <linux/moduleparam.h>
57#include <linux/kernel.h> 59#include <linux/kernel.h>
58#include <linux/errno.h> 60#include <linux/errno.h>
59#include <linux/string.h> 61#include <linux/string.h>
62#include <linux/ctype.h>
60#include <linux/mm.h> 63#include <linux/mm.h>
61#include <linux/slab.h> 64#include <linux/slab.h>
62#include <linux/delay.h> 65#include <linux/delay.h>
@@ -91,7 +94,6 @@
91 94
92#include "../edid.h" // MOVE THAT TO include/video 95#include "../edid.h" // MOVE THAT TO include/video
93#include "ati_ids.h" 96#include "ati_ids.h"
94#include "radeonfb.h"
95 97
96#define MAX_MAPPED_VRAM (2048*2048*4) 98#define MAX_MAPPED_VRAM (2048*2048*4)
97#define MIN_MAPPED_VRAM (1024*768*1) 99#define MIN_MAPPED_VRAM (1024*768*1)
@@ -1488,7 +1490,7 @@ static void radeon_calc_pll_regs(struct radeonfb_info *rinfo, struct radeon_regs
1488 freq = rinfo->pll.ppll_max; 1490 freq = rinfo->pll.ppll_max;
1489 if (freq*12 < rinfo->pll.ppll_min) 1491 if (freq*12 < rinfo->pll.ppll_min)
1490 freq = rinfo->pll.ppll_min / 12; 1492 freq = rinfo->pll.ppll_min / 12;
1491 RTRACE("freq = %lu, PLL min = %u, PLL max = %u\n", 1493 pr_debug("freq = %lu, PLL min = %u, PLL max = %u\n",
1492 freq, rinfo->pll.ppll_min, rinfo->pll.ppll_max); 1494 freq, rinfo->pll.ppll_min, rinfo->pll.ppll_max);
1493 1495
1494 for (post_div = &post_divs[0]; post_div->divider; ++post_div) { 1496 for (post_div = &post_divs[0]; post_div->divider; ++post_div) {
@@ -1509,7 +1511,7 @@ static void radeon_calc_pll_regs(struct radeonfb_info *rinfo, struct radeon_regs
1509 post_div = &post_divs[post_div->bitvalue]; 1511 post_div = &post_divs[post_div->bitvalue];
1510 pll_output_freq = post_div->divider * freq; 1512 pll_output_freq = post_div->divider * freq;
1511 } 1513 }
1512 RTRACE("ref_div = %d, ref_clk = %d, output_freq = %d\n", 1514 pr_debug("ref_div = %d, ref_clk = %d, output_freq = %d\n",
1513 rinfo->pll.ref_div, rinfo->pll.ref_clk, 1515 rinfo->pll.ref_div, rinfo->pll.ref_clk,
1514 pll_output_freq); 1516 pll_output_freq);
1515 1517
@@ -1519,7 +1521,7 @@ static void radeon_calc_pll_regs(struct radeonfb_info *rinfo, struct radeon_regs
1519 post_div = &post_divs[post_div->bitvalue]; 1521 post_div = &post_divs[post_div->bitvalue];
1520 pll_output_freq = post_div->divider * freq; 1522 pll_output_freq = post_div->divider * freq;
1521 } 1523 }
1522 RTRACE("ref_div = %d, ref_clk = %d, output_freq = %d\n", 1524 pr_debug("ref_div = %d, ref_clk = %d, output_freq = %d\n",
1523 rinfo->pll.ref_div, rinfo->pll.ref_clk, 1525 rinfo->pll.ref_div, rinfo->pll.ref_clk,
1524 pll_output_freq); 1526 pll_output_freq);
1525 1527
@@ -1528,9 +1530,9 @@ static void radeon_calc_pll_regs(struct radeonfb_info *rinfo, struct radeon_regs
1528 regs->ppll_ref_div = rinfo->pll.ref_div; 1530 regs->ppll_ref_div = rinfo->pll.ref_div;
1529 regs->ppll_div_3 = fb_div | (post_div->bitvalue << 16); 1531 regs->ppll_div_3 = fb_div | (post_div->bitvalue << 16);
1530 1532
1531 RTRACE("post div = 0x%x\n", post_div->bitvalue); 1533 pr_debug("post div = 0x%x\n", post_div->bitvalue);
1532 RTRACE("fb_div = 0x%x\n", fb_div); 1534 pr_debug("fb_div = 0x%x\n", fb_div);
1533 RTRACE("ppll_div_3 = 0x%x\n", regs->ppll_div_3); 1535 pr_debug("ppll_div_3 = 0x%x\n", regs->ppll_div_3);
1534} 1536}
1535 1537
1536static int radeonfb_set_par(struct fb_info *info) 1538static int radeonfb_set_par(struct fb_info *info)
@@ -1602,9 +1604,9 @@ static int radeonfb_set_par(struct fb_info *info)
1602 dotClock = 1000000000 / pixClock; 1604 dotClock = 1000000000 / pixClock;
1603 freq = dotClock / 10; /* x100 */ 1605 freq = dotClock / 10; /* x100 */
1604 1606
1605 RTRACE("hStart = %d, hEnd = %d, hTotal = %d\n", 1607 pr_debug("hStart = %d, hEnd = %d, hTotal = %d\n",
1606 hSyncStart, hSyncEnd, hTotal); 1608 hSyncStart, hSyncEnd, hTotal);
1607 RTRACE("vStart = %d, vEnd = %d, vTotal = %d\n", 1609 pr_debug("vStart = %d, vEnd = %d, vTotal = %d\n",
1608 vSyncStart, vSyncEnd, vTotal); 1610 vSyncStart, vSyncEnd, vTotal);
1609 1611
1610 hsync_wid = (hSyncEnd - hSyncStart) / 8; 1612 hsync_wid = (hSyncEnd - hSyncStart) / 8;
@@ -1713,16 +1715,16 @@ static int radeonfb_set_par(struct fb_info *info)
1713 newmode->surf_info[i] = 0; 1715 newmode->surf_info[i] = 0;
1714 } 1716 }
1715 1717
1716 RTRACE("h_total_disp = 0x%x\t hsync_strt_wid = 0x%x\n", 1718 pr_debug("h_total_disp = 0x%x\t hsync_strt_wid = 0x%x\n",
1717 newmode->crtc_h_total_disp, newmode->crtc_h_sync_strt_wid); 1719 newmode->crtc_h_total_disp, newmode->crtc_h_sync_strt_wid);
1718 RTRACE("v_total_disp = 0x%x\t vsync_strt_wid = 0x%x\n", 1720 pr_debug("v_total_disp = 0x%x\t vsync_strt_wid = 0x%x\n",
1719 newmode->crtc_v_total_disp, newmode->crtc_v_sync_strt_wid); 1721 newmode->crtc_v_total_disp, newmode->crtc_v_sync_strt_wid);
1720 1722
1721 rinfo->bpp = mode->bits_per_pixel; 1723 rinfo->bpp = mode->bits_per_pixel;
1722 rinfo->depth = depth; 1724 rinfo->depth = depth;
1723 1725
1724 RTRACE("pixclock = %lu\n", (unsigned long)pixClock); 1726 pr_debug("pixclock = %lu\n", (unsigned long)pixClock);
1725 RTRACE("freq = %lu\n", (unsigned long)freq); 1727 pr_debug("freq = %lu\n", (unsigned long)freq);
1726 1728
1727 /* We use PPLL_DIV_3 */ 1729 /* We use PPLL_DIV_3 */
1728 newmode->clk_cntl_index = 0x300; 1730 newmode->clk_cntl_index = 0x300;
@@ -1986,7 +1988,7 @@ static void fixup_memory_mappings(struct radeonfb_info *rinfo)
1986 if (rinfo->has_CRTC2) 1988 if (rinfo->has_CRTC2)
1987 OUTREG(CRTC2_GEN_CNTL, save_crtc2_gen_cntl); 1989 OUTREG(CRTC2_GEN_CNTL, save_crtc2_gen_cntl);
1988 1990
1989 RTRACE("aper_base: %08x MC_FB_LOC to: %08x, MC_AGP_LOC to: %08x\n", 1991 pr_debug("aper_base: %08x MC_FB_LOC to: %08x, MC_AGP_LOC to: %08x\n",
1990 aper_base, 1992 aper_base,
1991 ((aper_base + aper_size - 1) & 0xffff0000) | (aper_base >> 16), 1993 ((aper_base + aper_size - 1) & 0xffff0000) | (aper_base >> 16),
1992 0xffff0000 | (agp_base >> 16)); 1994 0xffff0000 | (agp_base >> 16));
@@ -2083,7 +2085,7 @@ static void radeon_identify_vram(struct radeonfb_info *rinfo)
2083 * ToDo: identify these cases 2085 * ToDo: identify these cases
2084 */ 2086 */
2085 2087
2086 RTRACE("radeonfb (%s): Found %ldk of %s %d bits wide videoram\n", 2088 pr_debug("radeonfb (%s): Found %ldk of %s %d bits wide videoram\n",
2087 pci_name(rinfo->pdev), 2089 pci_name(rinfo->pdev),
2088 rinfo->video_ram / 1024, 2090 rinfo->video_ram / 1024,
2089 rinfo->vram_ddr ? "DDR" : "SDRAM", 2091 rinfo->vram_ddr ? "DDR" : "SDRAM",
@@ -2158,8 +2160,9 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
2158 struct fb_info *info; 2160 struct fb_info *info;
2159 struct radeonfb_info *rinfo; 2161 struct radeonfb_info *rinfo;
2160 int ret; 2162 int ret;
2163 unsigned char c1, c2;
2161 2164
2162 RTRACE("radeonfb_pci_register BEGIN\n"); 2165 pr_debug("radeonfb_pci_register BEGIN\n");
2163 2166
2164 /* Enable device in PCI config */ 2167 /* Enable device in PCI config */
2165 ret = pci_enable_device(pdev); 2168 ret = pci_enable_device(pdev);
@@ -2185,9 +2188,15 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
2185 rinfo->lvds_timer.function = radeon_lvds_timer_func; 2188 rinfo->lvds_timer.function = radeon_lvds_timer_func;
2186 rinfo->lvds_timer.data = (unsigned long)rinfo; 2189 rinfo->lvds_timer.data = (unsigned long)rinfo;
2187 2190
2188 strcpy(rinfo->name, "ATI Radeon XX "); 2191 c1 = ent->device >> 8;
2189 rinfo->name[11] = ent->device >> 8; 2192 c2 = ent->device & 0xff;
2190 rinfo->name[12] = ent->device & 0xFF; 2193 if (isprint(c1) && isprint(c2))
2194 snprintf(rinfo->name, sizeof(rinfo->name),
2195 "ATI Radeon %x \"%c%c\"", ent->device & 0xffff, c1, c2);
2196 else
2197 snprintf(rinfo->name, sizeof(rinfo->name),
2198 "ATI Radeon %x", ent->device & 0xffff);
2199
2191 rinfo->family = ent->driver_data & CHIP_FAMILY_MASK; 2200 rinfo->family = ent->driver_data & CHIP_FAMILY_MASK;
2192 rinfo->chipset = pdev->device; 2201 rinfo->chipset = pdev->device;
2193 rinfo->has_CRTC2 = (ent->driver_data & CHIP_HAS_CRTC2) != 0; 2202 rinfo->has_CRTC2 = (ent->driver_data & CHIP_HAS_CRTC2) != 0;
@@ -2278,7 +2287,7 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
2278 goto err_unmap_rom; 2287 goto err_unmap_rom;
2279 } 2288 }
2280 2289
2281 RTRACE("radeonfb (%s): mapped %ldk videoram\n", pci_name(rinfo->pdev), 2290 pr_debug("radeonfb (%s): mapped %ldk videoram\n", pci_name(rinfo->pdev),
2282 rinfo->mapped_vram/1024); 2291 rinfo->mapped_vram/1024);
2283 2292
2284 /* 2293 /*
@@ -2373,7 +2382,7 @@ static int __devinit radeonfb_pci_register (struct pci_dev *pdev,
2373 2382
2374 if (rinfo->bios_seg) 2383 if (rinfo->bios_seg)
2375 radeon_unmap_ROM(rinfo, pdev); 2384 radeon_unmap_ROM(rinfo, pdev);
2376 RTRACE("radeonfb_pci_register END\n"); 2385 pr_debug("radeonfb_pci_register END\n");
2377 2386
2378 return 0; 2387 return 0;
2379err_unmap_fb: 2388err_unmap_fb:
diff --git a/drivers/video/aty/radeon_i2c.c b/drivers/video/aty/radeon_i2c.c
index 7db9de681716..f9e7c29ad9bf 100644
--- a/drivers/video/aty/radeon_i2c.c
+++ b/drivers/video/aty/radeon_i2c.c
@@ -1,3 +1,5 @@
1#include "radeonfb.h"
2
1#include <linux/module.h> 3#include <linux/module.h>
2#include <linux/kernel.h> 4#include <linux/kernel.h>
3#include <linux/delay.h> 5#include <linux/delay.h>
@@ -11,7 +13,6 @@
11#include <asm/io.h> 13#include <asm/io.h>
12 14
13#include <video/radeon.h> 15#include <video/radeon.h>
14#include "radeonfb.h"
15#include "../edid.h" 16#include "../edid.h"
16 17
17static void radeon_gpio_setscl(void* data, int state) 18static void radeon_gpio_setscl(void* data, int state)
@@ -77,7 +78,7 @@ static int radeon_setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
77 chan->algo.setscl = radeon_gpio_setscl; 78 chan->algo.setscl = radeon_gpio_setscl;
78 chan->algo.getsda = radeon_gpio_getsda; 79 chan->algo.getsda = radeon_gpio_getsda;
79 chan->algo.getscl = radeon_gpio_getscl; 80 chan->algo.getscl = radeon_gpio_getscl;
80 chan->algo.udelay = 40; 81 chan->algo.udelay = 10;
81 chan->algo.timeout = 20; 82 chan->algo.timeout = 20;
82 chan->algo.data = chan; 83 chan->algo.data = chan;
83 84
@@ -148,21 +149,21 @@ int radeon_probe_i2c_connector(struct radeonfb_info *rinfo, int conn,
148 if (out_edid) 149 if (out_edid)
149 *out_edid = edid; 150 *out_edid = edid;
150 if (!edid) { 151 if (!edid) {
151 RTRACE("radeonfb: I2C (port %d) ... not found\n", conn); 152 pr_debug("radeonfb: I2C (port %d) ... not found\n", conn);
152 return MT_NONE; 153 return MT_NONE;
153 } 154 }
154 if (edid[0x14] & 0x80) { 155 if (edid[0x14] & 0x80) {
155 /* Fix detection using BIOS tables */ 156 /* Fix detection using BIOS tables */
156 if (rinfo->is_mobility /*&& conn == ddc_dvi*/ && 157 if (rinfo->is_mobility /*&& conn == ddc_dvi*/ &&
157 (INREG(LVDS_GEN_CNTL) & LVDS_ON)) { 158 (INREG(LVDS_GEN_CNTL) & LVDS_ON)) {
158 RTRACE("radeonfb: I2C (port %d) ... found LVDS panel\n", conn); 159 pr_debug("radeonfb: I2C (port %d) ... found LVDS panel\n", conn);
159 return MT_LCD; 160 return MT_LCD;
160 } else { 161 } else {
161 RTRACE("radeonfb: I2C (port %d) ... found TMDS panel\n", conn); 162 pr_debug("radeonfb: I2C (port %d) ... found TMDS panel\n", conn);
162 return MT_DFP; 163 return MT_DFP;
163 } 164 }
164 } 165 }
165 RTRACE("radeonfb: I2C (port %d) ... found CRT display\n", conn); 166 pr_debug("radeonfb: I2C (port %d) ... found CRT display\n", conn);
166 return MT_CRT; 167 return MT_CRT;
167} 168}
168 169
diff --git a/drivers/video/aty/radeon_monitor.c b/drivers/video/aty/radeon_monitor.c
index 2030ed813429..b4d4b88afc09 100644
--- a/drivers/video/aty/radeon_monitor.c
+++ b/drivers/video/aty/radeon_monitor.c
@@ -69,11 +69,11 @@ static int __devinit radeon_parse_montype_prop(struct device_node *dp, u8 **out_
69 u8 *tmp; 69 u8 *tmp;
70 int i, mt = MT_NONE; 70 int i, mt = MT_NONE;
71 71
72 RTRACE("analyzing OF properties...\n"); 72 pr_debug("analyzing OF properties...\n");
73 pmt = of_get_property(dp, "display-type", NULL); 73 pmt = of_get_property(dp, "display-type", NULL);
74 if (!pmt) 74 if (!pmt)
75 return MT_NONE; 75 return MT_NONE;
76 RTRACE("display-type: %s\n", pmt); 76 pr_debug("display-type: %s\n", pmt);
77 /* OF says "LCD" for DFP as well, we discriminate from the caller of this 77 /* OF says "LCD" for DFP as well, we discriminate from the caller of this
78 * function 78 * function
79 */ 79 */
@@ -117,7 +117,7 @@ static int __devinit radeon_probe_OF_head(struct radeonfb_info *rinfo, int head_
117{ 117{
118 struct device_node *dp; 118 struct device_node *dp;
119 119
120 RTRACE("radeon_probe_OF_head\n"); 120 pr_debug("radeon_probe_OF_head\n");
121 121
122 dp = rinfo->of_node; 122 dp = rinfo->of_node;
123 while (dp == NULL) 123 while (dp == NULL)
@@ -135,7 +135,7 @@ static int __devinit radeon_probe_OF_head(struct radeonfb_info *rinfo, int head_
135 if (!pname) 135 if (!pname)
136 return MT_NONE; 136 return MT_NONE;
137 len = strlen(pname); 137 len = strlen(pname);
138 RTRACE("head: %s (letter: %c, head_no: %d)\n", 138 pr_debug("head: %s (letter: %c, head_no: %d)\n",
139 pname, pname[len-1], head_no); 139 pname, pname[len-1], head_no);
140 if (pname[len-1] == 'A' && head_no == 0) { 140 if (pname[len-1] == 'A' && head_no == 0) {
141 int mt = radeon_parse_montype_prop(dp, out_EDID, 0); 141 int mt = radeon_parse_montype_prop(dp, out_EDID, 0);
@@ -185,7 +185,7 @@ static int __devinit radeon_get_panel_info_BIOS(struct radeonfb_info *rinfo)
185 rinfo->panel_info.xres, rinfo->panel_info.yres); 185 rinfo->panel_info.xres, rinfo->panel_info.yres);
186 186
187 rinfo->panel_info.pwr_delay = BIOS_IN16(tmp + 44); 187 rinfo->panel_info.pwr_delay = BIOS_IN16(tmp + 44);
188 RTRACE("BIOS provided panel power delay: %d\n", rinfo->panel_info.pwr_delay); 188 pr_debug("BIOS provided panel power delay: %d\n", rinfo->panel_info.pwr_delay);
189 if (rinfo->panel_info.pwr_delay > 2000 || rinfo->panel_info.pwr_delay <= 0) 189 if (rinfo->panel_info.pwr_delay > 2000 || rinfo->panel_info.pwr_delay <= 0)
190 rinfo->panel_info.pwr_delay = 2000; 190 rinfo->panel_info.pwr_delay = 2000;
191 191
@@ -199,16 +199,16 @@ static int __devinit radeon_get_panel_info_BIOS(struct radeonfb_info *rinfo)
199 rinfo->panel_info.fbk_divider > 3) { 199 rinfo->panel_info.fbk_divider > 3) {
200 rinfo->panel_info.use_bios_dividers = 1; 200 rinfo->panel_info.use_bios_dividers = 1;
201 printk(KERN_INFO "radeondb: BIOS provided dividers will be used\n"); 201 printk(KERN_INFO "radeondb: BIOS provided dividers will be used\n");
202 RTRACE("ref_divider = %x\n", rinfo->panel_info.ref_divider); 202 pr_debug("ref_divider = %x\n", rinfo->panel_info.ref_divider);
203 RTRACE("post_divider = %x\n", rinfo->panel_info.post_divider); 203 pr_debug("post_divider = %x\n", rinfo->panel_info.post_divider);
204 RTRACE("fbk_divider = %x\n", rinfo->panel_info.fbk_divider); 204 pr_debug("fbk_divider = %x\n", rinfo->panel_info.fbk_divider);
205 } 205 }
206 RTRACE("Scanning BIOS table ...\n"); 206 pr_debug("Scanning BIOS table ...\n");
207 for(i=0; i<32; i++) { 207 for(i=0; i<32; i++) {
208 tmp0 = BIOS_IN16(tmp+64+i*2); 208 tmp0 = BIOS_IN16(tmp+64+i*2);
209 if (tmp0 == 0) 209 if (tmp0 == 0)
210 break; 210 break;
211 RTRACE(" %d x %d\n", BIOS_IN16(tmp0), BIOS_IN16(tmp0+2)); 211 pr_debug(" %d x %d\n", BIOS_IN16(tmp0), BIOS_IN16(tmp0+2));
212 if ((BIOS_IN16(tmp0) == rinfo->panel_info.xres) && 212 if ((BIOS_IN16(tmp0) == rinfo->panel_info.xres) &&
213 (BIOS_IN16(tmp0+2) == rinfo->panel_info.yres)) { 213 (BIOS_IN16(tmp0+2) == rinfo->panel_info.yres)) {
214 rinfo->panel_info.hblank = (BIOS_IN16(tmp0+17) - BIOS_IN16(tmp0+19)) * 8; 214 rinfo->panel_info.hblank = (BIOS_IN16(tmp0+17) - BIOS_IN16(tmp0+19)) * 8;
@@ -227,19 +227,19 @@ static int __devinit radeon_get_panel_info_BIOS(struct radeonfb_info *rinfo)
227 /* Mark panel infos valid */ 227 /* Mark panel infos valid */
228 rinfo->panel_info.valid = 1; 228 rinfo->panel_info.valid = 1;
229 229
230 RTRACE("Found panel in BIOS table:\n"); 230 pr_debug("Found panel in BIOS table:\n");
231 RTRACE(" hblank: %d\n", rinfo->panel_info.hblank); 231 pr_debug(" hblank: %d\n", rinfo->panel_info.hblank);
232 RTRACE(" hOver_plus: %d\n", rinfo->panel_info.hOver_plus); 232 pr_debug(" hOver_plus: %d\n", rinfo->panel_info.hOver_plus);
233 RTRACE(" hSync_width: %d\n", rinfo->panel_info.hSync_width); 233 pr_debug(" hSync_width: %d\n", rinfo->panel_info.hSync_width);
234 RTRACE(" vblank: %d\n", rinfo->panel_info.vblank); 234 pr_debug(" vblank: %d\n", rinfo->panel_info.vblank);
235 RTRACE(" vOver_plus: %d\n", rinfo->panel_info.vOver_plus); 235 pr_debug(" vOver_plus: %d\n", rinfo->panel_info.vOver_plus);
236 RTRACE(" vSync_width: %d\n", rinfo->panel_info.vSync_width); 236 pr_debug(" vSync_width: %d\n", rinfo->panel_info.vSync_width);
237 RTRACE(" clock: %d\n", rinfo->panel_info.clock); 237 pr_debug(" clock: %d\n", rinfo->panel_info.clock);
238 238
239 return 1; 239 return 1;
240 } 240 }
241 } 241 }
242 RTRACE("Didn't find panel in BIOS table !\n"); 242 pr_debug("Didn't find panel in BIOS table !\n");
243 243
244 return 0; 244 return 0;
245} 245}
@@ -271,18 +271,18 @@ static void __devinit radeon_parse_connector_info(struct radeonfb_info *rinfo)
271 * DEBUG is enabled 271 * DEBUG is enabled
272 */ 272 */
273 chips = BIOS_IN8(offset++) >> 4; 273 chips = BIOS_IN8(offset++) >> 4;
274 RTRACE("%d chips in connector info\n", chips); 274 pr_debug("%d chips in connector info\n", chips);
275 for (i = 0; i < chips; i++) { 275 for (i = 0; i < chips; i++) {
276 tmp = BIOS_IN8(offset++); 276 tmp = BIOS_IN8(offset++);
277 connectors = tmp & 0x0f; 277 connectors = tmp & 0x0f;
278 RTRACE(" - chip %d has %d connectors\n", tmp >> 4, connectors); 278 pr_debug(" - chip %d has %d connectors\n", tmp >> 4, connectors);
279 for (conn = 0; ; conn++) { 279 for (conn = 0; ; conn++) {
280 tmp = BIOS_IN16(offset); 280 tmp = BIOS_IN16(offset);
281 if (tmp == 0) 281 if (tmp == 0)
282 break; 282 break;
283 offset += 2; 283 offset += 2;
284 type = (tmp >> 12) & 0x0f; 284 type = (tmp >> 12) & 0x0f;
285 RTRACE(" * connector %d of type %d (%s) : %04x\n", 285 pr_debug(" * connector %d of type %d (%s) : %04x\n",
286 conn, type, __conn_type_table[type], tmp); 286 conn, type, __conn_type_table[type], tmp);
287 } 287 }
288 } 288 }
@@ -449,7 +449,7 @@ void __devinit radeon_probe_screens(struct radeonfb_info *rinfo,
449 * a layout for each card ? 449 * a layout for each card ?
450 */ 450 */
451 451
452 RTRACE("Using specified monitor layout: %s", monitor_layout); 452 pr_debug("Using specified monitor layout: %s", monitor_layout);
453#ifdef CONFIG_FB_RADEON_I2C 453#ifdef CONFIG_FB_RADEON_I2C
454 if (!ignore_edid) { 454 if (!ignore_edid) {
455 if (rinfo->mon1_type != MT_NONE) 455 if (rinfo->mon1_type != MT_NONE)
@@ -479,9 +479,9 @@ void __devinit radeon_probe_screens(struct radeonfb_info *rinfo,
479 * Auto-detecting display type (well... trying to ...) 479 * Auto-detecting display type (well... trying to ...)
480 */ 480 */
481 481
482 RTRACE("Starting monitor auto detection...\n"); 482 pr_debug("Starting monitor auto detection...\n");
483 483
484#if DEBUG && defined(CONFIG_FB_RADEON_I2C) 484#if defined(DEBUG) && defined(CONFIG_FB_RADEON_I2C)
485 { 485 {
486 u8 *EDIDs[4] = { NULL, NULL, NULL, NULL }; 486 u8 *EDIDs[4] = { NULL, NULL, NULL, NULL };
487 int mon_types[4] = {MT_NONE, MT_NONE, MT_NONE, MT_NONE}; 487 int mon_types[4] = {MT_NONE, MT_NONE, MT_NONE, MT_NONE};
@@ -756,7 +756,7 @@ void __devinit radeon_check_modes(struct radeonfb_info *rinfo, const char *mode_
756 if (!rinfo->panel_info.use_bios_dividers && rinfo->mon1_type != MT_CRT 756 if (!rinfo->panel_info.use_bios_dividers && rinfo->mon1_type != MT_CRT
757 && rinfo->mon1_EDID) { 757 && rinfo->mon1_EDID) {
758 struct fb_var_screeninfo var; 758 struct fb_var_screeninfo var;
759 RTRACE("Parsing EDID data for panel info\n"); 759 pr_debug("Parsing EDID data for panel info\n");
760 if (fb_parse_edid(rinfo->mon1_EDID, &var) == 0) { 760 if (fb_parse_edid(rinfo->mon1_EDID, &var) == 0) {
761 if (var.xres >= rinfo->panel_info.xres && 761 if (var.xres >= rinfo->panel_info.xres &&
762 var.yres >= rinfo->panel_info.yres) 762 var.yres >= rinfo->panel_info.yres)
@@ -776,7 +776,7 @@ void __devinit radeon_check_modes(struct radeonfb_info *rinfo, const char *mode_
776 if (rinfo->mon1_type != MT_CRT && rinfo->panel_info.valid) { 776 if (rinfo->mon1_type != MT_CRT && rinfo->panel_info.valid) {
777 struct fb_var_screeninfo *var = &info->var; 777 struct fb_var_screeninfo *var = &info->var;
778 778
779 RTRACE("Setting up default mode based on panel info\n"); 779 pr_debug("Setting up default mode based on panel info\n");
780 var->xres = rinfo->panel_info.xres; 780 var->xres = rinfo->panel_info.xres;
781 var->yres = rinfo->panel_info.yres; 781 var->yres = rinfo->panel_info.yres;
782 var->xres_virtual = rinfo->panel_info.xres; 782 var->xres_virtual = rinfo->panel_info.xres;
@@ -824,7 +824,7 @@ void __devinit radeon_check_modes(struct radeonfb_info *rinfo, const char *mode_
824 int dbsize; 824 int dbsize;
825 char modename[32]; 825 char modename[32];
826 826
827 RTRACE("Guessing panel info...\n"); 827 pr_debug("Guessing panel info...\n");
828 if (rinfo->panel_info.xres == 0 || rinfo->panel_info.yres == 0) { 828 if (rinfo->panel_info.xres == 0 || rinfo->panel_info.yres == 0) {
829 u32 tmp = INREG(FP_HORZ_STRETCH) & HORZ_PANEL_SIZE; 829 u32 tmp = INREG(FP_HORZ_STRETCH) & HORZ_PANEL_SIZE;
830 rinfo->panel_info.xres = ((tmp >> HORZ_PANEL_SHIFT) + 1) * 8; 830 rinfo->panel_info.xres = ((tmp >> HORZ_PANEL_SHIFT) + 1) * 8;
diff --git a/drivers/video/aty/radeonfb.h b/drivers/video/aty/radeonfb.h
index 5eac1ce52e72..c347e38cd0b0 100644
--- a/drivers/video/aty/radeonfb.h
+++ b/drivers/video/aty/radeonfb.h
@@ -1,6 +1,10 @@
1#ifndef __RADEONFB_H__ 1#ifndef __RADEONFB_H__
2#define __RADEONFB_H__ 2#define __RADEONFB_H__
3 3
4#ifdef CONFIG_FB_RADEON_DEBUG
5#define DEBUG 1
6#endif
7
4#include <linux/module.h> 8#include <linux/module.h>
5#include <linux/kernel.h> 9#include <linux/kernel.h>
6#include <linux/sched.h> 10#include <linux/sched.h>
@@ -365,22 +369,6 @@ struct radeonfb_info {
365 369
366 370
367/* 371/*
368 * Debugging stuffs
369 */
370#ifdef CONFIG_FB_RADEON_DEBUG
371#define DEBUG 1
372#else
373#define DEBUG 0
374#endif
375
376#if DEBUG
377#define RTRACE printk
378#else
379#define RTRACE if(0) printk
380#endif
381
382
383/*
384 * IO macros 372 * IO macros
385 */ 373 */
386 374
diff --git a/drivers/video/bf54x-lq043fb.c b/drivers/video/bf54x-lq043fb.c
index eefba3d0e4b9..49834a67a623 100644
--- a/drivers/video/bf54x-lq043fb.c
+++ b/drivers/video/bf54x-lq043fb.c
@@ -336,7 +336,7 @@ static int bfin_bf54x_fb_check_var(struct fb_var_screeninfo *var,
336{ 336{
337 337
338 if (var->bits_per_pixel != LCD_BPP) { 338 if (var->bits_per_pixel != LCD_BPP) {
339 pr_debug("%s: depth not supported: %u BPP\n", __FUNCTION__, 339 pr_debug("%s: depth not supported: %u BPP\n", __func__,
340 var->bits_per_pixel); 340 var->bits_per_pixel);
341 return -EINVAL; 341 return -EINVAL;
342 } 342 }
@@ -345,7 +345,7 @@ static int bfin_bf54x_fb_check_var(struct fb_var_screeninfo *var,
345 info->var.xres_virtual != var->xres_virtual || 345 info->var.xres_virtual != var->xres_virtual ||
346 info->var.yres_virtual != var->yres_virtual) { 346 info->var.yres_virtual != var->yres_virtual) {
347 pr_debug("%s: Resolution not supported: X%u x Y%u \n", 347 pr_debug("%s: Resolution not supported: X%u x Y%u \n",
348 __FUNCTION__, var->xres, var->yres); 348 __func__, var->xres, var->yres);
349 return -EINVAL; 349 return -EINVAL;
350 } 350 }
351 351
@@ -355,7 +355,7 @@ static int bfin_bf54x_fb_check_var(struct fb_var_screeninfo *var,
355 355
356 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) { 356 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
357 pr_debug("%s: Memory Limit requested yres_virtual = %u\n", 357 pr_debug("%s: Memory Limit requested yres_virtual = %u\n",
358 __FUNCTION__, var->yres_virtual); 358 __func__, var->yres_virtual);
359 return -ENOMEM; 359 return -ENOMEM;
360 } 360 }
361 361
@@ -652,7 +652,7 @@ static int __init bfin_bf54x_probe(struct platform_device *pdev)
652 goto out7; 652 goto out7;
653 } 653 }
654 654
655 if (request_irq(info->irq, (void *)bfin_bf54x_irq_error, IRQF_DISABLED, 655 if (request_irq(info->irq, bfin_bf54x_irq_error, IRQF_DISABLED,
656 "PPI ERROR", info) < 0) { 656 "PPI ERROR", info) < 0) {
657 printk(KERN_ERR DRIVER_NAME 657 printk(KERN_ERR DRIVER_NAME
658 ": unable to request PPI ERROR IRQ\n"); 658 ": unable to request PPI ERROR IRQ\n");
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index 833b10c84064..275d9dab0c61 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -339,7 +339,7 @@ static int __devinit bw2_probe(struct of_device *op, const struct of_device_id *
339 339
340 dev_set_drvdata(&op->dev, info); 340 dev_set_drvdata(&op->dev, info);
341 341
342 printk("%s: bwtwo at %lx:%lx\n", 342 printk(KERN_INFO "%s: bwtwo at %lx:%lx\n",
343 dp->full_name, par->which_io, par->physbase); 343 dp->full_name, par->which_io, par->physbase);
344 344
345 return 0; 345 return 0;
@@ -399,10 +399,9 @@ static int __init bw2_init(void)
399 399
400static void __exit bw2_exit(void) 400static void __exit bw2_exit(void)
401{ 401{
402 return of_unregister_driver(&bw2_driver); 402 of_unregister_driver(&bw2_driver);
403} 403}
404 404
405
406module_init(bw2_init); 405module_init(bw2_init);
407module_exit(bw2_exit); 406module_exit(bw2_exit);
408 407
diff --git a/drivers/video/cfbcopyarea.c b/drivers/video/cfbcopyarea.c
index b07e419b12d2..df03f3776dcc 100644
--- a/drivers/video/cfbcopyarea.c
+++ b/drivers/video/cfbcopyarea.c
@@ -44,15 +44,16 @@
44 */ 44 */
45 45
46static void 46static void
47bitcpy(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem *src, 47bitcpy(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
48 int src_idx, int bits, unsigned n, u32 bswapmask) 48 const unsigned long __iomem *src, int src_idx, int bits,
49 unsigned n, u32 bswapmask)
49{ 50{
50 unsigned long first, last; 51 unsigned long first, last;
51 int const shift = dst_idx-src_idx; 52 int const shift = dst_idx-src_idx;
52 int left, right; 53 int left, right;
53 54
54 first = fb_shifted_pixels_mask_long(dst_idx, bswapmask); 55 first = fb_shifted_pixels_mask_long(p, dst_idx, bswapmask);
55 last = ~fb_shifted_pixels_mask_long((dst_idx+n) % bits, bswapmask); 56 last = ~fb_shifted_pixels_mask_long(p, (dst_idx+n) % bits, bswapmask);
56 57
57 if (!shift) { 58 if (!shift) {
58 // Same alignment for source and dest 59 // Same alignment for source and dest
@@ -202,8 +203,9 @@ bitcpy(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem *src
202 */ 203 */
203 204
204static void 205static void
205bitcpy_rev(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem *src, 206bitcpy_rev(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
206 int src_idx, int bits, unsigned n, u32 bswapmask) 207 const unsigned long __iomem *src, int src_idx, int bits,
208 unsigned n, u32 bswapmask)
207{ 209{
208 unsigned long first, last; 210 unsigned long first, last;
209 int shift; 211 int shift;
@@ -221,8 +223,9 @@ bitcpy_rev(unsigned long __iomem *dst, int dst_idx, const unsigned long __iomem
221 223
222 shift = dst_idx-src_idx; 224 shift = dst_idx-src_idx;
223 225
224 first = fb_shifted_pixels_mask_long(bits - 1 - dst_idx, bswapmask); 226 first = fb_shifted_pixels_mask_long(p, bits - 1 - dst_idx, bswapmask);
225 last = ~fb_shifted_pixels_mask_long(bits - 1 - ((dst_idx-n) % bits), bswapmask); 227 last = ~fb_shifted_pixels_mask_long(p, bits - 1 - ((dst_idx-n) % bits),
228 bswapmask);
226 229
227 if (!shift) { 230 if (!shift) {
228 // Same alignment for source and dest 231 // Same alignment for source and dest
@@ -404,7 +407,7 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
404 dst_idx &= (bytes - 1); 407 dst_idx &= (bytes - 1);
405 src += src_idx >> (ffs(bits) - 1); 408 src += src_idx >> (ffs(bits) - 1);
406 src_idx &= (bytes - 1); 409 src_idx &= (bytes - 1);
407 bitcpy_rev(dst, dst_idx, src, src_idx, bits, 410 bitcpy_rev(p, dst, dst_idx, src, src_idx, bits,
408 width*p->var.bits_per_pixel, bswapmask); 411 width*p->var.bits_per_pixel, bswapmask);
409 } 412 }
410 } else { 413 } else {
@@ -413,7 +416,7 @@ void cfb_copyarea(struct fb_info *p, const struct fb_copyarea *area)
413 dst_idx &= (bytes - 1); 416 dst_idx &= (bytes - 1);
414 src += src_idx >> (ffs(bits) - 1); 417 src += src_idx >> (ffs(bits) - 1);
415 src_idx &= (bytes - 1); 418 src_idx &= (bytes - 1);
416 bitcpy(dst, dst_idx, src, src_idx, bits, 419 bitcpy(p, dst, dst_idx, src, src_idx, bits,
417 width*p->var.bits_per_pixel, bswapmask); 420 width*p->var.bits_per_pixel, bswapmask);
418 dst_idx += bits_per_line; 421 dst_idx += bits_per_line;
419 src_idx += bits_per_line; 422 src_idx += bits_per_line;
diff --git a/drivers/video/cfbfillrect.c b/drivers/video/cfbfillrect.c
index 23d70a12e4da..64b35766b2a2 100644
--- a/drivers/video/cfbfillrect.c
+++ b/drivers/video/cfbfillrect.c
@@ -36,16 +36,16 @@
36 */ 36 */
37 37
38static void 38static void
39bitfill_aligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat, 39bitfill_aligned(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
40 unsigned n, int bits, u32 bswapmask) 40 unsigned long pat, unsigned n, int bits, u32 bswapmask)
41{ 41{
42 unsigned long first, last; 42 unsigned long first, last;
43 43
44 if (!n) 44 if (!n)
45 return; 45 return;
46 46
47 first = fb_shifted_pixels_mask_long(dst_idx, bswapmask); 47 first = fb_shifted_pixels_mask_long(p, dst_idx, bswapmask);
48 last = ~fb_shifted_pixels_mask_long((dst_idx+n) % bits, bswapmask); 48 last = ~fb_shifted_pixels_mask_long(p, (dst_idx+n) % bits, bswapmask);
49 49
50 if (dst_idx+n <= bits) { 50 if (dst_idx+n <= bits) {
51 // Single word 51 // Single word
@@ -93,16 +93,16 @@ bitfill_aligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
93 */ 93 */
94 94
95static void 95static void
96bitfill_unaligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat, 96bitfill_unaligned(struct fb_info *p, unsigned long __iomem *dst, int dst_idx,
97 int left, int right, unsigned n, int bits) 97 unsigned long pat, int left, int right, unsigned n, int bits)
98{ 98{
99 unsigned long first, last; 99 unsigned long first, last;
100 100
101 if (!n) 101 if (!n)
102 return; 102 return;
103 103
104 first = FB_SHIFT_HIGH(~0UL, dst_idx); 104 first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
105 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits)); 105 last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
106 106
107 if (dst_idx+n <= bits) { 107 if (dst_idx+n <= bits) {
108 // Single word 108 // Single word
@@ -147,8 +147,9 @@ bitfill_unaligned(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
147 * Aligned pattern invert using 32/64-bit memory accesses 147 * Aligned pattern invert using 32/64-bit memory accesses
148 */ 148 */
149static void 149static void
150bitfill_aligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat, 150bitfill_aligned_rev(struct fb_info *p, unsigned long __iomem *dst,
151 unsigned n, int bits, u32 bswapmask) 151 int dst_idx, unsigned long pat, unsigned n, int bits,
152 u32 bswapmask)
152{ 153{
153 unsigned long val = pat, dat; 154 unsigned long val = pat, dat;
154 unsigned long first, last; 155 unsigned long first, last;
@@ -156,8 +157,8 @@ bitfill_aligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
156 if (!n) 157 if (!n)
157 return; 158 return;
158 159
159 first = fb_shifted_pixels_mask_long(dst_idx, bswapmask); 160 first = fb_shifted_pixels_mask_long(p, dst_idx, bswapmask);
160 last = ~fb_shifted_pixels_mask_long((dst_idx+n) % bits, bswapmask); 161 last = ~fb_shifted_pixels_mask_long(p, (dst_idx+n) % bits, bswapmask);
161 162
162 if (dst_idx+n <= bits) { 163 if (dst_idx+n <= bits) {
163 // Single word 164 // Single word
@@ -217,16 +218,17 @@ bitfill_aligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat,
217 */ 218 */
218 219
219static void 220static void
220bitfill_unaligned_rev(unsigned long __iomem *dst, int dst_idx, unsigned long pat, 221bitfill_unaligned_rev(struct fb_info *p, unsigned long __iomem *dst,
221 int left, int right, unsigned n, int bits) 222 int dst_idx, unsigned long pat, int left, int right,
223 unsigned n, int bits)
222{ 224{
223 unsigned long first, last, dat; 225 unsigned long first, last, dat;
224 226
225 if (!n) 227 if (!n)
226 return; 228 return;
227 229
228 first = FB_SHIFT_HIGH(~0UL, dst_idx); 230 first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
229 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits)); 231 last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
230 232
231 if (dst_idx+n <= bits) { 233 if (dst_idx+n <= bits) {
232 // Single word 234 // Single word
@@ -306,7 +308,8 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
306 p->fbops->fb_sync(p); 308 p->fbops->fb_sync(p);
307 if (!left) { 309 if (!left) {
308 u32 bswapmask = fb_compute_bswapmask(p); 310 u32 bswapmask = fb_compute_bswapmask(p);
309 void (*fill_op32)(unsigned long __iomem *dst, int dst_idx, 311 void (*fill_op32)(struct fb_info *p,
312 unsigned long __iomem *dst, int dst_idx,
310 unsigned long pat, unsigned n, int bits, 313 unsigned long pat, unsigned n, int bits,
311 u32 bswapmask) = NULL; 314 u32 bswapmask) = NULL;
312 315
@@ -325,16 +328,17 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
325 while (height--) { 328 while (height--) {
326 dst += dst_idx >> (ffs(bits) - 1); 329 dst += dst_idx >> (ffs(bits) - 1);
327 dst_idx &= (bits - 1); 330 dst_idx &= (bits - 1);
328 fill_op32(dst, dst_idx, pat, width*bpp, bits, bswapmask); 331 fill_op32(p, dst, dst_idx, pat, width*bpp, bits,
332 bswapmask);
329 dst_idx += p->fix.line_length*8; 333 dst_idx += p->fix.line_length*8;
330 } 334 }
331 } else { 335 } else {
332 int right; 336 int right;
333 int r; 337 int r;
334 int rot = (left-dst_idx) % bpp; 338 int rot = (left-dst_idx) % bpp;
335 void (*fill_op)(unsigned long __iomem *dst, int dst_idx, 339 void (*fill_op)(struct fb_info *p, unsigned long __iomem *dst,
336 unsigned long pat, int left, int right, 340 int dst_idx, unsigned long pat, int left,
337 unsigned n, int bits) = NULL; 341 int right, unsigned n, int bits) = NULL;
338 342
339 /* rotate pattern to correct start position */ 343 /* rotate pattern to correct start position */
340 pat = pat << rot | pat >> (bpp-rot); 344 pat = pat << rot | pat >> (bpp-rot);
@@ -355,7 +359,7 @@ void cfb_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
355 while (height--) { 359 while (height--) {
356 dst += dst_idx >> (ffs(bits) - 1); 360 dst += dst_idx >> (ffs(bits) - 1);
357 dst_idx &= (bits - 1); 361 dst_idx &= (bits - 1);
358 fill_op(dst, dst_idx, pat, left, right, 362 fill_op(p, dst, dst_idx, pat, left, right,
359 width*bpp, bits); 363 width*bpp, bits);
360 r = (p->fix.line_length*8) % bpp; 364 r = (p->fix.line_length*8) % bpp;
361 pat = pat << (bpp-r) | pat >> r; 365 pat = pat << (bpp-r) | pat >> r;
diff --git a/drivers/video/cfbimgblt.c b/drivers/video/cfbimgblt.c
index f598907b42ad..baed57d3cfff 100644
--- a/drivers/video/cfbimgblt.c
+++ b/drivers/video/cfbimgblt.c
@@ -38,35 +38,31 @@
38#define DEBUG 38#define DEBUG
39 39
40#ifdef DEBUG 40#ifdef DEBUG
41#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__FUNCTION__,## args) 41#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__func__,## args)
42#else 42#else
43#define DPRINTK(fmt, args...) 43#define DPRINTK(fmt, args...)
44#endif 44#endif
45 45
46static const u32 cfb_tab8[] = { 46static const u32 cfb_tab8_be[] = {
47#if defined(__BIG_ENDIAN)
48 0x00000000,0x000000ff,0x0000ff00,0x0000ffff, 47 0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
49 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff, 48 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
50 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff, 49 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,
51 0xffff0000,0xffff00ff,0xffffff00,0xffffffff 50 0xffff0000,0xffff00ff,0xffffff00,0xffffffff
52#elif defined(__LITTLE_ENDIAN) 51};
52
53static const u32 cfb_tab8_le[] = {
53 0x00000000,0xff000000,0x00ff0000,0xffff0000, 54 0x00000000,0xff000000,0x00ff0000,0xffff0000,
54 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00, 55 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,
55 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff, 56 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,
56 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff 57 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff
57#else
58#error FIXME: No endianness??
59#endif
60}; 58};
61 59
62static const u32 cfb_tab16[] = { 60static const u32 cfb_tab16_be[] = {
63#if defined(__BIG_ENDIAN)
64 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff 61 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
65#elif defined(__LITTLE_ENDIAN) 62};
63
64static const u32 cfb_tab16_le[] = {
66 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff 65 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
67#else
68#error FIXME: No endianness??
69#endif
70}; 66};
71 67
72static const u32 cfb_tab32[] = { 68static const u32 cfb_tab32[] = {
@@ -98,7 +94,8 @@ static inline void color_imageblit(const struct fb_image *image,
98 val = 0; 94 val = 0;
99 95
100 if (start_index) { 96 if (start_index) {
101 u32 start_mask = ~fb_shifted_pixels_mask_u32(start_index, bswapmask); 97 u32 start_mask = ~fb_shifted_pixels_mask_u32(p,
98 start_index, bswapmask);
102 val = FB_READL(dst) & start_mask; 99 val = FB_READL(dst) & start_mask;
103 shift = start_index; 100 shift = start_index;
104 } 101 }
@@ -108,20 +105,21 @@ static inline void color_imageblit(const struct fb_image *image,
108 color = palette[*src]; 105 color = palette[*src];
109 else 106 else
110 color = *src; 107 color = *src;
111 color <<= FB_LEFT_POS(bpp); 108 color <<= FB_LEFT_POS(p, bpp);
112 val |= FB_SHIFT_HIGH(color, shift ^ bswapmask); 109 val |= FB_SHIFT_HIGH(p, color, shift ^ bswapmask);
113 if (shift >= null_bits) { 110 if (shift >= null_bits) {
114 FB_WRITEL(val, dst++); 111 FB_WRITEL(val, dst++);
115 112
116 val = (shift == null_bits) ? 0 : 113 val = (shift == null_bits) ? 0 :
117 FB_SHIFT_LOW(color, 32 - shift); 114 FB_SHIFT_LOW(p, color, 32 - shift);
118 } 115 }
119 shift += bpp; 116 shift += bpp;
120 shift &= (32 - 1); 117 shift &= (32 - 1);
121 src++; 118 src++;
122 } 119 }
123 if (shift) { 120 if (shift) {
124 u32 end_mask = fb_shifted_pixels_mask_u32(shift, bswapmask); 121 u32 end_mask = fb_shifted_pixels_mask_u32(p, shift,
122 bswapmask);
125 123
126 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); 124 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
127 } 125 }
@@ -152,8 +150,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
152 u32 bswapmask = fb_compute_bswapmask(p); 150 u32 bswapmask = fb_compute_bswapmask(p);
153 151
154 dst2 = (u32 __iomem *) dst1; 152 dst2 = (u32 __iomem *) dst1;
155 fgcolor <<= FB_LEFT_POS(bpp); 153 fgcolor <<= FB_LEFT_POS(p, bpp);
156 bgcolor <<= FB_LEFT_POS(bpp); 154 bgcolor <<= FB_LEFT_POS(p, bpp);
157 155
158 for (i = image->height; i--; ) { 156 for (i = image->height; i--; ) {
159 shift = val = 0; 157 shift = val = 0;
@@ -164,7 +162,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
164 162
165 /* write leading bits */ 163 /* write leading bits */
166 if (start_index) { 164 if (start_index) {
167 u32 start_mask = ~fb_shifted_pixels_mask_u32(start_index, bswapmask); 165 u32 start_mask = ~fb_shifted_pixels_mask_u32(p,
166 start_index, bswapmask);
168 val = FB_READL(dst) & start_mask; 167 val = FB_READL(dst) & start_mask;
169 shift = start_index; 168 shift = start_index;
170 } 169 }
@@ -172,13 +171,13 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
172 while (j--) { 171 while (j--) {
173 l--; 172 l--;
174 color = (*s & (1 << l)) ? fgcolor : bgcolor; 173 color = (*s & (1 << l)) ? fgcolor : bgcolor;
175 val |= FB_SHIFT_HIGH(color, shift ^ bswapmask); 174 val |= FB_SHIFT_HIGH(p, color, shift ^ bswapmask);
176 175
177 /* Did the bitshift spill bits to the next long? */ 176 /* Did the bitshift spill bits to the next long? */
178 if (shift >= null_bits) { 177 if (shift >= null_bits) {
179 FB_WRITEL(val, dst++); 178 FB_WRITEL(val, dst++);
180 val = (shift == null_bits) ? 0 : 179 val = (shift == null_bits) ? 0 :
181 FB_SHIFT_LOW(color,32 - shift); 180 FB_SHIFT_LOW(p, color, 32 - shift);
182 } 181 }
183 shift += bpp; 182 shift += bpp;
184 shift &= (32 - 1); 183 shift &= (32 - 1);
@@ -187,7 +186,8 @@ static inline void slow_imageblit(const struct fb_image *image, struct fb_info *
187 186
188 /* write trailing bits */ 187 /* write trailing bits */
189 if (shift) { 188 if (shift) {
190 u32 end_mask = fb_shifted_pixels_mask_u32(shift, bswapmask); 189 u32 end_mask = fb_shifted_pixels_mask_u32(p, shift,
190 bswapmask);
191 191
192 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst); 192 FB_WRITEL((FB_READL(dst) & end_mask) | val, dst);
193 } 193 }
@@ -223,13 +223,13 @@ static inline void fast_imageblit(const struct fb_image *image, struct fb_info *
223 u32 __iomem *dst; 223 u32 __iomem *dst;
224 const u32 *tab = NULL; 224 const u32 *tab = NULL;
225 int i, j, k; 225 int i, j, k;
226 226
227 switch (bpp) { 227 switch (bpp) {
228 case 8: 228 case 8:
229 tab = cfb_tab8; 229 tab = fb_be_math(p) ? cfb_tab8_be : cfb_tab8_le;
230 break; 230 break;
231 case 16: 231 case 16:
232 tab = cfb_tab16; 232 tab = fb_be_math(p) ? cfb_tab16_be : cfb_tab16_le;
233 break; 233 break;
234 case 32: 234 case 32:
235 default: 235 default:
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c
index fdc9f43ec30a..0db0fecba93b 100644
--- a/drivers/video/cg14.c
+++ b/drivers/video/cg14.c
@@ -556,7 +556,7 @@ static int __devinit cg14_probe(struct of_device *op, const struct of_device_id
556 556
557 dev_set_drvdata(&op->dev, info); 557 dev_set_drvdata(&op->dev, info);
558 558
559 printk("%s: cgfourteen at %lx:%lx, %dMB\n", 559 printk(KERN_INFO "%s: cgfourteen at %lx:%lx, %dMB\n",
560 dp->full_name, 560 dp->full_name,
561 par->iospace, par->physbase, 561 par->iospace, par->physbase,
562 par->ramsize >> 20); 562 par->ramsize >> 20);
@@ -605,7 +605,7 @@ static struct of_platform_driver cg14_driver = {
605 .remove = __devexit_p(cg14_remove), 605 .remove = __devexit_p(cg14_remove),
606}; 606};
607 607
608int __init cg14_init(void) 608static int __init cg14_init(void)
609{ 609{
610 if (fb_get_options("cg14fb", NULL)) 610 if (fb_get_options("cg14fb", NULL))
611 return -ENODEV; 611 return -ENODEV;
@@ -613,7 +613,7 @@ int __init cg14_init(void)
613 return of_register_driver(&cg14_driver, &of_bus_type); 613 return of_register_driver(&cg14_driver, &of_bus_type);
614} 614}
615 615
616void __exit cg14_exit(void) 616static void __exit cg14_exit(void)
617{ 617{
618 of_unregister_driver(&cg14_driver); 618 of_unregister_driver(&cg14_driver);
619} 619}
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c
index a5c7fb331527..010ea53978f8 100644
--- a/drivers/video/cg3.c
+++ b/drivers/video/cg3.c
@@ -419,7 +419,7 @@ static int __devinit cg3_probe(struct of_device *op,
419 419
420 dev_set_drvdata(&op->dev, info); 420 dev_set_drvdata(&op->dev, info);
421 421
422 printk("%s: cg3 at %lx:%lx\n", 422 printk(KERN_INFO "%s: cg3 at %lx:%lx\n",
423 dp->full_name, par->which_io, par->physbase); 423 dp->full_name, par->which_io, par->physbase);
424 424
425 return 0; 425 return 0;
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c
index 549891d76ef5..fc90db6da65a 100644
--- a/drivers/video/cg6.c
+++ b/drivers/video/cg6.c
@@ -781,7 +781,7 @@ static int __devinit cg6_probe(struct of_device *op,
781 781
782 dev_set_drvdata(&op->dev, info); 782 dev_set_drvdata(&op->dev, info);
783 783
784 printk("%s: CGsix [%s] at %lx:%lx\n", 784 printk(KERN_INFO "%s: CGsix [%s] at %lx:%lx\n",
785 dp->full_name, info->fix.id, 785 dp->full_name, info->fix.id,
786 par->which_io, par->physbase); 786 par->which_io, par->physbase);
787 787
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index f7e2d5add831..35ac9d956b3d 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -81,7 +81,7 @@
81/* debug output */ 81/* debug output */
82#ifdef CIRRUSFB_DEBUG 82#ifdef CIRRUSFB_DEBUG
83#define DPRINTK(fmt, args...) \ 83#define DPRINTK(fmt, args...) \
84 printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) 84 printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
85#else 85#else
86#define DPRINTK(fmt, args...) 86#define DPRINTK(fmt, args...)
87#endif 87#endif
@@ -91,7 +91,7 @@
91#define assert(expr) \ 91#define assert(expr) \
92 if (!(expr)) { \ 92 if (!(expr)) { \
93 printk("Assertion failed! %s,%s,%s,line=%d\n", \ 93 printk("Assertion failed! %s,%s,%s,line=%d\n", \
94 #expr, __FILE__, __FUNCTION__, __LINE__); \ 94 #expr, __FILE__, __func__, __LINE__); \
95 } 95 }
96#else 96#else
97#define assert(expr) 97#define assert(expr)
@@ -3117,7 +3117,7 @@ static void bestclock(long freq, long *best, long *nom,
3117 } 3117 }
3118 } 3118 }
3119 } 3119 }
3120 d = ((143181 * n) + f - 1) / f; 3120 d = DIV_ROUND_UP(143181 * n, f);
3121 if ((d >= 7) && (d <= 63)) { 3121 if ((d >= 7) && (d <= 63)) {
3122 if (d > 31) 3122 if (d > 31)
3123 d = (d / 2) * 2; 3123 d = (d / 2) * 2;
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 022282494d3f..8eda7b60df8f 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -92,7 +92,7 @@
92#include "fbcon.h" 92#include "fbcon.h"
93 93
94#ifdef FBCONDEBUG 94#ifdef FBCONDEBUG
95# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) 95# define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
96#else 96#else
97# define DPRINTK(fmt, args...) 97# define DPRINTK(fmt, args...)
98#endif 98#endif
@@ -620,8 +620,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
620 if (fb_get_color_depth(&info->var, &info->fix) == 1) 620 if (fb_get_color_depth(&info->var, &info->fix) == 1)
621 erase &= ~0x400; 621 erase &= ~0x400;
622 logo_height = fb_prepare_logo(info, ops->rotate); 622 logo_height = fb_prepare_logo(info, ops->rotate);
623 logo_lines = (logo_height + vc->vc_font.height - 1) / 623 logo_lines = DIV_ROUND_UP(logo_height, vc->vc_font.height);
624 vc->vc_font.height;
625 q = (unsigned short *) (vc->vc_origin + 624 q = (unsigned short *) (vc->vc_origin +
626 vc->vc_size_row * rows); 625 vc->vc_size_row * rows);
627 step = logo_lines * cols; 626 step = logo_lines * cols;
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h
index 3706307e70ed..0135e0395456 100644
--- a/drivers/video/console/fbcon.h
+++ b/drivers/video/console/fbcon.h
@@ -104,10 +104,14 @@ struct fbcon_ops {
104#define attr_blink(s) \ 104#define attr_blink(s) \
105 ((s) & 0x8000) 105 ((s) & 0x8000)
106 106
107#define mono_col(info) \ 107
108 (~(0xfff << (max((info)->var.green.length, \ 108static inline int mono_col(const struct fb_info *info)
109 max((info)->var.red.length, \ 109{
110 (info)->var.blue.length)))) & 0xff) 110 __u32 max_len;
111 max_len = max(info->var.green.length, info->var.red.length);
112 max_len = max(info->var.blue.length, max_len);
113 return ~(0xfff << (max_len & 0xff));
114}
111 115
112static inline int attr_col_ec(int shift, struct vc_data *vc, 116static inline int attr_col_ec(int shift, struct vc_data *vc,
113 struct fb_info *info, int is_fg) 117 struct fb_info *info, int is_fg)
diff --git a/drivers/video/fb_draw.h b/drivers/video/fb_draw.h
index a2a0618d86a5..1db622192bde 100644
--- a/drivers/video/fb_draw.h
+++ b/drivers/video/fb_draw.h
@@ -94,41 +94,44 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val,
94 return val; 94 return val;
95} 95}
96 96
97static inline u32 fb_shifted_pixels_mask_u32(u32 index, u32 bswapmask) 97static inline u32 fb_shifted_pixels_mask_u32(struct fb_info *p, u32 index,
98 u32 bswapmask)
98{ 99{
99 u32 mask; 100 u32 mask;
100 101
101 if (!bswapmask) { 102 if (!bswapmask) {
102 mask = FB_SHIFT_HIGH(~(u32)0, index); 103 mask = FB_SHIFT_HIGH(p, ~(u32)0, index);
103 } else { 104 } else {
104 mask = 0xff << FB_LEFT_POS(8); 105 mask = 0xff << FB_LEFT_POS(p, 8);
105 mask = FB_SHIFT_LOW(mask, index & (bswapmask)) & mask; 106 mask = FB_SHIFT_LOW(p, mask, index & (bswapmask)) & mask;
106 mask = FB_SHIFT_HIGH(mask, index & ~(bswapmask)); 107 mask = FB_SHIFT_HIGH(p, mask, index & ~(bswapmask));
107#if defined(__i386__) || defined(__x86_64__) 108#if defined(__i386__) || defined(__x86_64__)
108 /* Shift argument is limited to 0 - 31 on x86 based CPU's */ 109 /* Shift argument is limited to 0 - 31 on x86 based CPU's */
109 if(index + bswapmask < 32) 110 if(index + bswapmask < 32)
110#endif 111#endif
111 mask |= FB_SHIFT_HIGH(~(u32)0, 112 mask |= FB_SHIFT_HIGH(p, ~(u32)0,
112 (index + bswapmask) & ~(bswapmask)); 113 (index + bswapmask) & ~(bswapmask));
113 } 114 }
114 return mask; 115 return mask;
115} 116}
116 117
117static inline unsigned long fb_shifted_pixels_mask_long(u32 index, u32 bswapmask) 118static inline unsigned long fb_shifted_pixels_mask_long(struct fb_info *p,
119 u32 index,
120 u32 bswapmask)
118{ 121{
119 unsigned long mask; 122 unsigned long mask;
120 123
121 if (!bswapmask) { 124 if (!bswapmask) {
122 mask = FB_SHIFT_HIGH(~0UL, index); 125 mask = FB_SHIFT_HIGH(p, ~0UL, index);
123 } else { 126 } else {
124 mask = 0xff << FB_LEFT_POS(8); 127 mask = 0xff << FB_LEFT_POS(p, 8);
125 mask = FB_SHIFT_LOW(mask, index & (bswapmask)) & mask; 128 mask = FB_SHIFT_LOW(p, mask, index & (bswapmask)) & mask;
126 mask = FB_SHIFT_HIGH(mask, index & ~(bswapmask)); 129 mask = FB_SHIFT_HIGH(p, mask, index & ~(bswapmask));
127#if defined(__i386__) || defined(__x86_64__) 130#if defined(__i386__) || defined(__x86_64__)
128 /* Shift argument is limited to 0 - 31 on x86 based CPU's */ 131 /* Shift argument is limited to 0 - 31 on x86 based CPU's */
129 if(index + bswapmask < BITS_PER_LONG) 132 if(index + bswapmask < BITS_PER_LONG)
130#endif 133#endif
131 mask |= FB_SHIFT_HIGH(~0UL, 134 mask |= FB_SHIFT_HIGH(p, ~0UL,
132 (index + bswapmask) & ~(bswapmask)); 135 (index + bswapmask) & ~(bswapmask));
133 } 136 }
134 return mask; 137 return mask;
@@ -158,8 +161,8 @@ static inline unsigned long fb_rev_pixels_in_long(unsigned long val,
158 return val; 161 return val;
159} 162}
160 163
161#define fb_shifted_pixels_mask_u32(i, b) FB_SHIFT_HIGH(~(u32)0, (i)) 164#define fb_shifted_pixels_mask_u32(p, i, b) FB_SHIFT_HIGH((p), ~(u32)0, (i))
162#define fb_shifted_pixels_mask_long(i, b) FB_SHIFT_HIGH(~0UL, (i)) 165#define fb_shifted_pixels_mask_long(p, i, b) FB_SHIFT_HIGH((p), ~0UL, (i))
163#define fb_compute_bswapmask(...) 0 166#define fb_compute_bswapmask(...) 0
164 167
165#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */ 168#endif /* CONFIG_FB_CFB_REV_PIXELS_IN_BYTE */
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index 01072f4b3e8f..776f7fcd2fbf 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -26,6 +26,7 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/linux_logo.h> 27#include <linux/linux_logo.h>
28#include <linux/proc_fs.h> 28#include <linux/proc_fs.h>
29#include <linux/seq_file.h>
29#include <linux/console.h> 30#include <linux/console.h>
30#ifdef CONFIG_KMOD 31#ifdef CONFIG_KMOD
31#include <linux/kmod.h> 32#include <linux/kmod.h>
@@ -632,27 +633,51 @@ int fb_prepare_logo(struct fb_info *info, int rotate) { return 0; }
632int fb_show_logo(struct fb_info *info, int rotate) { return 0; } 633int fb_show_logo(struct fb_info *info, int rotate) { return 0; }
633#endif /* CONFIG_LOGO */ 634#endif /* CONFIG_LOGO */
634 635
635static int fbmem_read_proc(char *buf, char **start, off_t offset, 636static void *fb_seq_start(struct seq_file *m, loff_t *pos)
636 int len, int *eof, void *private)
637{ 637{
638 struct fb_info **fi; 638 return (*pos < FB_MAX) ? pos : NULL;
639 int clen; 639}
640 640
641 clen = 0; 641static void *fb_seq_next(struct seq_file *m, void *v, loff_t *pos)
642 for (fi = registered_fb; fi < &registered_fb[FB_MAX] && clen < 4000; 642{
643 fi++) 643 (*pos)++;
644 if (*fi) 644 return (*pos < FB_MAX) ? pos : NULL;
645 clen += sprintf(buf + clen, "%d %s\n", 645}
646 (*fi)->node, 646
647 (*fi)->fix.id); 647static void fb_seq_stop(struct seq_file *m, void *v)
648 *start = buf + offset; 648{
649 if (clen > offset) 649}
650 clen -= offset; 650
651 else 651static int fb_seq_show(struct seq_file *m, void *v)
652 clen = 0; 652{
653 return clen < len ? clen : len; 653 int i = *(loff_t *)v;
654 struct fb_info *fi = registered_fb[i];
655
656 if (fi)
657 seq_printf(m, "%d %s\n", fi->node, fi->fix.id);
658 return 0;
659}
660
661static const struct seq_operations proc_fb_seq_ops = {
662 .start = fb_seq_start,
663 .next = fb_seq_next,
664 .stop = fb_seq_stop,
665 .show = fb_seq_show,
666};
667
668static int proc_fb_open(struct inode *inode, struct file *file)
669{
670 return seq_open(file, &proc_fb_seq_ops);
654} 671}
655 672
673static const struct file_operations fb_proc_fops = {
674 .owner = THIS_MODULE,
675 .open = proc_fb_open,
676 .read = seq_read,
677 .llseek = seq_lseek,
678 .release = seq_release,
679};
680
656static ssize_t 681static ssize_t
657fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 682fb_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
658{ 683{
@@ -1057,7 +1082,7 @@ fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
1057 case FBIOPUT_CON2FBMAP: 1082 case FBIOPUT_CON2FBMAP:
1058 if (copy_from_user(&con2fb, argp, sizeof(con2fb))) 1083 if (copy_from_user(&con2fb, argp, sizeof(con2fb)))
1059 return - EFAULT; 1084 return - EFAULT;
1060 if (con2fb.console < 0 || con2fb.console > MAX_NR_CONSOLES) 1085 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
1061 return -EINVAL; 1086 return -EINVAL;
1062 if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) 1087 if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
1063 return -EINVAL; 1088 return -EINVAL;
@@ -1352,6 +1377,32 @@ static const struct file_operations fb_fops = {
1352 1377
1353struct class *fb_class; 1378struct class *fb_class;
1354EXPORT_SYMBOL(fb_class); 1379EXPORT_SYMBOL(fb_class);
1380
1381static int fb_check_foreignness(struct fb_info *fi)
1382{
1383 const bool foreign_endian = fi->flags & FBINFO_FOREIGN_ENDIAN;
1384
1385 fi->flags &= ~FBINFO_FOREIGN_ENDIAN;
1386
1387#ifdef __BIG_ENDIAN
1388 fi->flags |= foreign_endian ? 0 : FBINFO_BE_MATH;
1389#else
1390 fi->flags |= foreign_endian ? FBINFO_BE_MATH : 0;
1391#endif /* __BIG_ENDIAN */
1392
1393 if (fi->flags & FBINFO_BE_MATH && !fb_be_math(fi)) {
1394 pr_err("%s: enable CONFIG_FB_BIG_ENDIAN to "
1395 "support this framebuffer\n", fi->fix.id);
1396 return -ENOSYS;
1397 } else if (!(fi->flags & FBINFO_BE_MATH) && fb_be_math(fi)) {
1398 pr_err("%s: enable CONFIG_FB_LITTLE_ENDIAN to "
1399 "support this framebuffer\n", fi->fix.id);
1400 return -ENOSYS;
1401 }
1402
1403 return 0;
1404}
1405
1355/** 1406/**
1356 * register_framebuffer - registers a frame buffer device 1407 * register_framebuffer - registers a frame buffer device
1357 * @fb_info: frame buffer info structure 1408 * @fb_info: frame buffer info structure
@@ -1371,6 +1422,10 @@ register_framebuffer(struct fb_info *fb_info)
1371 1422
1372 if (num_registered_fb == FB_MAX) 1423 if (num_registered_fb == FB_MAX)
1373 return -ENXIO; 1424 return -ENXIO;
1425
1426 if (fb_check_foreignness(fb_info))
1427 return -ENOSYS;
1428
1374 num_registered_fb++; 1429 num_registered_fb++;
1375 for (i = 0 ; i < FB_MAX; i++) 1430 for (i = 0 ; i < FB_MAX; i++)
1376 if (!registered_fb[i]) 1431 if (!registered_fb[i])
@@ -1503,7 +1558,7 @@ void fb_set_suspend(struct fb_info *info, int state)
1503static int __init 1558static int __init
1504fbmem_init(void) 1559fbmem_init(void)
1505{ 1560{
1506 create_proc_read_entry("fb", 0, NULL, fbmem_read_proc, NULL); 1561 proc_create("fb", 0, NULL, &fb_proc_fops);
1507 1562
1508 if (register_chrdev(FB_MAJOR,"fb",&fb_fops)) 1563 if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
1509 printk("unable to get major %d for fb devs\n", FB_MAJOR); 1564 printk("unable to get major %d for fb devs\n", FB_MAJOR);
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index d7e24889650e..93dca3e2aa50 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -32,7 +32,6 @@
32static int ffb_setcolreg(unsigned, unsigned, unsigned, unsigned, 32static int ffb_setcolreg(unsigned, unsigned, unsigned, unsigned,
33 unsigned, struct fb_info *); 33 unsigned, struct fb_info *);
34static int ffb_blank(int, struct fb_info *); 34static int ffb_blank(int, struct fb_info *);
35static void ffb_init_fix(struct fb_info *);
36 35
37static void ffb_imageblit(struct fb_info *, const struct fb_image *); 36static void ffb_imageblit(struct fb_info *, const struct fb_image *);
38static void ffb_fillrect(struct fb_info *, const struct fb_fillrect *); 37static void ffb_fillrect(struct fb_info *, const struct fb_fillrect *);
@@ -1001,7 +1000,7 @@ static int __devinit ffb_probe(struct of_device *op,
1001 1000
1002 dev_set_drvdata(&op->dev, info); 1001 dev_set_drvdata(&op->dev, info);
1003 1002
1004 printk("%s: %s at %016lx, type %d, " 1003 printk(KERN_INFO "%s: %s at %016lx, type %d, "
1005 "DAC pnum[%x] rev[%d] manuf_rev[%d]\n", 1004 "DAC pnum[%x] rev[%d] manuf_rev[%d]\n",
1006 dp->full_name, 1005 dp->full_name,
1007 ((par->flags & FFB_FLAG_AFB) ? "AFB" : "FFB"), 1006 ((par->flags & FFB_FLAG_AFB) ? "AFB" : "FFB"),
@@ -1062,7 +1061,7 @@ static struct of_platform_driver ffb_driver = {
1062 .remove = __devexit_p(ffb_remove), 1061 .remove = __devexit_p(ffb_remove),
1063}; 1062};
1064 1063
1065int __init ffb_init(void) 1064static int __init ffb_init(void)
1066{ 1065{
1067 if (fb_get_options("ffb", NULL)) 1066 if (fb_get_options("ffb", NULL))
1068 return -ENODEV; 1067 return -ENODEV;
@@ -1070,7 +1069,7 @@ int __init ffb_init(void)
1070 return of_register_driver(&ffb_driver, &of_bus_type); 1069 return of_register_driver(&ffb_driver, &of_bus_type);
1071} 1070}
1072 1071
1073void __exit ffb_exit(void) 1072static void __exit ffb_exit(void)
1074{ 1073{
1075 of_unregister_driver(&ffb_driver); 1074 of_unregister_driver(&ffb_driver);
1076} 1075}
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
new file mode 100644
index 000000000000..b50bb03cb5ab
--- /dev/null
+++ b/drivers/video/fsl-diu-fb.c
@@ -0,0 +1,1721 @@
1/*
2 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * Freescale DIU Frame Buffer device driver
5 *
6 * Authors: Hongjun Chen <hong-jun.chen@freescale.com>
7 * Paul Widmer <paul.widmer@freescale.com>
8 * Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
9 * York Sun <yorksun@freescale.com>
10 *
11 * Based on imxfb.c Copyright (C) 2004 S.Hauer, Pengutronix
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 */
19
20#include <linux/module.h>
21#include <linux/kernel.h>
22#include <linux/errno.h>
23#include <linux/string.h>
24#include <linux/slab.h>
25#include <linux/fb.h>
26#include <linux/init.h>
27#include <linux/dma-mapping.h>
28#include <linux/platform_device.h>
29#include <linux/interrupt.h>
30#include <linux/clk.h>
31#include <linux/uaccess.h>
32#include <linux/vmalloc.h>
33
34#include <linux/of_platform.h>
35
36#include <sysdev/fsl_soc.h>
37#include "fsl-diu-fb.h"
38
39/*
40 * These parameters give default parameters
41 * for video output 1024x768,
42 * FIXME - change timing to proper amounts
43 * hsync 31.5kHz, vsync 60Hz
44 */
45static struct fb_videomode __devinitdata fsl_diu_default_mode = {
46 .refresh = 60,
47 .xres = 1024,
48 .yres = 768,
49 .pixclock = 15385,
50 .left_margin = 160,
51 .right_margin = 24,
52 .upper_margin = 29,
53 .lower_margin = 3,
54 .hsync_len = 136,
55 .vsync_len = 6,
56 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
57 .vmode = FB_VMODE_NONINTERLACED
58};
59
60static struct fb_videomode __devinitdata fsl_diu_mode_db[] = {
61 {
62 .name = "1024x768-60",
63 .refresh = 60,
64 .xres = 1024,
65 .yres = 768,
66 .pixclock = 15385,
67 .left_margin = 160,
68 .right_margin = 24,
69 .upper_margin = 29,
70 .lower_margin = 3,
71 .hsync_len = 136,
72 .vsync_len = 6,
73 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
74 .vmode = FB_VMODE_NONINTERLACED
75 },
76 {
77 .name = "1024x768-70",
78 .refresh = 70,
79 .xres = 1024,
80 .yres = 768,
81 .pixclock = 16886,
82 .left_margin = 3,
83 .right_margin = 3,
84 .upper_margin = 2,
85 .lower_margin = 2,
86 .hsync_len = 40,
87 .vsync_len = 18,
88 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
89 .vmode = FB_VMODE_NONINTERLACED
90 },
91 {
92 .name = "1024x768-75",
93 .refresh = 75,
94 .xres = 1024,
95 .yres = 768,
96 .pixclock = 15009,
97 .left_margin = 3,
98 .right_margin = 3,
99 .upper_margin = 2,
100 .lower_margin = 2,
101 .hsync_len = 80,
102 .vsync_len = 32,
103 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
104 .vmode = FB_VMODE_NONINTERLACED
105 },
106 {
107 .name = "1280x1024-60",
108 .refresh = 60,
109 .xres = 1280,
110 .yres = 1024,
111 .pixclock = 9375,
112 .left_margin = 38,
113 .right_margin = 128,
114 .upper_margin = 2,
115 .lower_margin = 7,
116 .hsync_len = 216,
117 .vsync_len = 37,
118 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
119 .vmode = FB_VMODE_NONINTERLACED
120 },
121 {
122 .name = "1280x1024-70",
123 .refresh = 70,
124 .xres = 1280,
125 .yres = 1024,
126 .pixclock = 9380,
127 .left_margin = 6,
128 .right_margin = 6,
129 .upper_margin = 4,
130 .lower_margin = 4,
131 .hsync_len = 60,
132 .vsync_len = 94,
133 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
134 .vmode = FB_VMODE_NONINTERLACED
135 },
136 {
137 .name = "1280x1024-75",
138 .refresh = 75,
139 .xres = 1280,
140 .yres = 1024,
141 .pixclock = 9380,
142 .left_margin = 6,
143 .right_margin = 6,
144 .upper_margin = 4,
145 .lower_margin = 4,
146 .hsync_len = 60,
147 .vsync_len = 15,
148 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
149 .vmode = FB_VMODE_NONINTERLACED
150 },
151 {
152 .name = "320x240", /* for AOI only */
153 .refresh = 60,
154 .xres = 320,
155 .yres = 240,
156 .pixclock = 15385,
157 .left_margin = 0,
158 .right_margin = 0,
159 .upper_margin = 0,
160 .lower_margin = 0,
161 .hsync_len = 0,
162 .vsync_len = 0,
163 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
164 .vmode = FB_VMODE_NONINTERLACED
165 },
166 {
167 .name = "1280x480-60",
168 .refresh = 60,
169 .xres = 1280,
170 .yres = 480,
171 .pixclock = 18939,
172 .left_margin = 353,
173 .right_margin = 47,
174 .upper_margin = 39,
175 .lower_margin = 4,
176 .hsync_len = 8,
177 .vsync_len = 2,
178 .sync = FB_SYNC_COMP_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
179 .vmode = FB_VMODE_NONINTERLACED
180 },
181};
182
183static char *fb_mode = "1024x768-32@60";
184static unsigned long default_bpp = 32;
185static int monitor_port;
186
187#if defined(CONFIG_NOT_COHERENT_CACHE)
188static u8 *coherence_data;
189static size_t coherence_data_size;
190static unsigned int d_cache_line_size;
191#endif
192
193static DEFINE_SPINLOCK(diu_lock);
194
195struct fsl_diu_data {
196 struct fb_info *fsl_diu_info[FSL_AOI_NUM - 1];
197 /*FSL_AOI_NUM has one dummy AOI */
198 struct device_attribute dev_attr;
199 struct diu_ad *dummy_ad;
200 void *dummy_aoi_virt;
201 unsigned int irq;
202 int fb_enabled;
203 int monitor_port;
204};
205
206struct mfb_info {
207 int index;
208 int type;
209 char *id;
210 int registered;
211 int blank;
212 unsigned long pseudo_palette[16];
213 struct diu_ad *ad;
214 int cursor_reset;
215 unsigned char g_alpha;
216 unsigned int count;
217 int x_aoi_d; /* aoi display x offset to physical screen */
218 int y_aoi_d; /* aoi display y offset to physical screen */
219 struct fsl_diu_data *parent;
220};
221
222
223static struct mfb_info mfb_template[] = {
224 { /* AOI 0 for plane 0 */
225 .index = 0,
226 .type = MFB_TYPE_OUTPUT,
227 .id = "Panel0",
228 .registered = 0,
229 .count = 0,
230 .x_aoi_d = 0,
231 .y_aoi_d = 0,
232 },
233 { /* AOI 0 for plane 1 */
234 .index = 1,
235 .type = MFB_TYPE_OUTPUT,
236 .id = "Panel1 AOI0",
237 .registered = 0,
238 .g_alpha = 0xff,
239 .count = 0,
240 .x_aoi_d = 0,
241 .y_aoi_d = 0,
242 },
243 { /* AOI 1 for plane 1 */
244 .index = 2,
245 .type = MFB_TYPE_OUTPUT,
246 .id = "Panel1 AOI1",
247 .registered = 0,
248 .g_alpha = 0xff,
249 .count = 0,
250 .x_aoi_d = 0,
251 .y_aoi_d = 480,
252 },
253 { /* AOI 0 for plane 2 */
254 .index = 3,
255 .type = MFB_TYPE_OUTPUT,
256 .id = "Panel2 AOI0",
257 .registered = 0,
258 .g_alpha = 0xff,
259 .count = 0,
260 .x_aoi_d = 640,
261 .y_aoi_d = 0,
262 },
263 { /* AOI 1 for plane 2 */
264 .index = 4,
265 .type = MFB_TYPE_OUTPUT,
266 .id = "Panel2 AOI1",
267 .registered = 0,
268 .g_alpha = 0xff,
269 .count = 0,
270 .x_aoi_d = 640,
271 .y_aoi_d = 480,
272 },
273};
274
275static struct diu_hw dr = {
276 .mode = MFB_MODE1,
277 .reg_lock = __SPIN_LOCK_UNLOCKED(diu_hw.reg_lock),
278};
279
280static struct diu_pool pool;
281
282/* To allocate memory for framebuffer. First try __get_free_pages(). If it
283 * fails, try rh_alloc. The reason is __get_free_pages() cannot allocate
284 * very large memory (more than 4MB). We don't want to allocate all memory
285 * in rheap since small memory allocation/deallocation will fragment the
286 * rheap and make the furture large allocation fail.
287 */
288
289void *fsl_diu_alloc(unsigned long size, phys_addr_t *phys)
290{
291 void *virt;
292
293 pr_debug("size=%lu\n", size);
294
295 virt = (void *)__get_free_pages(GFP_DMA | __GFP_ZERO, get_order(size));
296 if (virt) {
297 *phys = virt_to_phys(virt);
298 pr_debug("virt %p, phys=%llx\n", virt, (uint64_t) *phys);
299 return virt;
300 }
301 if (!diu_ops.diu_mem) {
302 printk(KERN_INFO "%s: no diu_mem."
303 " To reserve more memory, put 'diufb=15M' "
304 "in the command line\n", __func__);
305 return NULL;
306 }
307
308 virt = (void *)rh_alloc(&diu_ops.diu_rh_info, size, "DIU");
309 if (virt) {
310 *phys = virt_to_bus(virt);
311 memset(virt, 0, size);
312 }
313
314 pr_debug("rh virt=%p phys=%lx\n", virt, *phys);
315
316 return virt;
317}
318
319void fsl_diu_free(void *p, unsigned long size)
320{
321 pr_debug("p=%p size=%lu\n", p, size);
322
323 if (!p)
324 return;
325
326 if ((p >= diu_ops.diu_mem) &&
327 (p < (diu_ops.diu_mem + diu_ops.diu_size))) {
328 pr_debug("rh\n");
329 rh_free(&diu_ops.diu_rh_info, (unsigned long) p);
330 } else {
331 pr_debug("dma\n");
332 free_pages((unsigned long)p, get_order(size));
333 }
334}
335
336static int fsl_diu_enable_panel(struct fb_info *info)
337{
338 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
339 struct diu *hw = dr.diu_reg;
340 struct diu_ad *ad = mfbi->ad;
341 struct fsl_diu_data *machine_data = mfbi->parent;
342 int res = 0;
343
344 pr_debug("enable_panel index %d\n", mfbi->index);
345 if (mfbi->type != MFB_TYPE_OFF) {
346 switch (mfbi->index) {
347 case 0: /* plane 0 */
348 if (hw->desc[0] != ad->paddr)
349 out_be32(&hw->desc[0], ad->paddr);
350 break;
351 case 1: /* plane 1 AOI 0 */
352 cmfbi = machine_data->fsl_diu_info[2]->par;
353 if (hw->desc[1] != ad->paddr) { /* AOI0 closed */
354 if (cmfbi->count > 0) /* AOI1 open */
355 ad->next_ad =
356 cpu_to_le32(cmfbi->ad->paddr);
357 else
358 ad->next_ad = 0;
359 out_be32(&hw->desc[1], ad->paddr);
360 }
361 break;
362 case 3: /* plane 2 AOI 0 */
363 cmfbi = machine_data->fsl_diu_info[4]->par;
364 if (hw->desc[2] != ad->paddr) { /* AOI0 closed */
365 if (cmfbi->count > 0) /* AOI1 open */
366 ad->next_ad =
367 cpu_to_le32(cmfbi->ad->paddr);
368 else
369 ad->next_ad = 0;
370 out_be32(&hw->desc[2], ad->paddr);
371 }
372 break;
373 case 2: /* plane 1 AOI 1 */
374 pmfbi = machine_data->fsl_diu_info[1]->par;
375 ad->next_ad = 0;
376 if (hw->desc[1] == machine_data->dummy_ad->paddr)
377 out_be32(&hw->desc[1], ad->paddr);
378 else /* AOI0 open */
379 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
380 break;
381 case 4: /* plane 2 AOI 1 */
382 pmfbi = machine_data->fsl_diu_info[3]->par;
383 ad->next_ad = 0;
384 if (hw->desc[2] == machine_data->dummy_ad->paddr)
385 out_be32(&hw->desc[2], ad->paddr);
386 else /* AOI0 was open */
387 pmfbi->ad->next_ad = cpu_to_le32(ad->paddr);
388 break;
389 default:
390 res = -EINVAL;
391 break;
392 }
393 } else
394 res = -EINVAL;
395 return res;
396}
397
398static int fsl_diu_disable_panel(struct fb_info *info)
399{
400 struct mfb_info *pmfbi, *cmfbi, *mfbi = info->par;
401 struct diu *hw = dr.diu_reg;
402 struct diu_ad *ad = mfbi->ad;
403 struct fsl_diu_data *machine_data = mfbi->parent;
404 int res = 0;
405
406 switch (mfbi->index) {
407 case 0: /* plane 0 */
408 if (hw->desc[0] != machine_data->dummy_ad->paddr)
409 out_be32(&hw->desc[0],
410 machine_data->dummy_ad->paddr);
411 break;
412 case 1: /* plane 1 AOI 0 */
413 cmfbi = machine_data->fsl_diu_info[2]->par;
414 if (cmfbi->count > 0) /* AOI1 is open */
415 out_be32(&hw->desc[1], cmfbi->ad->paddr);
416 /* move AOI1 to the first */
417 else /* AOI1 was closed */
418 out_be32(&hw->desc[1],
419 machine_data->dummy_ad->paddr);
420 /* close AOI 0 */
421 break;
422 case 3: /* plane 2 AOI 0 */
423 cmfbi = machine_data->fsl_diu_info[4]->par;
424 if (cmfbi->count > 0) /* AOI1 is open */
425 out_be32(&hw->desc[2], cmfbi->ad->paddr);
426 /* move AOI1 to the first */
427 else /* AOI1 was closed */
428 out_be32(&hw->desc[2],
429 machine_data->dummy_ad->paddr);
430 /* close AOI 0 */
431 break;
432 case 2: /* plane 1 AOI 1 */
433 pmfbi = machine_data->fsl_diu_info[1]->par;
434 if (hw->desc[1] != ad->paddr) {
435 /* AOI1 is not the first in the chain */
436 if (pmfbi->count > 0)
437 /* AOI0 is open, must be the first */
438 pmfbi->ad->next_ad = 0;
439 } else /* AOI1 is the first in the chain */
440 out_be32(&hw->desc[1], machine_data->dummy_ad->paddr);
441 /* close AOI 1 */
442 break;
443 case 4: /* plane 2 AOI 1 */
444 pmfbi = machine_data->fsl_diu_info[3]->par;
445 if (hw->desc[2] != ad->paddr) {
446 /* AOI1 is not the first in the chain */
447 if (pmfbi->count > 0)
448 /* AOI0 is open, must be the first */
449 pmfbi->ad->next_ad = 0;
450 } else /* AOI1 is the first in the chain */
451 out_be32(&hw->desc[2], machine_data->dummy_ad->paddr);
452 /* close AOI 1 */
453 break;
454 default:
455 res = -EINVAL;
456 break;
457 }
458
459 return res;
460}
461
462static void enable_lcdc(struct fb_info *info)
463{
464 struct diu *hw = dr.diu_reg;
465 struct mfb_info *mfbi = info->par;
466 struct fsl_diu_data *machine_data = mfbi->parent;
467
468 if (!machine_data->fb_enabled) {
469 out_be32(&hw->diu_mode, dr.mode);
470 machine_data->fb_enabled++;
471 }
472}
473
474static void disable_lcdc(struct fb_info *info)
475{
476 struct diu *hw = dr.diu_reg;
477 struct mfb_info *mfbi = info->par;
478 struct fsl_diu_data *machine_data = mfbi->parent;
479
480 if (machine_data->fb_enabled) {
481 out_be32(&hw->diu_mode, 0);
482 machine_data->fb_enabled = 0;
483 }
484}
485
486static void adjust_aoi_size_position(struct fb_var_screeninfo *var,
487 struct fb_info *info)
488{
489 struct mfb_info *lower_aoi_mfbi, *upper_aoi_mfbi, *mfbi = info->par;
490 struct fsl_diu_data *machine_data = mfbi->parent;
491 int available_height, upper_aoi_bottom, index = mfbi->index;
492 int lower_aoi_is_open, upper_aoi_is_open;
493 __u32 base_plane_width, base_plane_height, upper_aoi_height;
494
495 base_plane_width = machine_data->fsl_diu_info[0]->var.xres;
496 base_plane_height = machine_data->fsl_diu_info[0]->var.yres;
497
498 switch (index) {
499 case 0:
500 if (mfbi->x_aoi_d != 0)
501 mfbi->x_aoi_d = 0;
502 if (mfbi->y_aoi_d != 0)
503 mfbi->y_aoi_d = 0;
504 break;
505 case 1: /* AOI 0 */
506 case 3:
507 lower_aoi_mfbi = machine_data->fsl_diu_info[index+1]->par;
508 lower_aoi_is_open = lower_aoi_mfbi->count > 0 ? 1 : 0;
509 if (var->xres > base_plane_width)
510 var->xres = base_plane_width;
511 if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
512 mfbi->x_aoi_d = base_plane_width - var->xres;
513
514 if (lower_aoi_is_open)
515 available_height = lower_aoi_mfbi->y_aoi_d;
516 else
517 available_height = base_plane_height;
518 if (var->yres > available_height)
519 var->yres = available_height;
520 if ((mfbi->y_aoi_d + var->yres) > available_height)
521 mfbi->y_aoi_d = available_height - var->yres;
522 break;
523 case 2: /* AOI 1 */
524 case 4:
525 upper_aoi_mfbi = machine_data->fsl_diu_info[index-1]->par;
526 upper_aoi_height =
527 machine_data->fsl_diu_info[index-1]->var.yres;
528 upper_aoi_bottom = upper_aoi_mfbi->y_aoi_d + upper_aoi_height;
529 upper_aoi_is_open = upper_aoi_mfbi->count > 0 ? 1 : 0;
530 if (var->xres > base_plane_width)
531 var->xres = base_plane_width;
532 if ((mfbi->x_aoi_d + var->xres) > base_plane_width)
533 mfbi->x_aoi_d = base_plane_width - var->xres;
534 if (mfbi->y_aoi_d < 0)
535 mfbi->y_aoi_d = 0;
536 if (upper_aoi_is_open) {
537 if (mfbi->y_aoi_d < upper_aoi_bottom)
538 mfbi->y_aoi_d = upper_aoi_bottom;
539 available_height = base_plane_height
540 - upper_aoi_bottom;
541 } else
542 available_height = base_plane_height;
543 if (var->yres > available_height)
544 var->yres = available_height;
545 if ((mfbi->y_aoi_d + var->yres) > base_plane_height)
546 mfbi->y_aoi_d = base_plane_height - var->yres;
547 break;
548 }
549}
550/*
551 * Checks to see if the hardware supports the state requested by var passed
552 * in. This function does not alter the hardware state! If the var passed in
553 * is slightly off by what the hardware can support then we alter the var
554 * PASSED in to what we can do. If the hardware doesn't support mode change
555 * a -EINVAL will be returned by the upper layers.
556 */
557static int fsl_diu_check_var(struct fb_var_screeninfo *var,
558 struct fb_info *info)
559{
560 unsigned long htotal, vtotal;
561
562 pr_debug("check_var xres: %d\n", var->xres);
563 pr_debug("check_var yres: %d\n", var->yres);
564
565 if (var->xres_virtual < var->xres)
566 var->xres_virtual = var->xres;
567 if (var->yres_virtual < var->yres)
568 var->yres_virtual = var->yres;
569
570 if (var->xoffset < 0)
571 var->xoffset = 0;
572
573 if (var->yoffset < 0)
574 var->yoffset = 0;
575
576 if (var->xoffset + info->var.xres > info->var.xres_virtual)
577 var->xoffset = info->var.xres_virtual - info->var.xres;
578
579 if (var->yoffset + info->var.yres > info->var.yres_virtual)
580 var->yoffset = info->var.yres_virtual - info->var.yres;
581
582 if ((var->bits_per_pixel != 32) && (var->bits_per_pixel != 24) &&
583 (var->bits_per_pixel != 16))
584 var->bits_per_pixel = default_bpp;
585
586 switch (var->bits_per_pixel) {
587 case 16:
588 var->red.length = 5;
589 var->red.offset = 11;
590 var->red.msb_right = 0;
591
592 var->green.length = 6;
593 var->green.offset = 5;
594 var->green.msb_right = 0;
595
596 var->blue.length = 5;
597 var->blue.offset = 0;
598 var->blue.msb_right = 0;
599
600 var->transp.length = 0;
601 var->transp.offset = 0;
602 var->transp.msb_right = 0;
603 break;
604 case 24:
605 var->red.length = 8;
606 var->red.offset = 0;
607 var->red.msb_right = 0;
608
609 var->green.length = 8;
610 var->green.offset = 8;
611 var->green.msb_right = 0;
612
613 var->blue.length = 8;
614 var->blue.offset = 16;
615 var->blue.msb_right = 0;
616
617 var->transp.length = 0;
618 var->transp.offset = 0;
619 var->transp.msb_right = 0;
620 break;
621 case 32:
622 var->red.length = 8;
623 var->red.offset = 16;
624 var->red.msb_right = 0;
625
626 var->green.length = 8;
627 var->green.offset = 8;
628 var->green.msb_right = 0;
629
630 var->blue.length = 8;
631 var->blue.offset = 0;
632 var->blue.msb_right = 0;
633
634 var->transp.length = 8;
635 var->transp.offset = 24;
636 var->transp.msb_right = 0;
637
638 break;
639 }
640 /* If the pixclock is below the minimum spec'd value then set to
641 * refresh rate for 60Hz since this is supported by most monitors.
642 * Refer to Documentation/fb/ for calculations.
643 */
644 if ((var->pixclock < MIN_PIX_CLK) || (var->pixclock > MAX_PIX_CLK)) {
645 htotal = var->xres + var->right_margin + var->hsync_len +
646 var->left_margin;
647 vtotal = var->yres + var->lower_margin + var->vsync_len +
648 var->upper_margin;
649 var->pixclock = (vtotal * htotal * 6UL) / 100UL;
650 var->pixclock = KHZ2PICOS(var->pixclock);
651 pr_debug("pixclock set for 60Hz refresh = %u ps\n",
652 var->pixclock);
653 }
654
655 var->height = -1;
656 var->width = -1;
657 var->grayscale = 0;
658
659 /* Copy nonstd field to/from sync for fbset usage */
660 var->sync |= var->nonstd;
661 var->nonstd |= var->sync;
662
663 adjust_aoi_size_position(var, info);
664 return 0;
665}
666
667static void set_fix(struct fb_info *info)
668{
669 struct fb_fix_screeninfo *fix = &info->fix;
670 struct fb_var_screeninfo *var = &info->var;
671 struct mfb_info *mfbi = info->par;
672
673 strncpy(fix->id, mfbi->id, strlen(mfbi->id));
674 fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
675 fix->type = FB_TYPE_PACKED_PIXELS;
676 fix->accel = FB_ACCEL_NONE;
677 fix->visual = FB_VISUAL_TRUECOLOR;
678 fix->xpanstep = 1;
679 fix->ypanstep = 1;
680}
681
682static void update_lcdc(struct fb_info *info)
683{
684 struct fb_var_screeninfo *var = &info->var;
685 struct mfb_info *mfbi = info->par;
686 struct fsl_diu_data *machine_data = mfbi->parent;
687 struct diu *hw;
688 int i, j;
689 char __iomem *cursor_base, *gamma_table_base;
690
691 u32 temp;
692
693 hw = dr.diu_reg;
694
695 if (mfbi->type == MFB_TYPE_OFF) {
696 fsl_diu_disable_panel(info);
697 return;
698 }
699
700 diu_ops.set_monitor_port(machine_data->monitor_port);
701 gamma_table_base = pool.gamma.vaddr;
702 cursor_base = pool.cursor.vaddr;
703 /* Prep for DIU init - gamma table, cursor table */
704
705 for (i = 0; i <= 2; i++)
706 for (j = 0; j <= 255; j++)
707 *gamma_table_base++ = j;
708
709 diu_ops.set_gamma_table(machine_data->monitor_port, pool.gamma.vaddr);
710
711 pr_debug("update-lcdc: HW - %p\n Disabling DIU\n", hw);
712 disable_lcdc(info);
713
714 /* Program DIU registers */
715
716 out_be32(&hw->gamma, pool.gamma.paddr);
717 out_be32(&hw->cursor, pool.cursor.paddr);
718
719 out_be32(&hw->bgnd, 0x007F7F7F); /* BGND */
720 out_be32(&hw->bgnd_wb, 0); /* BGND_WB */
721 out_be32(&hw->disp_size, (var->yres << 16 | var->xres));
722 /* DISP SIZE */
723 pr_debug("DIU xres: %d\n", var->xres);
724 pr_debug("DIU yres: %d\n", var->yres);
725
726 out_be32(&hw->wb_size, 0); /* WB SIZE */
727 out_be32(&hw->wb_mem_addr, 0); /* WB MEM ADDR */
728
729 /* Horizontal and vertical configuration register */
730 temp = var->left_margin << 22 | /* BP_H */
731 var->hsync_len << 11 | /* PW_H */
732 var->right_margin; /* FP_H */
733
734 out_be32(&hw->hsyn_para, temp);
735
736 temp = var->upper_margin << 22 | /* BP_V */
737 var->vsync_len << 11 | /* PW_V */
738 var->lower_margin; /* FP_V */
739
740 out_be32(&hw->vsyn_para, temp);
741
742 pr_debug("DIU right_margin - %d\n", var->right_margin);
743 pr_debug("DIU left_margin - %d\n", var->left_margin);
744 pr_debug("DIU hsync_len - %d\n", var->hsync_len);
745 pr_debug("DIU upper_margin - %d\n", var->upper_margin);
746 pr_debug("DIU lower_margin - %d\n", var->lower_margin);
747 pr_debug("DIU vsync_len - %d\n", var->vsync_len);
748 pr_debug("DIU HSYNC - 0x%08x\n", hw->hsyn_para);
749 pr_debug("DIU VSYNC - 0x%08x\n", hw->vsyn_para);
750
751 diu_ops.set_pixel_clock(var->pixclock);
752
753 out_be32(&hw->syn_pol, 0); /* SYNC SIGNALS POLARITY */
754 out_be32(&hw->thresholds, 0x00037800); /* The Thresholds */
755 out_be32(&hw->int_status, 0); /* INTERRUPT STATUS */
756 out_be32(&hw->plut, 0x01F5F666);
757
758 /* Enable the DIU */
759 enable_lcdc(info);
760}
761
762static int map_video_memory(struct fb_info *info)
763{
764 phys_addr_t phys;
765
766 pr_debug("info->var.xres_virtual = %d\n", info->var.xres_virtual);
767 pr_debug("info->var.yres_virtual = %d\n", info->var.yres_virtual);
768 pr_debug("info->fix.line_length = %d\n", info->fix.line_length);
769
770 info->fix.smem_len = info->fix.line_length * info->var.yres_virtual;
771 pr_debug("MAP_VIDEO_MEMORY: smem_len = %d\n", info->fix.smem_len);
772 info->screen_base = fsl_diu_alloc(info->fix.smem_len, &phys);
773 if (info->screen_base == 0) {
774 printk(KERN_ERR "Unable to allocate fb memory\n");
775 return -ENOMEM;
776 }
777 info->fix.smem_start = (unsigned long) phys;
778 info->screen_size = info->fix.smem_len;
779
780 pr_debug("Allocated fb @ paddr=0x%08lx, size=%d.\n",
781 info->fix.smem_start,
782 info->fix.smem_len);
783 pr_debug("screen base %p\n", info->screen_base);
784
785 return 0;
786}
787
788static void unmap_video_memory(struct fb_info *info)
789{
790 fsl_diu_free(info->screen_base, info->fix.smem_len);
791 info->screen_base = 0;
792 info->fix.smem_start = 0;
793 info->fix.smem_len = 0;
794}
795
796/*
797 * Using the fb_var_screeninfo in fb_info we set the resolution of this
798 * particular framebuffer. This function alters the fb_fix_screeninfo stored
799 * in fb_info. It does not alter var in fb_info since we are using that
800 * data. This means we depend on the data in var inside fb_info to be
801 * supported by the hardware. fsl_diu_check_var is always called before
802 * fsl_diu_set_par to ensure this.
803 */
804static int fsl_diu_set_par(struct fb_info *info)
805{
806 unsigned long len;
807 struct fb_var_screeninfo *var = &info->var;
808 struct mfb_info *mfbi = info->par;
809 struct fsl_diu_data *machine_data = mfbi->parent;
810 struct diu_ad *ad = mfbi->ad;
811 struct diu *hw;
812
813 hw = dr.diu_reg;
814
815 set_fix(info);
816 mfbi->cursor_reset = 1;
817
818 len = info->var.yres_virtual * info->fix.line_length;
819 /* Alloc & dealloc each time resolution/bpp change */
820 if (len != info->fix.smem_len) {
821 if (info->fix.smem_start)
822 unmap_video_memory(info);
823 pr_debug("SET PAR: smem_len = %d\n", info->fix.smem_len);
824
825 /* Memory allocation for framebuffer */
826 if (map_video_memory(info)) {
827 printk(KERN_ERR "Unable to allocate fb memory 1\n");
828 return -ENOMEM;
829 }
830 }
831
832 ad->pix_fmt =
833 diu_ops.get_pixel_format(var->bits_per_pixel,
834 machine_data->monitor_port);
835 ad->addr = cpu_to_le32(info->fix.smem_start);
836 ad->src_size_g_alpha = cpu_to_le32((var->yres << 12) |
837 var->xres) | mfbi->g_alpha;
838 /* fix me. AOI should not be greater than display size */
839 ad->aoi_size = cpu_to_le32((var->yres << 16) | var->xres);
840 ad->offset_xyi = 0;
841 ad->offset_xyd = cpu_to_le32((mfbi->y_aoi_d << 16) | mfbi->x_aoi_d);
842
843 /* Disable chroma keying function */
844 ad->ckmax_r = 0;
845 ad->ckmax_g = 0;
846 ad->ckmax_b = 0;
847
848 ad->ckmin_r = 255;
849 ad->ckmin_g = 255;
850 ad->ckmin_b = 255;
851
852 if (mfbi->index == 0)
853 update_lcdc(info);
854 return 0;
855}
856
857static inline __u32 CNVT_TOHW(__u32 val, __u32 width)
858{
859 return ((val<<width) + 0x7FFF - val)>>16;
860}
861
862/*
863 * Set a single color register. The values supplied have a 16 bit magnitude
864 * which needs to be scaled in this function for the hardware. Things to take
865 * into consideration are how many color registers, if any, are supported with
866 * the current color visual. With truecolor mode no color palettes are
867 * supported. Here a psuedo palette is created which we store the value in
868 * pseudo_palette in struct fb_info. For pseudocolor mode we have a limited
869 * color palette.
870 */
871static int fsl_diu_setcolreg(unsigned regno, unsigned red, unsigned green,
872 unsigned blue, unsigned transp, struct fb_info *info)
873{
874 int ret = 1;
875
876 /*
877 * If greyscale is true, then we convert the RGB value
878 * to greyscale no matter what visual we are using.
879 */
880 if (info->var.grayscale)
881 red = green = blue = (19595 * red + 38470 * green +
882 7471 * blue) >> 16;
883 switch (info->fix.visual) {
884 case FB_VISUAL_TRUECOLOR:
885 /*
886 * 16-bit True Colour. We encode the RGB value
887 * according to the RGB bitfield information.
888 */
889 if (regno < 16) {
890 u32 *pal = info->pseudo_palette;
891 u32 v;
892
893 red = CNVT_TOHW(red, info->var.red.length);
894 green = CNVT_TOHW(green, info->var.green.length);
895 blue = CNVT_TOHW(blue, info->var.blue.length);
896 transp = CNVT_TOHW(transp, info->var.transp.length);
897
898 v = (red << info->var.red.offset) |
899 (green << info->var.green.offset) |
900 (blue << info->var.blue.offset) |
901 (transp << info->var.transp.offset);
902
903 pal[regno] = v;
904 ret = 0;
905 }
906 break;
907 case FB_VISUAL_STATIC_PSEUDOCOLOR:
908 case FB_VISUAL_PSEUDOCOLOR:
909 break;
910 }
911
912 return ret;
913}
914
915/*
916 * Pan (or wrap, depending on the `vmode' field) the display using the
917 * 'xoffset' and 'yoffset' fields of the 'var' structure. If the values
918 * don't fit, return -EINVAL.
919 */
920static int fsl_diu_pan_display(struct fb_var_screeninfo *var,
921 struct fb_info *info)
922{
923 if ((info->var.xoffset == var->xoffset) &&
924 (info->var.yoffset == var->yoffset))
925 return 0; /* No change, do nothing */
926
927 if (var->xoffset < 0 || var->yoffset < 0
928 || var->xoffset + info->var.xres > info->var.xres_virtual
929 || var->yoffset + info->var.yres > info->var.yres_virtual)
930 return -EINVAL;
931
932 info->var.xoffset = var->xoffset;
933 info->var.yoffset = var->yoffset;
934
935 if (var->vmode & FB_VMODE_YWRAP)
936 info->var.vmode |= FB_VMODE_YWRAP;
937 else
938 info->var.vmode &= ~FB_VMODE_YWRAP;
939
940 return 0;
941}
942
943/*
944 * Blank the screen if blank_mode != 0, else unblank. Return 0 if blanking
945 * succeeded, != 0 if un-/blanking failed.
946 * blank_mode == 2: suspend vsync
947 * blank_mode == 3: suspend hsync
948 * blank_mode == 4: powerdown
949 */
950static int fsl_diu_blank(int blank_mode, struct fb_info *info)
951{
952 struct mfb_info *mfbi = info->par;
953
954 mfbi->blank = blank_mode;
955
956 switch (blank_mode) {
957 case FB_BLANK_VSYNC_SUSPEND:
958 case FB_BLANK_HSYNC_SUSPEND:
959 /* FIXME: fixes to enable_panel and enable lcdc needed */
960 case FB_BLANK_NORMAL:
961 /* fsl_diu_disable_panel(info);*/
962 break;
963 case FB_BLANK_POWERDOWN:
964 /* disable_lcdc(info); */
965 break;
966 case FB_BLANK_UNBLANK:
967 /* fsl_diu_enable_panel(info);*/
968 break;
969 }
970
971 return 0;
972}
973
974static int fsl_diu_ioctl(struct fb_info *info, unsigned int cmd,
975 unsigned long arg)
976{
977 struct mfb_info *mfbi = info->par;
978 struct diu_ad *ad = mfbi->ad;
979 struct mfb_chroma_key ck;
980 unsigned char global_alpha;
981 struct aoi_display_offset aoi_d;
982 __u32 pix_fmt;
983 void __user *buf = (void __user *)arg;
984
985 if (!arg)
986 return -EINVAL;
987 switch (cmd) {
988 case MFB_SET_PIXFMT:
989 if (copy_from_user(&pix_fmt, buf, sizeof(pix_fmt)))
990 return -EFAULT;
991 ad->pix_fmt = pix_fmt;
992 pr_debug("Set pixel format to 0x%08x\n", ad->pix_fmt);
993 break;
994 case MFB_GET_PIXFMT:
995 pix_fmt = ad->pix_fmt;
996 if (copy_to_user(buf, &pix_fmt, sizeof(pix_fmt)))
997 return -EFAULT;
998 pr_debug("get pixel format 0x%08x\n", ad->pix_fmt);
999 break;
1000 case MFB_SET_AOID:
1001 if (copy_from_user(&aoi_d, buf, sizeof(aoi_d)))
1002 return -EFAULT;
1003 mfbi->x_aoi_d = aoi_d.x_aoi_d;
1004 mfbi->y_aoi_d = aoi_d.y_aoi_d;
1005 pr_debug("set AOI display offset of index %d to (%d,%d)\n",
1006 mfbi->index, aoi_d.x_aoi_d, aoi_d.y_aoi_d);
1007 fsl_diu_check_var(&info->var, info);
1008 fsl_diu_set_par(info);
1009 break;
1010 case MFB_GET_AOID:
1011 aoi_d.x_aoi_d = mfbi->x_aoi_d;
1012 aoi_d.y_aoi_d = mfbi->y_aoi_d;
1013 if (copy_to_user(buf, &aoi_d, sizeof(aoi_d)))
1014 return -EFAULT;
1015 pr_debug("get AOI display offset of index %d (%d,%d)\n",
1016 mfbi->index, aoi_d.x_aoi_d, aoi_d.y_aoi_d);
1017 break;
1018 case MFB_GET_ALPHA:
1019 global_alpha = mfbi->g_alpha;
1020 if (copy_to_user(buf, &global_alpha, sizeof(global_alpha)))
1021 return -EFAULT;
1022 pr_debug("get global alpha of index %d\n", mfbi->index);
1023 break;
1024 case MFB_SET_ALPHA:
1025 /* set panel information */
1026 if (copy_from_user(&global_alpha, buf, sizeof(global_alpha)))
1027 return -EFAULT;
1028 ad->src_size_g_alpha = (ad->src_size_g_alpha & (~0xff)) |
1029 (global_alpha & 0xff);
1030 mfbi->g_alpha = global_alpha;
1031 pr_debug("set global alpha for index %d\n", mfbi->index);
1032 break;
1033 case MFB_SET_CHROMA_KEY:
1034 /* set panel winformation */
1035 if (copy_from_user(&ck, buf, sizeof(ck)))
1036 return -EFAULT;
1037
1038 if (ck.enable &&
1039 (ck.red_max < ck.red_min ||
1040 ck.green_max < ck.green_min ||
1041 ck.blue_max < ck.blue_min))
1042 return -EINVAL;
1043
1044 if (!ck.enable) {
1045 ad->ckmax_r = 0;
1046 ad->ckmax_g = 0;
1047 ad->ckmax_b = 0;
1048 ad->ckmin_r = 255;
1049 ad->ckmin_g = 255;
1050 ad->ckmin_b = 255;
1051 } else {
1052 ad->ckmax_r = ck.red_max;
1053 ad->ckmax_g = ck.green_max;
1054 ad->ckmax_b = ck.blue_max;
1055 ad->ckmin_r = ck.red_min;
1056 ad->ckmin_g = ck.green_min;
1057 ad->ckmin_b = ck.blue_min;
1058 }
1059 pr_debug("set chroma key\n");
1060 break;
1061 case FBIOGET_GWINFO:
1062 if (mfbi->type == MFB_TYPE_OFF)
1063 return -ENODEV;
1064 /* get graphic window information */
1065 if (copy_to_user(buf, ad, sizeof(*ad)))
1066 return -EFAULT;
1067 break;
1068 case FBIOGET_HWCINFO:
1069 pr_debug("FBIOGET_HWCINFO:0x%08x\n", FBIOGET_HWCINFO);
1070 break;
1071 case FBIOPUT_MODEINFO:
1072 pr_debug("FBIOPUT_MODEINFO:0x%08x\n", FBIOPUT_MODEINFO);
1073 break;
1074 case FBIOGET_DISPINFO:
1075 pr_debug("FBIOGET_DISPINFO:0x%08x\n", FBIOGET_DISPINFO);
1076 break;
1077
1078 default:
1079 printk(KERN_ERR "Unknown ioctl command (0x%08X)\n", cmd);
1080 return -ENOIOCTLCMD;
1081 }
1082
1083 return 0;
1084}
1085
1086/* turn on fb if count == 1
1087 */
1088static int fsl_diu_open(struct fb_info *info, int user)
1089{
1090 struct mfb_info *mfbi = info->par;
1091 int res = 0;
1092
1093 spin_lock(&diu_lock);
1094 mfbi->count++;
1095 if (mfbi->count == 1) {
1096 pr_debug("open plane index %d\n", mfbi->index);
1097 fsl_diu_check_var(&info->var, info);
1098 res = fsl_diu_set_par(info);
1099 if (res < 0)
1100 mfbi->count--;
1101 else {
1102 res = fsl_diu_enable_panel(info);
1103 if (res < 0)
1104 mfbi->count--;
1105 }
1106 }
1107
1108 spin_unlock(&diu_lock);
1109 return res;
1110}
1111
1112/* turn off fb if count == 0
1113 */
1114static int fsl_diu_release(struct fb_info *info, int user)
1115{
1116 struct mfb_info *mfbi = info->par;
1117 int res = 0;
1118
1119 spin_lock(&diu_lock);
1120 mfbi->count--;
1121 if (mfbi->count == 0) {
1122 pr_debug("release plane index %d\n", mfbi->index);
1123 res = fsl_diu_disable_panel(info);
1124 if (res < 0)
1125 mfbi->count++;
1126 }
1127 spin_unlock(&diu_lock);
1128 return res;
1129}
1130
1131static struct fb_ops fsl_diu_ops = {
1132 .owner = THIS_MODULE,
1133 .fb_check_var = fsl_diu_check_var,
1134 .fb_set_par = fsl_diu_set_par,
1135 .fb_setcolreg = fsl_diu_setcolreg,
1136 .fb_blank = fsl_diu_blank,
1137 .fb_pan_display = fsl_diu_pan_display,
1138 .fb_fillrect = cfb_fillrect,
1139 .fb_copyarea = cfb_copyarea,
1140 .fb_imageblit = cfb_imageblit,
1141 .fb_ioctl = fsl_diu_ioctl,
1142 .fb_open = fsl_diu_open,
1143 .fb_release = fsl_diu_release,
1144};
1145
1146static int init_fbinfo(struct fb_info *info)
1147{
1148 struct mfb_info *mfbi = info->par;
1149
1150 info->device = NULL;
1151 info->var.activate = FB_ACTIVATE_NOW;
1152 info->fbops = &fsl_diu_ops;
1153 info->flags = FBINFO_FLAG_DEFAULT;
1154 info->pseudo_palette = &mfbi->pseudo_palette;
1155
1156 /* Allocate colormap */
1157 fb_alloc_cmap(&info->cmap, 16, 0);
1158 return 0;
1159}
1160
1161static int install_fb(struct fb_info *info)
1162{
1163 int rc;
1164 struct mfb_info *mfbi = info->par;
1165 const char *aoi_mode, *init_aoi_mode = "320x240";
1166
1167 if (init_fbinfo(info))
1168 return -EINVAL;
1169
1170 if (mfbi->index == 0) /* plane 0 */
1171 aoi_mode = fb_mode;
1172 else
1173 aoi_mode = init_aoi_mode;
1174 pr_debug("mode used = %s\n", aoi_mode);
1175 rc = fb_find_mode(&info->var, info, aoi_mode, fsl_diu_mode_db,
1176 ARRAY_SIZE(fsl_diu_mode_db), &fsl_diu_default_mode, default_bpp);
1177
1178 switch (rc) {
1179 case 1:
1180 pr_debug("using mode specified in @mode\n");
1181 break;
1182 case 2:
1183 pr_debug("using mode specified in @mode "
1184 "with ignored refresh rate\n");
1185 break;
1186 case 3:
1187 pr_debug("using mode default mode\n");
1188 break;
1189 case 4:
1190 pr_debug("using mode from list\n");
1191 break;
1192 default:
1193 pr_debug("rc = %d\n", rc);
1194 pr_debug("failed to find mode\n");
1195 return -EINVAL;
1196 break;
1197 }
1198
1199 pr_debug("xres_virtual %d\n", info->var.xres_virtual);
1200 pr_debug("bits_per_pixel %d\n", info->var.bits_per_pixel);
1201
1202 pr_debug("info->var.yres_virtual = %d\n", info->var.yres_virtual);
1203 pr_debug("info->fix.line_length = %d\n", info->fix.line_length);
1204
1205 if (mfbi->type == MFB_TYPE_OFF)
1206 mfbi->blank = FB_BLANK_NORMAL;
1207 else
1208 mfbi->blank = FB_BLANK_UNBLANK;
1209
1210 if (fsl_diu_check_var(&info->var, info)) {
1211 printk(KERN_ERR "fb_check_var failed");
1212 fb_dealloc_cmap(&info->cmap);
1213 return -EINVAL;
1214 }
1215
1216 if (fsl_diu_set_par(info)) {
1217 printk(KERN_ERR "fb_set_par failed");
1218 fb_dealloc_cmap(&info->cmap);
1219 return -EINVAL;
1220 }
1221
1222 if (register_framebuffer(info) < 0) {
1223 printk(KERN_ERR "register_framebuffer failed");
1224 unmap_video_memory(info);
1225 fb_dealloc_cmap(&info->cmap);
1226 return -EINVAL;
1227 }
1228
1229 mfbi->registered = 1;
1230 printk(KERN_INFO "fb%d: %s fb device registered successfully.\n",
1231 info->node, info->fix.id);
1232
1233 return 0;
1234}
1235
1236static void __exit uninstall_fb(struct fb_info *info)
1237{
1238 struct mfb_info *mfbi = info->par;
1239
1240 if (!mfbi->registered)
1241 return;
1242
1243 unregister_framebuffer(info);
1244 unmap_video_memory(info);
1245 if (&info->cmap)
1246 fb_dealloc_cmap(&info->cmap);
1247
1248 mfbi->registered = 0;
1249}
1250
1251static irqreturn_t fsl_diu_isr(int irq, void *dev_id)
1252{
1253 struct diu *hw = dr.diu_reg;
1254 unsigned int status = in_be32(&hw->int_status);
1255
1256 if (status) {
1257 /* This is the workaround for underrun */
1258 if (status & INT_UNDRUN) {
1259 out_be32(&hw->diu_mode, 0);
1260 pr_debug("Err: DIU occurs underrun!\n");
1261 udelay(1);
1262 out_be32(&hw->diu_mode, 1);
1263 }
1264#if defined(CONFIG_NOT_COHERENT_CACHE)
1265 else if (status & INT_VSYNC) {
1266 unsigned int i;
1267 for (i = 0; i < coherence_data_size;
1268 i += d_cache_line_size)
1269 __asm__ __volatile__ (
1270 "dcbz 0, %[input]"
1271 ::[input]"r"(&coherence_data[i]));
1272 }
1273#endif
1274 return IRQ_HANDLED;
1275 }
1276 return IRQ_NONE;
1277}
1278
1279static int request_irq_local(int irq)
1280{
1281 unsigned long status, ints;
1282 struct diu *hw;
1283 int ret;
1284
1285 hw = dr.diu_reg;
1286
1287 /* Read to clear the status */
1288 status = in_be32(&hw->int_status);
1289
1290 ret = request_irq(irq, fsl_diu_isr, 0, "diu", 0);
1291 if (ret)
1292 pr_info("Request diu IRQ failed.\n");
1293 else {
1294 ints = INT_PARERR | INT_LS_BF_VS;
1295#if !defined(CONFIG_NOT_COHERENT_CACHE)
1296 ints |= INT_VSYNC;
1297#endif
1298 if (dr.mode == MFB_MODE2 || dr.mode == MFB_MODE3)
1299 ints |= INT_VSYNC_WB;
1300
1301 /* Read to clear the status */
1302 status = in_be32(&hw->int_status);
1303 out_be32(&hw->int_mask, ints);
1304 }
1305 return ret;
1306}
1307
1308static void free_irq_local(int irq)
1309{
1310 struct diu *hw = dr.diu_reg;
1311
1312 /* Disable all LCDC interrupt */
1313 out_be32(&hw->int_mask, 0x1f);
1314
1315 free_irq(irq, 0);
1316}
1317
1318#ifdef CONFIG_PM
1319/*
1320 * Power management hooks. Note that we won't be called from IRQ context,
1321 * unlike the blank functions above, so we may sleep.
1322 */
1323static int fsl_diu_suspend(struct of_device *dev, pm_message_t state)
1324{
1325 struct fsl_diu_data *machine_data;
1326
1327 machine_data = dev_get_drvdata(&ofdev->dev);
1328 disable_lcdc(machine_data->fsl_diu_info[0]);
1329
1330 return 0;
1331}
1332
1333static int fsl_diu_resume(struct of_device *dev)
1334{
1335 struct fsl_diu_data *machine_data;
1336
1337 machine_data = dev_get_drvdata(&ofdev->dev);
1338 enable_lcdc(machine_data->fsl_diu_info[0]);
1339
1340 return 0;
1341}
1342
1343#else
1344#define fsl_diu_suspend NULL
1345#define fsl_diu_resume NULL
1346#endif /* CONFIG_PM */
1347
1348/* Align to 64-bit(8-byte), 32-byte, etc. */
1349static int allocate_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
1350{
1351 u32 offset, ssize;
1352 u32 mask;
1353 dma_addr_t paddr = 0;
1354
1355 ssize = size + bytes_align;
1356 buf->vaddr = dma_alloc_coherent(0, ssize, &paddr, GFP_DMA | __GFP_ZERO);
1357 if (!buf->vaddr)
1358 return -ENOMEM;
1359
1360 buf->paddr = (__u32) paddr;
1361
1362 mask = bytes_align - 1;
1363 offset = (u32)buf->paddr & mask;
1364 if (offset) {
1365 buf->offset = bytes_align - offset;
1366 buf->paddr = (u32)buf->paddr + offset;
1367 } else
1368 buf->offset = 0;
1369 return 0;
1370}
1371
1372static void free_buf(struct diu_addr *buf, u32 size, u32 bytes_align)
1373{
1374 dma_free_coherent(0, size + bytes_align,
1375 buf->vaddr, (buf->paddr - buf->offset));
1376 return;
1377}
1378
1379static ssize_t store_monitor(struct device *device,
1380 struct device_attribute *attr, const char *buf, size_t count)
1381{
1382 int old_monitor_port;
1383 unsigned long val;
1384 struct fsl_diu_data *machine_data =
1385 container_of(attr, struct fsl_diu_data, dev_attr);
1386
1387 if (strict_strtoul(buf, 10, &val))
1388 return 0;
1389
1390 old_monitor_port = machine_data->monitor_port;
1391 machine_data->monitor_port = diu_ops.set_sysfs_monitor_port(val);
1392
1393 if (old_monitor_port != machine_data->monitor_port) {
1394 /* All AOIs need adjust pixel format
1395 * fsl_diu_set_par only change the pixsel format here
1396 * unlikely to fail. */
1397 fsl_diu_set_par(machine_data->fsl_diu_info[0]);
1398 fsl_diu_set_par(machine_data->fsl_diu_info[1]);
1399 fsl_diu_set_par(machine_data->fsl_diu_info[2]);
1400 fsl_diu_set_par(machine_data->fsl_diu_info[3]);
1401 fsl_diu_set_par(machine_data->fsl_diu_info[4]);
1402 }
1403 return count;
1404}
1405
1406static ssize_t show_monitor(struct device *device,
1407 struct device_attribute *attr, char *buf)
1408{
1409 struct fsl_diu_data *machine_data =
1410 container_of(attr, struct fsl_diu_data, dev_attr);
1411 return diu_ops.show_monitor_port(machine_data->monitor_port, buf);
1412}
1413
1414static int fsl_diu_probe(struct of_device *ofdev,
1415 const struct of_device_id *match)
1416{
1417 struct device_node *np = ofdev->node;
1418 struct mfb_info *mfbi;
1419 phys_addr_t dummy_ad_addr;
1420 int ret, i, error = 0;
1421 struct resource res;
1422 struct fsl_diu_data *machine_data;
1423
1424 machine_data = kzalloc(sizeof(struct fsl_diu_data), GFP_KERNEL);
1425 if (!machine_data)
1426 return -ENOMEM;
1427
1428 for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) {
1429 machine_data->fsl_diu_info[i] =
1430 framebuffer_alloc(sizeof(struct mfb_info), &ofdev->dev);
1431 if (!machine_data->fsl_diu_info[i]) {
1432 dev_err(&ofdev->dev, "cannot allocate memory\n");
1433 ret = -ENOMEM;
1434 goto error2;
1435 }
1436 mfbi = machine_data->fsl_diu_info[i]->par;
1437 memcpy(mfbi, &mfb_template[i], sizeof(struct mfb_info));
1438 mfbi->parent = machine_data;
1439 }
1440
1441 ret = of_address_to_resource(np, 0, &res);
1442 if (ret) {
1443 dev_err(&ofdev->dev, "could not obtain DIU address\n");
1444 goto error;
1445 }
1446 if (!res.start) {
1447 dev_err(&ofdev->dev, "invalid DIU address\n");
1448 goto error;
1449 }
1450 dev_dbg(&ofdev->dev, "%s, res.start: 0x%08x\n", __func__, res.start);
1451
1452 dr.diu_reg = ioremap(res.start, sizeof(struct diu));
1453 if (!dr.diu_reg) {
1454 dev_err(&ofdev->dev, "Err: can't map DIU registers!\n");
1455 ret = -EFAULT;
1456 goto error2;
1457 }
1458
1459 out_be32(&dr.diu_reg->diu_mode, 0); /* disable DIU anyway*/
1460
1461 /* Get the IRQ of the DIU */
1462 machine_data->irq = irq_of_parse_and_map(np, 0);
1463
1464 if (!machine_data->irq) {
1465 dev_err(&ofdev->dev, "could not get DIU IRQ\n");
1466 ret = -EINVAL;
1467 goto error;
1468 }
1469 machine_data->monitor_port = monitor_port;
1470
1471 /* Area descriptor memory pool aligns to 64-bit boundary */
1472 if (allocate_buf(&pool.ad, sizeof(struct diu_ad) * FSL_AOI_NUM, 8))
1473 return -ENOMEM;
1474
1475 /* Get memory for Gamma Table - 32-byte aligned memory */
1476 if (allocate_buf(&pool.gamma, 768, 32)) {
1477 ret = -ENOMEM;
1478 goto error;
1479 }
1480
1481 /* For performance, cursor bitmap buffer aligns to 32-byte boundary */
1482 if (allocate_buf(&pool.cursor, MAX_CURS * MAX_CURS * 2, 32)) {
1483 ret = -ENOMEM;
1484 goto error;
1485 }
1486
1487 i = ARRAY_SIZE(machine_data->fsl_diu_info);
1488 machine_data->dummy_ad = (struct diu_ad *)
1489 ((u32)pool.ad.vaddr + pool.ad.offset) + i;
1490 machine_data->dummy_ad->paddr = pool.ad.paddr +
1491 i * sizeof(struct diu_ad);
1492 machine_data->dummy_aoi_virt = fsl_diu_alloc(64, &dummy_ad_addr);
1493 if (!machine_data->dummy_aoi_virt) {
1494 ret = -ENOMEM;
1495 goto error;
1496 }
1497 machine_data->dummy_ad->addr = cpu_to_le32(dummy_ad_addr);
1498 machine_data->dummy_ad->pix_fmt = 0x88882317;
1499 machine_data->dummy_ad->src_size_g_alpha = cpu_to_le32((4 << 12) | 4);
1500 machine_data->dummy_ad->aoi_size = cpu_to_le32((4 << 16) | 2);
1501 machine_data->dummy_ad->offset_xyi = 0;
1502 machine_data->dummy_ad->offset_xyd = 0;
1503 machine_data->dummy_ad->next_ad = 0;
1504
1505 out_be32(&dr.diu_reg->desc[0], machine_data->dummy_ad->paddr);
1506 out_be32(&dr.diu_reg->desc[1], machine_data->dummy_ad->paddr);
1507 out_be32(&dr.diu_reg->desc[2], machine_data->dummy_ad->paddr);
1508
1509 for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++) {
1510 machine_data->fsl_diu_info[i]->fix.smem_start = 0;
1511 mfbi = machine_data->fsl_diu_info[i]->par;
1512 mfbi->ad = (struct diu_ad *)((u32)pool.ad.vaddr
1513 + pool.ad.offset) + i;
1514 mfbi->ad->paddr = pool.ad.paddr + i * sizeof(struct diu_ad);
1515 ret = install_fb(machine_data->fsl_diu_info[i]);
1516 if (ret) {
1517 dev_err(&ofdev->dev,
1518 "Failed to register framebuffer %d\n",
1519 i);
1520 goto error;
1521 }
1522 }
1523
1524 if (request_irq_local(machine_data->irq)) {
1525 dev_err(machine_data->fsl_diu_info[0]->dev,
1526 "could not request irq for diu.");
1527 goto error;
1528 }
1529
1530 machine_data->dev_attr.attr.name = "monitor";
1531 machine_data->dev_attr.attr.mode = S_IRUGO|S_IWUSR;
1532 machine_data->dev_attr.show = show_monitor;
1533 machine_data->dev_attr.store = store_monitor;
1534 error = device_create_file(machine_data->fsl_diu_info[0]->dev,
1535 &machine_data->dev_attr);
1536 if (error) {
1537 dev_err(machine_data->fsl_diu_info[0]->dev,
1538 "could not create sysfs %s file\n",
1539 machine_data->dev_attr.attr.name);
1540 }
1541
1542 dev_set_drvdata(&ofdev->dev, machine_data);
1543 return 0;
1544
1545error:
1546 for (i = ARRAY_SIZE(machine_data->fsl_diu_info);
1547 i > 0; i--)
1548 uninstall_fb(machine_data->fsl_diu_info[i - 1]);
1549 if (pool.ad.vaddr)
1550 free_buf(&pool.ad, sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
1551 if (pool.gamma.vaddr)
1552 free_buf(&pool.gamma, 768, 32);
1553 if (pool.cursor.vaddr)
1554 free_buf(&pool.cursor, MAX_CURS * MAX_CURS * 2, 32);
1555 if (machine_data->dummy_aoi_virt)
1556 fsl_diu_free(machine_data->dummy_aoi_virt, 64);
1557 iounmap(dr.diu_reg);
1558
1559error2:
1560 for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++)
1561 if (machine_data->fsl_diu_info[i])
1562 framebuffer_release(machine_data->fsl_diu_info[i]);
1563 kfree(machine_data);
1564
1565 return ret;
1566}
1567
1568
1569static int fsl_diu_remove(struct of_device *ofdev)
1570{
1571 struct fsl_diu_data *machine_data;
1572 int i;
1573
1574 machine_data = dev_get_drvdata(&ofdev->dev);
1575 disable_lcdc(machine_data->fsl_diu_info[0]);
1576 free_irq_local(machine_data->irq);
1577 for (i = ARRAY_SIZE(machine_data->fsl_diu_info); i > 0; i--)
1578 uninstall_fb(machine_data->fsl_diu_info[i - 1]);
1579 if (pool.ad.vaddr)
1580 free_buf(&pool.ad, sizeof(struct diu_ad) * FSL_AOI_NUM, 8);
1581 if (pool.gamma.vaddr)
1582 free_buf(&pool.gamma, 768, 32);
1583 if (pool.cursor.vaddr)
1584 free_buf(&pool.cursor, MAX_CURS * MAX_CURS * 2, 32);
1585 if (machine_data->dummy_aoi_virt)
1586 fsl_diu_free(machine_data->dummy_aoi_virt, 64);
1587 iounmap(dr.diu_reg);
1588 for (i = 0; i < ARRAY_SIZE(machine_data->fsl_diu_info); i++)
1589 if (machine_data->fsl_diu_info[i])
1590 framebuffer_release(machine_data->fsl_diu_info[i]);
1591 kfree(machine_data);
1592
1593 return 0;
1594}
1595
1596#ifndef MODULE
1597static int __init fsl_diu_setup(char *options)
1598{
1599 char *opt;
1600 unsigned long val;
1601
1602 if (!options || !*options)
1603 return 0;
1604
1605 while ((opt = strsep(&options, ",")) != NULL) {
1606 if (!*opt)
1607 continue;
1608 if (!strncmp(opt, "monitor=", 8)) {
1609 if (!strict_strtoul(opt + 8, 10, &val) && (val <= 2))
1610 monitor_port = val;
1611 } else if (!strncmp(opt, "bpp=", 4)) {
1612 if (!strict_strtoul(opt + 4, 10, &val))
1613 default_bpp = val;
1614 } else
1615 fb_mode = opt;
1616 }
1617
1618 return 0;
1619}
1620#endif
1621
1622static struct of_device_id fsl_diu_match[] = {
1623 {
1624 .compatible = "fsl,diu",
1625 },
1626 {}
1627};
1628MODULE_DEVICE_TABLE(of, fsl_diu_match);
1629
1630static struct of_platform_driver fsl_diu_driver = {
1631 .owner = THIS_MODULE,
1632 .name = "fsl_diu",
1633 .match_table = fsl_diu_match,
1634 .probe = fsl_diu_probe,
1635 .remove = fsl_diu_remove,
1636 .suspend = fsl_diu_suspend,
1637 .resume = fsl_diu_resume,
1638};
1639
1640static int __init fsl_diu_init(void)
1641{
1642#ifdef CONFIG_NOT_COHERENT_CACHE
1643 struct device_node *np;
1644 const u32 *prop;
1645#endif
1646 int ret;
1647#ifndef MODULE
1648 char *option;
1649
1650 /*
1651 * For kernel boot options (in 'video=xxxfb:<options>' format)
1652 */
1653 if (fb_get_options("fslfb", &option))
1654 return -ENODEV;
1655 fsl_diu_setup(option);
1656#endif
1657 printk(KERN_INFO "Freescale DIU driver\n");
1658
1659#ifdef CONFIG_NOT_COHERENT_CACHE
1660 np = of_find_node_by_type(NULL, "cpu");
1661 if (!np) {
1662 printk(KERN_ERR "Err: can't find device node 'cpu'\n");
1663 return -ENODEV;
1664 }
1665
1666 prop = of_get_property(np, "d-cache-size", NULL);
1667 if (prop == NULL)
1668 return -ENODEV;
1669
1670 /* Freescale PLRU requires 13/8 times the cache size to do a proper
1671 displacement flush
1672 */
1673 coherence_data_size = *prop * 13;
1674 coherence_data_size /= 8;
1675
1676 prop = of_get_property(np, "d-cache-line-size", NULL);
1677 if (prop == NULL)
1678 return -ENODEV;
1679 d_cache_line_size = *prop;
1680
1681 of_node_put(np);
1682 coherence_data = vmalloc(coherence_data_size);
1683 if (!coherence_data)
1684 return -ENOMEM;
1685#endif
1686 ret = of_register_platform_driver(&fsl_diu_driver);
1687 if (ret) {
1688 printk(KERN_ERR
1689 "fsl-diu: failed to register platform driver\n");
1690#if defined(CONFIG_NOT_COHERENT_CACHE)
1691 vfree(coherence_data);
1692#endif
1693 iounmap(dr.diu_reg);
1694 }
1695 return ret;
1696}
1697
1698static void __exit fsl_diu_exit(void)
1699{
1700 of_unregister_platform_driver(&fsl_diu_driver);
1701#if defined(CONFIG_NOT_COHERENT_CACHE)
1702 vfree(coherence_data);
1703#endif
1704}
1705
1706module_init(fsl_diu_init);
1707module_exit(fsl_diu_exit);
1708
1709MODULE_AUTHOR("York Sun <yorksun@freescale.com>");
1710MODULE_DESCRIPTION("Freescale DIU framebuffer driver");
1711MODULE_LICENSE("GPL");
1712
1713module_param_named(mode, fb_mode, charp, 0);
1714MODULE_PARM_DESC(mode,
1715 "Specify resolution as \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
1716module_param_named(bpp, default_bpp, ulong, 0);
1717MODULE_PARM_DESC(bpp, "Specify bit-per-pixel if not specified mode");
1718module_param_named(monitor, monitor_port, int, 0);
1719MODULE_PARM_DESC(monitor,
1720 "Specify the monitor port (0, 1 or 2) if supported by the platform");
1721
diff --git a/drivers/video/fsl-diu-fb.h b/drivers/video/fsl-diu-fb.h
new file mode 100644
index 000000000000..fc295d7ea463
--- /dev/null
+++ b/drivers/video/fsl-diu-fb.h
@@ -0,0 +1,223 @@
1/*
2 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
3 *
4 * Freescale DIU Frame Buffer device driver
5 *
6 * Authors: Hongjun Chen <hong-jun.chen@freescale.com>
7 * Paul Widmer <paul.widmer@freescale.com>
8 * Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
9 * York Sun <yorksun@freescale.com>
10 *
11 * Based on imxfb.c Copyright (C) 2004 S.Hauer, Pengutronix
12 *
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
17 *
18 */
19
20#ifndef __FSL_DIU_FB_H__
21#define __FSL_DIU_FB_H__
22
23/* Arbitrary threshold to determine the allocation method
24 * See mpc8610fb_set_par(), map_video_memory(), and unmap_video_memory()
25 */
26#define MEM_ALLOC_THRESHOLD (1024*768*4+32)
27/* Minimum value that the pixel clock can be set to in pico seconds
28 * This is determined by platform clock/3 where the minimum platform
29 * clock is 533MHz. This gives 5629 pico seconds.
30 */
31#define MIN_PIX_CLK 5629
32#define MAX_PIX_CLK 96096
33
34#include <linux/types.h>
35
36struct mfb_alpha {
37 int enable;
38 int alpha;
39};
40
41struct mfb_chroma_key {
42 int enable;
43 __u8 red_max;
44 __u8 green_max;
45 __u8 blue_max;
46 __u8 red_min;
47 __u8 green_min;
48 __u8 blue_min;
49};
50
51struct aoi_display_offset {
52 int x_aoi_d;
53 int y_aoi_d;
54};
55
56#define MFB_SET_CHROMA_KEY _IOW('M', 1, struct mfb_chroma_key)
57#define MFB_WAIT_FOR_VSYNC _IOW('F', 0x20, u_int32_t)
58#define MFB_SET_BRIGHTNESS _IOW('M', 3, __u8)
59
60#define MFB_SET_ALPHA 0x80014d00
61#define MFB_GET_ALPHA 0x40014d00
62#define MFB_SET_AOID 0x80084d04
63#define MFB_GET_AOID 0x40084d04
64#define MFB_SET_PIXFMT 0x80014d08
65#define MFB_GET_PIXFMT 0x40014d08
66
67#define FBIOGET_GWINFO 0x46E0
68#define FBIOPUT_GWINFO 0x46E1
69
70#ifdef __KERNEL__
71#include <linux/spinlock.h>
72
73/*
74 * These are the fields of area descriptor(in DDR memory) for every plane
75 */
76struct diu_ad {
77 /* Word 0(32-bit) in DDR memory */
78/* __u16 comp; */
79/* __u16 pixel_s:2; */
80/* __u16 pallete:1; */
81/* __u16 red_c:2; */
82/* __u16 green_c:2; */
83/* __u16 blue_c:2; */
84/* __u16 alpha_c:3; */
85/* __u16 byte_f:1; */
86/* __u16 res0:3; */
87
88 __be32 pix_fmt; /* hard coding pixel format */
89
90 /* Word 1(32-bit) in DDR memory */
91 __le32 addr;
92
93 /* Word 2(32-bit) in DDR memory */
94/* __u32 delta_xs:11; */
95/* __u32 res1:1; */
96/* __u32 delta_ys:11; */
97/* __u32 res2:1; */
98/* __u32 g_alpha:8; */
99 __le32 src_size_g_alpha;
100
101 /* Word 3(32-bit) in DDR memory */
102/* __u32 delta_xi:11; */
103/* __u32 res3:5; */
104/* __u32 delta_yi:11; */
105/* __u32 res4:3; */
106/* __u32 flip:2; */
107 __le32 aoi_size;
108
109 /* Word 4(32-bit) in DDR memory */
110 /*__u32 offset_xi:11;
111 __u32 res5:5;
112 __u32 offset_yi:11;
113 __u32 res6:5;
114 */
115 __le32 offset_xyi;
116
117 /* Word 5(32-bit) in DDR memory */
118 /*__u32 offset_xd:11;
119 __u32 res7:5;
120 __u32 offset_yd:11;
121 __u32 res8:5; */
122 __le32 offset_xyd;
123
124
125 /* Word 6(32-bit) in DDR memory */
126 __u8 ckmax_r;
127 __u8 ckmax_g;
128 __u8 ckmax_b;
129 __u8 res9;
130
131 /* Word 7(32-bit) in DDR memory */
132 __u8 ckmin_r;
133 __u8 ckmin_g;
134 __u8 ckmin_b;
135 __u8 res10;
136/* __u32 res10:8; */
137
138 /* Word 8(32-bit) in DDR memory */
139 __le32 next_ad;
140
141 /* Word 9(32-bit) in DDR memory, just for 64-bit aligned */
142 __u32 paddr;
143} __attribute__ ((packed));
144
145/* DIU register map */
146struct diu {
147 __be32 desc[3];
148 __be32 gamma;
149 __be32 pallete;
150 __be32 cursor;
151 __be32 curs_pos;
152 __be32 diu_mode;
153 __be32 bgnd;
154 __be32 bgnd_wb;
155 __be32 disp_size;
156 __be32 wb_size;
157 __be32 wb_mem_addr;
158 __be32 hsyn_para;
159 __be32 vsyn_para;
160 __be32 syn_pol;
161 __be32 thresholds;
162 __be32 int_status;
163 __be32 int_mask;
164 __be32 colorbar[8];
165 __be32 filling;
166 __be32 plut;
167} __attribute__ ((packed));
168
169struct diu_hw {
170 struct diu *diu_reg;
171 spinlock_t reg_lock;
172
173 __u32 mode; /* DIU operation mode */
174};
175
176struct diu_addr {
177 __u8 __iomem *vaddr; /* Virtual address */
178 dma_addr_t paddr; /* Physical address */
179 __u32 offset;
180};
181
182struct diu_pool {
183 struct diu_addr ad;
184 struct diu_addr gamma;
185 struct diu_addr pallete;
186 struct diu_addr cursor;
187};
188
189#define FSL_DIU_BASE_OFFSET 0x2C000 /* Offset of DIU */
190#define INT_LCDC 64 /* DIU interrupt number */
191
192#define FSL_AOI_NUM 6 /* 5 AOIs and one dummy AOI */
193 /* 1 for plane 0, 2 for plane 1&2 each */
194
195/* Minimum X and Y resolutions */
196#define MIN_XRES 64
197#define MIN_YRES 64
198
199/* HW cursor parameters */
200#define MAX_CURS 32
201
202/* Modes of operation of DIU */
203#define MFB_MODE0 0 /* DIU off */
204#define MFB_MODE1 1 /* All three planes output to display */
205#define MFB_MODE2 2 /* Plane 1 to display, planes 2+3 written back*/
206#define MFB_MODE3 3 /* All three planes written back to memory */
207#define MFB_MODE4 4 /* Color bar generation */
208
209/* INT_STATUS/INT_MASK field descriptions */
210#define INT_VSYNC 0x01 /* Vsync interrupt */
211#define INT_VSYNC_WB 0x02 /* Vsync interrupt for write back operation */
212#define INT_UNDRUN 0x04 /* Under run exception interrupt */
213#define INT_PARERR 0x08 /* Display parameters error interrupt */
214#define INT_LS_BF_VS 0x10 /* Lines before vsync. interrupt */
215
216/* Panels'operation modes */
217#define MFB_TYPE_OUTPUT 0 /* Panel output to display */
218#define MFB_TYPE_OFF 1 /* Panel off */
219#define MFB_TYPE_WB 2 /* Panel written back to memory */
220#define MFB_TYPE_TEST 3 /* Panel generate color bar */
221
222#endif /* __KERNEL__ */
223#endif /* __FSL_DIU_FB_H__ */
diff --git a/drivers/video/geode/Kconfig b/drivers/video/geode/Kconfig
index 7608429b3943..c5d8ba4b9fc3 100644
--- a/drivers/video/geode/Kconfig
+++ b/drivers/video/geode/Kconfig
@@ -38,26 +38,6 @@ config FB_GEODE_GX
38 38
39 If unsure, say N. 39 If unsure, say N.
40 40
41config FB_GEODE_GX_SET_FBSIZE
42 bool "Manually specify the Geode GX framebuffer size"
43 depends on FB_GEODE_GX
44 default n
45 ---help---
46 If you want to manually specify the size of your GX framebuffer,
47 say Y here, otherwise say N to dynamically probe it.
48
49 Say N unless you know what you are doing.
50
51config FB_GEODE_GX_FBSIZE
52 hex "Size of the GX framebuffer, in bytes"
53 depends on FB_GEODE_GX_SET_FBSIZE
54 default "0x1600000"
55 ---help---
56 Specify the size of the GX framebuffer. Normally, you will
57 want this to be MB aligned. Common values are 0x80000 (8MB)
58 and 0x1600000 (16MB). Don't change this unless you know what
59 you are doing
60
61config FB_GEODE_GX1 41config FB_GEODE_GX1
62 tristate "AMD Geode GX1 framebuffer support (EXPERIMENTAL)" 42 tristate "AMD Geode GX1 framebuffer support (EXPERIMENTAL)"
63 depends on FB && FB_GEODE && EXPERIMENTAL 43 depends on FB && FB_GEODE && EXPERIMENTAL
diff --git a/drivers/video/geode/Makefile b/drivers/video/geode/Makefile
index 957304b45fba..5c98da126883 100644
--- a/drivers/video/geode/Makefile
+++ b/drivers/video/geode/Makefile
@@ -5,5 +5,5 @@ obj-$(CONFIG_FB_GEODE_GX) += gxfb.o
5obj-$(CONFIG_FB_GEODE_LX) += lxfb.o 5obj-$(CONFIG_FB_GEODE_LX) += lxfb.o
6 6
7gx1fb-objs := gx1fb_core.o display_gx1.o video_cs5530.o 7gx1fb-objs := gx1fb_core.o display_gx1.o video_cs5530.o
8gxfb-objs := gxfb_core.o display_gx.o video_gx.o 8gxfb-objs := gxfb_core.o display_gx.o video_gx.o suspend_gx.o
9lxfb-objs := lxfb_core.o lxfb_ops.o 9lxfb-objs := lxfb_core.o lxfb_ops.o
diff --git a/drivers/video/geode/display_gx.c b/drivers/video/geode/display_gx.c
index 0f16e4bffc6c..e759895bf3d3 100644
--- a/drivers/video/geode/display_gx.c
+++ b/drivers/video/geode/display_gx.c
@@ -17,31 +17,40 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/div64.h> 18#include <asm/div64.h>
19#include <asm/delay.h> 19#include <asm/delay.h>
20#include <asm/geode.h>
20 21
21#include "geodefb.h" 22#include "gxfb.h"
22#include "display_gx.h"
23 23
24#ifdef CONFIG_FB_GEODE_GX_SET_FBSIZE
25unsigned int gx_frame_buffer_size(void)
26{
27 return CONFIG_FB_GEODE_GX_FBSIZE;
28}
29#else
30unsigned int gx_frame_buffer_size(void) 24unsigned int gx_frame_buffer_size(void)
31{ 25{
32 unsigned int val; 26 unsigned int val;
33 27
34 /* FB size is reported by a virtual register */ 28 if (!geode_has_vsa2()) {
29 uint32_t hi, lo;
30
31 /* The number of pages is (PMAX - PMIN)+1 */
32 rdmsr(MSR_GLIU_P2D_RO0, lo, hi);
33
34 /* PMAX */
35 val = ((hi & 0xff) << 12) | ((lo & 0xfff00000) >> 20);
36 /* PMIN */
37 val -= (lo & 0x000fffff);
38 val += 1;
39
40 /* The page size is 4k */
41 return (val << 12);
42 }
43
44 /* FB size can be obtained from the VSA II */
35 /* Virtual register class = 0x02 */ 45 /* Virtual register class = 0x02 */
36 /* VG_MEM_SIZE(512Kb units) = 0x00 */ 46 /* VG_MEM_SIZE(512Kb units) = 0x00 */
37 47
38 outw(0xFC53, 0xAC1C); 48 outw(VSA_VR_UNLOCK, VSA_VRC_INDEX);
39 outw(0x0200, 0xAC1C); 49 outw(VSA_VR_MEM_SIZE, VSA_VRC_INDEX);
40 50
41 val = (unsigned int)(inw(0xAC1E)) & 0xFFl; 51 val = (unsigned int)(inw(VSA_VRC_DATA)) & 0xFFl;
42 return (val << 19); 52 return (val << 19);
43} 53}
44#endif
45 54
46int gx_line_delta(int xres, int bpp) 55int gx_line_delta(int xres, int bpp)
47{ 56{
@@ -49,75 +58,76 @@ int gx_line_delta(int xres, int bpp)
49 return (xres * (bpp >> 3) + 7) & ~0x7; 58 return (xres * (bpp >> 3) + 7) & ~0x7;
50} 59}
51 60
52static void gx_set_mode(struct fb_info *info) 61void gx_set_mode(struct fb_info *info)
53{ 62{
54 struct geodefb_par *par = info->par; 63 struct gxfb_par *par = info->par;
55 u32 gcfg, dcfg; 64 u32 gcfg, dcfg;
56 int hactive, hblankstart, hsyncstart, hsyncend, hblankend, htotal; 65 int hactive, hblankstart, hsyncstart, hsyncend, hblankend, htotal;
57 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal; 66 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal;
58 67
59 /* Unlock the display controller registers. */ 68 /* Unlock the display controller registers. */
60 readl(par->dc_regs + DC_UNLOCK); 69 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
61 writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK);
62 70
63 gcfg = readl(par->dc_regs + DC_GENERAL_CFG); 71 gcfg = read_dc(par, DC_GENERAL_CFG);
64 dcfg = readl(par->dc_regs + DC_DISPLAY_CFG); 72 dcfg = read_dc(par, DC_DISPLAY_CFG);
65 73
66 /* Disable the timing generator. */ 74 /* Disable the timing generator. */
67 dcfg &= ~(DC_DCFG_TGEN); 75 dcfg &= ~DC_DISPLAY_CFG_TGEN;
68 writel(dcfg, par->dc_regs + DC_DISPLAY_CFG); 76 write_dc(par, DC_DISPLAY_CFG, dcfg);
69 77
70 /* Wait for pending memory requests before disabling the FIFO load. */ 78 /* Wait for pending memory requests before disabling the FIFO load. */
71 udelay(100); 79 udelay(100);
72 80
73 /* Disable FIFO load and compression. */ 81 /* Disable FIFO load and compression. */
74 gcfg &= ~(DC_GCFG_DFLE | DC_GCFG_CMPE | DC_GCFG_DECE); 82 gcfg &= ~(DC_GENERAL_CFG_DFLE | DC_GENERAL_CFG_CMPE |
75 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 83 DC_GENERAL_CFG_DECE);
84 write_dc(par, DC_GENERAL_CFG, gcfg);
76 85
77 /* Setup DCLK and its divisor. */ 86 /* Setup DCLK and its divisor. */
78 par->vid_ops->set_dclk(info); 87 gx_set_dclk_frequency(info);
79 88
80 /* 89 /*
81 * Setup new mode. 90 * Setup new mode.
82 */ 91 */
83 92
84 /* Clear all unused feature bits. */ 93 /* Clear all unused feature bits. */
85 gcfg &= DC_GCFG_YUVM | DC_GCFG_VDSE; 94 gcfg &= DC_GENERAL_CFG_YUVM | DC_GENERAL_CFG_VDSE;
86 dcfg = 0; 95 dcfg = 0;
87 96
88 /* Set FIFO priority (default 6/5) and enable. */ 97 /* Set FIFO priority (default 6/5) and enable. */
89 /* FIXME: increase fifo priority for 1280x1024 and higher modes? */ 98 /* FIXME: increase fifo priority for 1280x1024 and higher modes? */
90 gcfg |= (6 << DC_GCFG_DFHPEL_POS) | (5 << DC_GCFG_DFHPSL_POS) | DC_GCFG_DFLE; 99 gcfg |= (6 << DC_GENERAL_CFG_DFHPEL_SHIFT) |
100 (5 << DC_GENERAL_CFG_DFHPSL_SHIFT) | DC_GENERAL_CFG_DFLE;
91 101
92 /* Framebuffer start offset. */ 102 /* Framebuffer start offset. */
93 writel(0, par->dc_regs + DC_FB_ST_OFFSET); 103 write_dc(par, DC_FB_ST_OFFSET, 0);
94 104
95 /* Line delta and line buffer length. */ 105 /* Line delta and line buffer length. */
96 writel(info->fix.line_length >> 3, par->dc_regs + DC_GFX_PITCH); 106 write_dc(par, DC_GFX_PITCH, info->fix.line_length >> 3);
97 writel(((info->var.xres * info->var.bits_per_pixel/8) >> 3) + 2, 107 write_dc(par, DC_LINE_SIZE,
98 par->dc_regs + DC_LINE_SIZE); 108 ((info->var.xres * info->var.bits_per_pixel/8) >> 3) + 2);
99 109
100 110
101 /* Enable graphics and video data and unmask address lines. */ 111 /* Enable graphics and video data and unmask address lines. */
102 dcfg |= DC_DCFG_GDEN | DC_DCFG_VDEN | DC_DCFG_A20M | DC_DCFG_A18M; 112 dcfg |= DC_DISPLAY_CFG_GDEN | DC_DISPLAY_CFG_VDEN |
113 DC_DISPLAY_CFG_A20M | DC_DISPLAY_CFG_A18M;
103 114
104 /* Set pixel format. */ 115 /* Set pixel format. */
105 switch (info->var.bits_per_pixel) { 116 switch (info->var.bits_per_pixel) {
106 case 8: 117 case 8:
107 dcfg |= DC_DCFG_DISP_MODE_8BPP; 118 dcfg |= DC_DISPLAY_CFG_DISP_MODE_8BPP;
108 break; 119 break;
109 case 16: 120 case 16:
110 dcfg |= DC_DCFG_DISP_MODE_16BPP; 121 dcfg |= DC_DISPLAY_CFG_DISP_MODE_16BPP;
111 dcfg |= DC_DCFG_16BPP_MODE_565;
112 break; 122 break;
113 case 32: 123 case 32:
114 dcfg |= DC_DCFG_DISP_MODE_24BPP; 124 dcfg |= DC_DISPLAY_CFG_DISP_MODE_24BPP;
115 dcfg |= DC_DCFG_PALB; 125 dcfg |= DC_DISPLAY_CFG_PALB;
116 break; 126 break;
117 } 127 }
118 128
119 /* Enable timing generator. */ 129 /* Enable timing generator. */
120 dcfg |= DC_DCFG_TGEN; 130 dcfg |= DC_DISPLAY_CFG_TGEN;
121 131
122 /* Horizontal and vertical timings. */ 132 /* Horizontal and vertical timings. */
123 hactive = info->var.xres; 133 hactive = info->var.xres;
@@ -134,28 +144,34 @@ static void gx_set_mode(struct fb_info *info)
134 vblankend = vsyncend + info->var.upper_margin; 144 vblankend = vsyncend + info->var.upper_margin;
135 vtotal = vblankend; 145 vtotal = vblankend;
136 146
137 writel((hactive - 1) | ((htotal - 1) << 16), par->dc_regs + DC_H_ACTIVE_TIMING); 147 write_dc(par, DC_H_ACTIVE_TIMING, (hactive - 1) |
138 writel((hblankstart - 1) | ((hblankend - 1) << 16), par->dc_regs + DC_H_BLANK_TIMING); 148 ((htotal - 1) << 16));
139 writel((hsyncstart - 1) | ((hsyncend - 1) << 16), par->dc_regs + DC_H_SYNC_TIMING); 149 write_dc(par, DC_H_BLANK_TIMING, (hblankstart - 1) |
150 ((hblankend - 1) << 16));
151 write_dc(par, DC_H_SYNC_TIMING, (hsyncstart - 1) |
152 ((hsyncend - 1) << 16));
140 153
141 writel((vactive - 1) | ((vtotal - 1) << 16), par->dc_regs + DC_V_ACTIVE_TIMING); 154 write_dc(par, DC_V_ACTIVE_TIMING, (vactive - 1) |
142 writel((vblankstart - 1) | ((vblankend - 1) << 16), par->dc_regs + DC_V_BLANK_TIMING); 155 ((vtotal - 1) << 16));
143 writel((vsyncstart - 1) | ((vsyncend - 1) << 16), par->dc_regs + DC_V_SYNC_TIMING); 156 write_dc(par, DC_V_BLANK_TIMING, (vblankstart - 1) |
157 ((vblankend - 1) << 16));
158 write_dc(par, DC_V_SYNC_TIMING, (vsyncstart - 1) |
159 ((vsyncend - 1) << 16));
144 160
145 /* Write final register values. */ 161 /* Write final register values. */
146 writel(dcfg, par->dc_regs + DC_DISPLAY_CFG); 162 write_dc(par, DC_DISPLAY_CFG, dcfg);
147 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 163 write_dc(par, DC_GENERAL_CFG, gcfg);
148 164
149 par->vid_ops->configure_display(info); 165 gx_configure_display(info);
150 166
151 /* Relock display controller registers */ 167 /* Relock display controller registers */
152 writel(0, par->dc_regs + DC_UNLOCK); 168 write_dc(par, DC_UNLOCK, DC_UNLOCK_LOCK);
153} 169}
154 170
155static void gx_set_hw_palette_reg(struct fb_info *info, unsigned regno, 171void gx_set_hw_palette_reg(struct fb_info *info, unsigned regno,
156 unsigned red, unsigned green, unsigned blue) 172 unsigned red, unsigned green, unsigned blue)
157{ 173{
158 struct geodefb_par *par = info->par; 174 struct gxfb_par *par = info->par;
159 int val; 175 int val;
160 176
161 /* Hardware palette is in RGB 8-8-8 format. */ 177 /* Hardware palette is in RGB 8-8-8 format. */
@@ -163,11 +179,6 @@ static void gx_set_hw_palette_reg(struct fb_info *info, unsigned regno,
163 val |= (green) & 0x00ff00; 179 val |= (green) & 0x00ff00;
164 val |= (blue >> 8) & 0x0000ff; 180 val |= (blue >> 8) & 0x0000ff;
165 181
166 writel(regno, par->dc_regs + DC_PAL_ADDRESS); 182 write_dc(par, DC_PAL_ADDRESS, regno);
167 writel(val, par->dc_regs + DC_PAL_DATA); 183 write_dc(par, DC_PAL_DATA, val);
168} 184}
169
170struct geode_dc_ops gx_dc_ops = {
171 .set_mode = gx_set_mode,
172 .set_palette_reg = gx_set_hw_palette_reg,
173};
diff --git a/drivers/video/geode/display_gx.h b/drivers/video/geode/display_gx.h
deleted file mode 100644
index 0af33f329e88..000000000000
--- a/drivers/video/geode/display_gx.h
+++ /dev/null
@@ -1,101 +0,0 @@
1/*
2 * Geode GX display controller
3 *
4 * Copyright (C) 2006 Arcom Control Systems Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef __DISPLAY_GX_H__
12#define __DISPLAY_GX_H__
13
14unsigned int gx_frame_buffer_size(void);
15int gx_line_delta(int xres, int bpp);
16
17extern struct geode_dc_ops gx_dc_ops;
18
19/* MSR that tells us if a TFT or CRT is attached */
20#define GLD_MSR_CONFIG 0xC0002001
21#define GLD_MSR_CONFIG_DM_FP 0x40
22
23/* Display controller registers */
24
25#define DC_UNLOCK 0x00
26# define DC_UNLOCK_CODE 0x00004758
27
28#define DC_GENERAL_CFG 0x04
29# define DC_GCFG_DFLE 0x00000001
30# define DC_GCFG_CURE 0x00000002
31# define DC_GCFG_ICNE 0x00000004
32# define DC_GCFG_VIDE 0x00000008
33# define DC_GCFG_CMPE 0x00000020
34# define DC_GCFG_DECE 0x00000040
35# define DC_GCFG_VGAE 0x00000080
36# define DC_GCFG_DFHPSL_MASK 0x00000F00
37# define DC_GCFG_DFHPSL_POS 8
38# define DC_GCFG_DFHPEL_MASK 0x0000F000
39# define DC_GCFG_DFHPEL_POS 12
40# define DC_GCFG_STFM 0x00010000
41# define DC_GCFG_FDTY 0x00020000
42# define DC_GCFG_VGAFT 0x00040000
43# define DC_GCFG_VDSE 0x00080000
44# define DC_GCFG_YUVM 0x00100000
45# define DC_GCFG_VFSL 0x00800000
46# define DC_GCFG_SIGE 0x01000000
47# define DC_GCFG_SGRE 0x02000000
48# define DC_GCFG_SGFR 0x04000000
49# define DC_GCFG_CRC_MODE 0x08000000
50# define DC_GCFG_DIAG 0x10000000
51# define DC_GCFG_CFRW 0x20000000
52
53#define DC_DISPLAY_CFG 0x08
54# define DC_DCFG_TGEN 0x00000001
55# define DC_DCFG_GDEN 0x00000008
56# define DC_DCFG_VDEN 0x00000010
57# define DC_DCFG_TRUP 0x00000040
58# define DC_DCFG_DISP_MODE_MASK 0x00000300
59# define DC_DCFG_DISP_MODE_8BPP 0x00000000
60# define DC_DCFG_DISP_MODE_16BPP 0x00000100
61# define DC_DCFG_DISP_MODE_24BPP 0x00000200
62# define DC_DCFG_16BPP_MODE_MASK 0x00000c00
63# define DC_DCFG_16BPP_MODE_565 0x00000000
64# define DC_DCFG_16BPP_MODE_555 0x00000100
65# define DC_DCFG_16BPP_MODE_444 0x00000200
66# define DC_DCFG_DCEN 0x00080000
67# define DC_DCFG_PALB 0x02000000
68# define DC_DCFG_FRLK 0x04000000
69# define DC_DCFG_VISL 0x08000000
70# define DC_DCFG_FRSL 0x20000000
71# define DC_DCFG_A18M 0x40000000
72# define DC_DCFG_A20M 0x80000000
73
74#define DC_FB_ST_OFFSET 0x10
75
76#define DC_LINE_SIZE 0x30
77# define DC_LINE_SIZE_FB_LINE_SIZE_MASK 0x000007ff
78# define DC_LINE_SIZE_FB_LINE_SIZE_POS 0
79# define DC_LINE_SIZE_CB_LINE_SIZE_MASK 0x007f0000
80# define DC_LINE_SIZE_CB_LINE_SIZE_POS 16
81# define DC_LINE_SIZE_VID_LINE_SIZE_MASK 0xff000000
82# define DC_LINE_SIZE_VID_LINE_SIZE_POS 24
83
84#define DC_GFX_PITCH 0x34
85# define DC_GFX_PITCH_FB_PITCH_MASK 0x0000ffff
86# define DC_GFX_PITCH_FB_PITCH_POS 0
87# define DC_GFX_PITCH_CB_PITCH_MASK 0xffff0000
88# define DC_GFX_PITCH_CB_PITCH_POS 16
89
90#define DC_H_ACTIVE_TIMING 0x40
91#define DC_H_BLANK_TIMING 0x44
92#define DC_H_SYNC_TIMING 0x48
93#define DC_V_ACTIVE_TIMING 0x50
94#define DC_V_BLANK_TIMING 0x54
95#define DC_V_SYNC_TIMING 0x58
96
97#define DC_PAL_ADDRESS 0x70
98#define DC_PAL_DATA 0x74
99
100#define DC_GLIU0_MEM_OFFSET 0x84
101#endif /* !__DISPLAY_GX1_H__ */
diff --git a/drivers/video/geode/gxfb.h b/drivers/video/geode/gxfb.h
new file mode 100644
index 000000000000..16a96f8fd8c5
--- /dev/null
+++ b/drivers/video/geode/gxfb.h
@@ -0,0 +1,358 @@
1/*
2 * Copyright (C) 2008 Andres Salomon <dilinger@debian.org>
3 *
4 * Geode GX2 header information
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef _GXFB_H_
12#define _GXFB_H_
13
14#include <linux/io.h>
15
16#define GP_REG_COUNT (0x50 / 4)
17#define DC_REG_COUNT (0x90 / 4)
18#define VP_REG_COUNT (0x138 / 8)
19#define FP_REG_COUNT (0x68 / 8)
20
21#define DC_PAL_COUNT 0x104
22
23struct gxfb_par {
24 int enable_crt;
25 void __iomem *dc_regs;
26 void __iomem *vid_regs;
27 void __iomem *gp_regs;
28#ifdef CONFIG_PM
29 int powered_down;
30
31 /* register state, for power management functionality */
32 struct {
33 uint64_t padsel;
34 uint64_t dotpll;
35 } msr;
36
37 uint32_t gp[GP_REG_COUNT];
38 uint32_t dc[DC_REG_COUNT];
39 uint64_t vp[VP_REG_COUNT];
40 uint64_t fp[FP_REG_COUNT];
41
42 uint32_t pal[DC_PAL_COUNT];
43#endif
44};
45
46unsigned int gx_frame_buffer_size(void);
47int gx_line_delta(int xres, int bpp);
48void gx_set_mode(struct fb_info *info);
49void gx_set_hw_palette_reg(struct fb_info *info, unsigned regno,
50 unsigned red, unsigned green, unsigned blue);
51
52void gx_set_dclk_frequency(struct fb_info *info);
53void gx_configure_display(struct fb_info *info);
54int gx_blank_display(struct fb_info *info, int blank_mode);
55
56#ifdef CONFIG_PM
57int gx_powerdown(struct fb_info *info);
58int gx_powerup(struct fb_info *info);
59#endif
60
61
62/* Graphics Processor registers (table 6-23 from the data book) */
63enum gp_registers {
64 GP_DST_OFFSET = 0,
65 GP_SRC_OFFSET,
66 GP_STRIDE,
67 GP_WID_HEIGHT,
68
69 GP_SRC_COLOR_FG,
70 GP_SRC_COLOR_BG,
71 GP_PAT_COLOR_0,
72 GP_PAT_COLOR_1,
73
74 GP_PAT_COLOR_2,
75 GP_PAT_COLOR_3,
76 GP_PAT_COLOR_4,
77 GP_PAT_COLOR_5,
78
79 GP_PAT_DATA_0,
80 GP_PAT_DATA_1,
81 GP_RASTER_MODE,
82 GP_VECTOR_MODE,
83
84 GP_BLT_MODE,
85 GP_BLT_STATUS,
86 GP_HST_SRC,
87 GP_BASE_OFFSET, /* 0x4c */
88};
89
90#define GP_BLT_STATUS_BLT_PENDING (1 << 2)
91#define GP_BLT_STATUS_BLT_BUSY (1 << 0)
92
93
94/* Display Controller registers (table 6-38 from the data book) */
95enum dc_registers {
96 DC_UNLOCK = 0,
97 DC_GENERAL_CFG,
98 DC_DISPLAY_CFG,
99 DC_RSVD_0,
100
101 DC_FB_ST_OFFSET,
102 DC_CB_ST_OFFSET,
103 DC_CURS_ST_OFFSET,
104 DC_ICON_ST_OFFSET,
105
106 DC_VID_Y_ST_OFFSET,
107 DC_VID_U_ST_OFFSET,
108 DC_VID_V_ST_OFFSET,
109 DC_RSVD_1,
110
111 DC_LINE_SIZE,
112 DC_GFX_PITCH,
113 DC_VID_YUV_PITCH,
114 DC_RSVD_2,
115
116 DC_H_ACTIVE_TIMING,
117 DC_H_BLANK_TIMING,
118 DC_H_SYNC_TIMING,
119 DC_RSVD_3,
120
121 DC_V_ACTIVE_TIMING,
122 DC_V_BLANK_TIMING,
123 DC_V_SYNC_TIMING,
124 DC_RSVD_4,
125
126 DC_CURSOR_X,
127 DC_CURSOR_Y,
128 DC_ICON_X,
129 DC_LINE_CNT,
130
131 DC_PAL_ADDRESS,
132 DC_PAL_DATA,
133 DC_DFIFO_DIAG,
134 DC_CFIFO_DIAG,
135
136 DC_VID_DS_DELTA,
137 DC_GLIU0_MEM_OFFSET,
138 DC_RSVD_5,
139 DC_DV_ACC, /* 0x8c */
140};
141
142#define DC_UNLOCK_LOCK 0x00000000
143#define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
144
145#define DC_GENERAL_CFG_YUVM (1 << 20)
146#define DC_GENERAL_CFG_VDSE (1 << 19)
147#define DC_GENERAL_CFG_DFHPEL_SHIFT 12
148#define DC_GENERAL_CFG_DFHPSL_SHIFT 8
149#define DC_GENERAL_CFG_DECE (1 << 6)
150#define DC_GENERAL_CFG_CMPE (1 << 5)
151#define DC_GENERAL_CFG_VIDE (1 << 3)
152#define DC_GENERAL_CFG_ICNE (1 << 2)
153#define DC_GENERAL_CFG_CURE (1 << 1)
154#define DC_GENERAL_CFG_DFLE (1 << 0)
155
156#define DC_DISPLAY_CFG_A20M (1 << 31)
157#define DC_DISPLAY_CFG_A18M (1 << 30)
158#define DC_DISPLAY_CFG_PALB (1 << 25)
159#define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
160#define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
161#define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
162#define DC_DISPLAY_CFG_VDEN (1 << 4)
163#define DC_DISPLAY_CFG_GDEN (1 << 3)
164#define DC_DISPLAY_CFG_TGEN (1 << 0)
165
166
167/*
168 * Video Processor registers (table 6-54).
169 * There is space for 64 bit values, but we never use more than the
170 * lower 32 bits. The actual register save/restore code only bothers
171 * to restore those 32 bits.
172 */
173enum vp_registers {
174 VP_VCFG = 0,
175 VP_DCFG,
176
177 VP_VX,
178 VP_VY,
179
180 VP_VS,
181 VP_VCK,
182
183 VP_VCM,
184 VP_GAR,
185
186 VP_GDR,
187 VP_RSVD_0,
188
189 VP_MISC,
190 VP_CCS,
191
192 VP_RSVD_1,
193 VP_RSVD_2,
194
195 VP_RSVD_3,
196 VP_VDC,
197
198 VP_VCO,
199 VP_CRC,
200
201 VP_CRC32,
202 VP_VDE,
203
204 VP_CCK,
205 VP_CCM,
206
207 VP_CC1,
208 VP_CC2,
209
210 VP_A1X,
211 VP_A1Y,
212
213 VP_A1C,
214 VP_A1T,
215
216 VP_A2X,
217 VP_A2Y,
218
219 VP_A2C,
220 VP_A2T,
221
222 VP_A3X,
223 VP_A3Y,
224
225 VP_A3C,
226 VP_A3T,
227
228 VP_VRR,
229 VP_AWT,
230
231 VP_VTM, /* 0x130 */
232};
233
234#define VP_VCFG_VID_EN (1 << 0)
235
236#define VP_DCFG_DAC_VREF (1 << 26)
237#define VP_DCFG_GV_GAM (1 << 21)
238#define VP_DCFG_VG_CK (1 << 20)
239#define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
240#define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
241#define VP_DCFG_CRT_VSYNC_POL (1 << 9)
242#define VP_DCFG_CRT_HSYNC_POL (1 << 8)
243#define VP_DCFG_FP_DATA_EN (1 << 7) /* undocumented */
244#define VP_DCFG_FP_PWR_EN (1 << 6) /* undocumented */
245#define VP_DCFG_DAC_BL_EN (1 << 3)
246#define VP_DCFG_VSYNC_EN (1 << 2)
247#define VP_DCFG_HSYNC_EN (1 << 1)
248#define VP_DCFG_CRT_EN (1 << 0)
249
250#define VP_MISC_GAM_EN (1 << 0)
251#define VP_MISC_DACPWRDN (1 << 10)
252#define VP_MISC_APWRDN (1 << 11)
253
254
255/*
256 * Flat Panel registers (table 6-55).
257 * Also 64 bit registers; see above note about 32-bit handling.
258 */
259
260/* we're actually in the VP register space, starting at address 0x400 */
261#define VP_FP_START 0x400
262
263enum fp_registers {
264 FP_PT1 = 0,
265 FP_PT2,
266
267 FP_PM,
268 FP_DFC,
269
270 FP_BLFSR,
271 FP_RLFSR,
272
273 FP_FMI,
274 FP_FMD,
275
276 FP_RSVD_0,
277 FP_DCA,
278
279 FP_DMD,
280 FP_CRC,
281
282 FP_FBB, /* 0x460 */
283};
284
285#define FP_PT1_VSIZE_SHIFT 16 /* undocumented? */
286#define FP_PT1_VSIZE_MASK 0x7FF0000 /* undocumented? */
287
288#define FP_PT2_HSP (1 << 22)
289#define FP_PT2_VSP (1 << 23)
290
291#define FP_PM_P (1 << 24) /* panel power on */
292#define FP_PM_PANEL_PWR_UP (1 << 3) /* r/o */
293#define FP_PM_PANEL_PWR_DOWN (1 << 2) /* r/o */
294#define FP_PM_PANEL_OFF (1 << 1) /* r/o */
295#define FP_PM_PANEL_ON (1 << 0) /* r/o */
296
297#define FP_DFC_NFI ((1 << 4) | (1 << 5) | (1 << 6))
298
299
300/* register access functions */
301
302static inline uint32_t read_gp(struct gxfb_par *par, int reg)
303{
304 return readl(par->gp_regs + 4*reg);
305}
306
307static inline void write_gp(struct gxfb_par *par, int reg, uint32_t val)
308{
309 writel(val, par->gp_regs + 4*reg);
310}
311
312static inline uint32_t read_dc(struct gxfb_par *par, int reg)
313{
314 return readl(par->dc_regs + 4*reg);
315}
316
317static inline void write_dc(struct gxfb_par *par, int reg, uint32_t val)
318{
319 writel(val, par->dc_regs + 4*reg);
320}
321
322static inline uint32_t read_vp(struct gxfb_par *par, int reg)
323{
324 return readl(par->vid_regs + 8*reg);
325}
326
327static inline void write_vp(struct gxfb_par *par, int reg, uint32_t val)
328{
329 writel(val, par->vid_regs + 8*reg);
330}
331
332static inline uint32_t read_fp(struct gxfb_par *par, int reg)
333{
334 return readl(par->vid_regs + 8*reg + VP_FP_START);
335}
336
337static inline void write_fp(struct gxfb_par *par, int reg, uint32_t val)
338{
339 writel(val, par->vid_regs + 8*reg + VP_FP_START);
340}
341
342
343/* MSRs are defined in asm/geode.h; their bitfields are here */
344
345#define MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3 (1 << 3)
346#define MSR_GLCP_SYS_RSTPLL_DOTPREMULT2 (1 << 2)
347#define MSR_GLCP_SYS_RSTPLL_DOTPREDIV2 (1 << 1)
348
349#define MSR_GLCP_DOTPLL_LOCK (1 << 25) /* r/o */
350#define MSR_GLCP_DOTPLL_BYPASS (1 << 15)
351#define MSR_GLCP_DOTPLL_DOTRESET (1 << 0)
352
353#define MSR_GX_MSR_PADSEL_MASK 0x3FFFFFFF /* undocumented? */
354#define MSR_GX_MSR_PADSEL_TFT 0x1FFFFFFF /* undocumented? */
355
356#define MSR_GX_GLD_MSR_CONFIG_FP (1 << 3)
357
358#endif
diff --git a/drivers/video/geode/gxfb_core.c b/drivers/video/geode/gxfb_core.c
index cf841efa229a..de2b8f9876a5 100644
--- a/drivers/video/geode/gxfb_core.c
+++ b/drivers/video/geode/gxfb_core.c
@@ -28,17 +28,20 @@
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <linux/delay.h> 29#include <linux/delay.h>
30#include <linux/fb.h> 30#include <linux/fb.h>
31#include <linux/console.h>
32#include <linux/suspend.h>
31#include <linux/init.h> 33#include <linux/init.h>
32#include <linux/pci.h> 34#include <linux/pci.h>
35#include <asm/geode.h>
33 36
34#include "geodefb.h" 37#include "gxfb.h"
35#include "display_gx.h"
36#include "video_gx.h"
37 38
38static char *mode_option; 39static char *mode_option;
40static int vram;
41static int vt_switch;
39 42
40/* Modes relevant to the GX (taken from modedb.c) */ 43/* Modes relevant to the GX (taken from modedb.c) */
41static const struct fb_videomode gx_modedb[] __initdata = { 44static struct fb_videomode gx_modedb[] __initdata = {
42 /* 640x480-60 VESA */ 45 /* 640x480-60 VESA */
43 { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2, 46 { NULL, 60, 640, 480, 39682, 48, 16, 33, 10, 96, 2,
44 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, 47 0, FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
@@ -105,6 +108,35 @@ static const struct fb_videomode gx_modedb[] __initdata = {
105 FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA }, 108 FB_VMODE_NONINTERLACED, FB_MODE_IS_VESA },
106}; 109};
107 110
111#ifdef CONFIG_OLPC
112#include <asm/olpc.h>
113
114static struct fb_videomode gx_dcon_modedb[] __initdata = {
115 /* The only mode the DCON has is 1200x900 */
116 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
117 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
118 FB_VMODE_NONINTERLACED, 0 }
119};
120
121static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size)
122{
123 if (olpc_has_dcon()) {
124 *modedb = (struct fb_videomode *) gx_dcon_modedb;
125 *size = ARRAY_SIZE(gx_dcon_modedb);
126 } else {
127 *modedb = (struct fb_videomode *) gx_modedb;
128 *size = ARRAY_SIZE(gx_modedb);
129 }
130}
131
132#else
133static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size)
134{
135 *modedb = (struct fb_videomode *) gx_modedb;
136 *size = ARRAY_SIZE(gx_modedb);
137}
138#endif
139
108static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 140static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
109{ 141{
110 if (var->xres > 1600 || var->yres > 1200) 142 if (var->xres > 1600 || var->yres > 1200)
@@ -139,8 +171,6 @@ static int gxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
139 171
140static int gxfb_set_par(struct fb_info *info) 172static int gxfb_set_par(struct fb_info *info)
141{ 173{
142 struct geodefb_par *par = info->par;
143
144 if (info->var.bits_per_pixel > 8) { 174 if (info->var.bits_per_pixel > 8) {
145 info->fix.visual = FB_VISUAL_TRUECOLOR; 175 info->fix.visual = FB_VISUAL_TRUECOLOR;
146 fb_dealloc_cmap(&info->cmap); 176 fb_dealloc_cmap(&info->cmap);
@@ -151,7 +181,7 @@ static int gxfb_set_par(struct fb_info *info)
151 181
152 info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel); 182 info->fix.line_length = gx_line_delta(info->var.xres, info->var.bits_per_pixel);
153 183
154 par->dc_ops->set_mode(info); 184 gx_set_mode(info);
155 185
156 return 0; 186 return 0;
157} 187}
@@ -167,8 +197,6 @@ static int gxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
167 unsigned blue, unsigned transp, 197 unsigned blue, unsigned transp,
168 struct fb_info *info) 198 struct fb_info *info)
169{ 199{
170 struct geodefb_par *par = info->par;
171
172 if (info->var.grayscale) { 200 if (info->var.grayscale) {
173 /* grayscale = 0.30*R + 0.59*G + 0.11*B */ 201 /* grayscale = 0.30*R + 0.59*G + 0.11*B */
174 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8; 202 red = green = blue = (red * 77 + green * 151 + blue * 28) >> 8;
@@ -191,7 +219,7 @@ static int gxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
191 if (regno >= 256) 219 if (regno >= 256)
192 return -EINVAL; 220 return -EINVAL;
193 221
194 par->dc_ops->set_palette_reg(info, regno, red, green, blue); 222 gx_set_hw_palette_reg(info, regno, red, green, blue);
195 } 223 }
196 224
197 return 0; 225 return 0;
@@ -199,15 +227,12 @@ static int gxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
199 227
200static int gxfb_blank(int blank_mode, struct fb_info *info) 228static int gxfb_blank(int blank_mode, struct fb_info *info)
201{ 229{
202 struct geodefb_par *par = info->par; 230 return gx_blank_display(info, blank_mode);
203
204 return par->vid_ops->blank_display(info, blank_mode);
205} 231}
206 232
207static int __init gxfb_map_video_memory(struct fb_info *info, struct pci_dev *dev) 233static int __init gxfb_map_video_memory(struct fb_info *info, struct pci_dev *dev)
208{ 234{
209 struct geodefb_par *par = info->par; 235 struct gxfb_par *par = info->par;
210 int fb_len;
211 int ret; 236 int ret;
212 237
213 ret = pci_enable_device(dev); 238 ret = pci_enable_device(dev);
@@ -229,24 +254,31 @@ static int __init gxfb_map_video_memory(struct fb_info *info, struct pci_dev *de
229 if (!par->dc_regs) 254 if (!par->dc_regs)
230 return -ENOMEM; 255 return -ENOMEM;
231 256
232 ret = pci_request_region(dev, 0, "gxfb (framebuffer)"); 257 ret = pci_request_region(dev, 1, "gxfb (graphics processor)");
233 if (ret < 0) 258 if (ret < 0)
234 return ret; 259 return ret;
235 if ((fb_len = gx_frame_buffer_size()) < 0) 260 par->gp_regs = ioremap(pci_resource_start(dev, 1),
261 pci_resource_len(dev, 1));
262
263 if (!par->gp_regs)
236 return -ENOMEM; 264 return -ENOMEM;
265
266 ret = pci_request_region(dev, 0, "gxfb (framebuffer)");
267 if (ret < 0)
268 return ret;
269
237 info->fix.smem_start = pci_resource_start(dev, 0); 270 info->fix.smem_start = pci_resource_start(dev, 0);
238 info->fix.smem_len = fb_len; 271 info->fix.smem_len = vram ? vram : gx_frame_buffer_size();
239 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); 272 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
240 if (!info->screen_base) 273 if (!info->screen_base)
241 return -ENOMEM; 274 return -ENOMEM;
242 275
243 /* Set the 16MB aligned base address of the graphics memory region 276 /* Set the 16MiB aligned base address of the graphics memory region
244 * in the display controller */ 277 * in the display controller */
245 278
246 writel(info->fix.smem_start & 0xFF000000, 279 write_dc(par, DC_GLIU0_MEM_OFFSET, info->fix.smem_start & 0xFF000000);
247 par->dc_regs + DC_GLIU0_MEM_OFFSET);
248 280
249 dev_info(&dev->dev, "%d Kibyte of video memory at 0x%lx\n", 281 dev_info(&dev->dev, "%d KiB of video memory at 0x%lx\n",
250 info->fix.smem_len / 1024, info->fix.smem_start); 282 info->fix.smem_len / 1024, info->fix.smem_start);
251 283
252 return 0; 284 return 0;
@@ -266,11 +298,12 @@ static struct fb_ops gxfb_ops = {
266 298
267static struct fb_info * __init gxfb_init_fbinfo(struct device *dev) 299static struct fb_info * __init gxfb_init_fbinfo(struct device *dev)
268{ 300{
269 struct geodefb_par *par; 301 struct gxfb_par *par;
270 struct fb_info *info; 302 struct fb_info *info;
271 303
272 /* Alloc enough space for the pseudo palette. */ 304 /* Alloc enough space for the pseudo palette. */
273 info = framebuffer_alloc(sizeof(struct geodefb_par) + sizeof(u32) * 16, dev); 305 info = framebuffer_alloc(sizeof(struct gxfb_par) + sizeof(u32) * 16,
306 dev);
274 if (!info) 307 if (!info)
275 return NULL; 308 return NULL;
276 309
@@ -296,29 +329,64 @@ static struct fb_info * __init gxfb_init_fbinfo(struct device *dev)
296 info->flags = FBINFO_DEFAULT; 329 info->flags = FBINFO_DEFAULT;
297 info->node = -1; 330 info->node = -1;
298 331
299 info->pseudo_palette = (void *)par + sizeof(struct geodefb_par); 332 info->pseudo_palette = (void *)par + sizeof(struct gxfb_par);
300 333
301 info->var.grayscale = 0; 334 info->var.grayscale = 0;
302 335
303 return info; 336 return info;
304} 337}
305 338
339#ifdef CONFIG_PM
340static int gxfb_suspend(struct pci_dev *pdev, pm_message_t state)
341{
342 struct fb_info *info = pci_get_drvdata(pdev);
343
344 if (state.event == PM_EVENT_SUSPEND) {
345 acquire_console_sem();
346 gx_powerdown(info);
347 fb_set_suspend(info, 1);
348 release_console_sem();
349 }
350
351 /* there's no point in setting PCI states; we emulate PCI, so
352 * we don't end up getting power savings anyways */
353
354 return 0;
355}
356
357static int gxfb_resume(struct pci_dev *pdev)
358{
359 struct fb_info *info = pci_get_drvdata(pdev);
360 int ret;
361
362 acquire_console_sem();
363 ret = gx_powerup(info);
364 if (ret) {
365 printk(KERN_ERR "gxfb: power up failed!\n");
366 return ret;
367 }
368
369 fb_set_suspend(info, 0);
370 release_console_sem();
371 return 0;
372}
373#endif
374
306static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) 375static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
307{ 376{
308 struct geodefb_par *par; 377 struct gxfb_par *par;
309 struct fb_info *info; 378 struct fb_info *info;
310 int ret; 379 int ret;
311 unsigned long val; 380 unsigned long val;
312 381
382 struct fb_videomode *modedb_ptr;
383 unsigned int modedb_size;
384
313 info = gxfb_init_fbinfo(&pdev->dev); 385 info = gxfb_init_fbinfo(&pdev->dev);
314 if (!info) 386 if (!info)
315 return -ENOMEM; 387 return -ENOMEM;
316 par = info->par; 388 par = info->par;
317 389
318 /* GX display controller and GX video device. */
319 par->dc_ops = &gx_dc_ops;
320 par->vid_ops = &gx_vid_ops;
321
322 if ((ret = gxfb_map_video_memory(info, pdev)) < 0) { 390 if ((ret = gxfb_map_video_memory(info, pdev)) < 0) {
323 dev_err(&pdev->dev, "failed to map frame buffer or controller registers\n"); 391 dev_err(&pdev->dev, "failed to map frame buffer or controller registers\n");
324 goto err; 392 goto err;
@@ -326,15 +394,16 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
326 394
327 /* Figure out if this is a TFT or CRT part */ 395 /* Figure out if this is a TFT or CRT part */
328 396
329 rdmsrl(GLD_MSR_CONFIG, val); 397 rdmsrl(MSR_GX_GLD_MSR_CONFIG, val);
330 398
331 if ((val & GLD_MSR_CONFIG_DM_FP) == GLD_MSR_CONFIG_DM_FP) 399 if ((val & MSR_GX_GLD_MSR_CONFIG_FP) == MSR_GX_GLD_MSR_CONFIG_FP)
332 par->enable_crt = 0; 400 par->enable_crt = 0;
333 else 401 else
334 par->enable_crt = 1; 402 par->enable_crt = 1;
335 403
404 get_modedb(&modedb_ptr, &modedb_size);
336 ret = fb_find_mode(&info->var, info, mode_option, 405 ret = fb_find_mode(&info->var, info, mode_option,
337 gx_modedb, ARRAY_SIZE(gx_modedb), NULL, 16); 406 modedb_ptr, modedb_size, NULL, 16);
338 if (ret == 0 || ret == 4) { 407 if (ret == 0 || ret == 4) {
339 dev_err(&pdev->dev, "could not find valid video mode\n"); 408 dev_err(&pdev->dev, "could not find valid video mode\n");
340 ret = -EINVAL; 409 ret = -EINVAL;
@@ -348,6 +417,8 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
348 gxfb_check_var(&info->var, info); 417 gxfb_check_var(&info->var, info);
349 gxfb_set_par(info); 418 gxfb_set_par(info);
350 419
420 pm_set_vt_switch(vt_switch);
421
351 if (register_framebuffer(info) < 0) { 422 if (register_framebuffer(info) < 0) {
352 ret = -EINVAL; 423 ret = -EINVAL;
353 goto err; 424 goto err;
@@ -369,6 +440,10 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
369 iounmap(par->dc_regs); 440 iounmap(par->dc_regs);
370 pci_release_region(pdev, 2); 441 pci_release_region(pdev, 2);
371 } 442 }
443 if (par->gp_regs) {
444 iounmap(par->gp_regs);
445 pci_release_region(pdev, 1);
446 }
372 447
373 if (info) 448 if (info)
374 framebuffer_release(info); 449 framebuffer_release(info);
@@ -378,7 +453,7 @@ static int __init gxfb_probe(struct pci_dev *pdev, const struct pci_device_id *i
378static void gxfb_remove(struct pci_dev *pdev) 453static void gxfb_remove(struct pci_dev *pdev)
379{ 454{
380 struct fb_info *info = pci_get_drvdata(pdev); 455 struct fb_info *info = pci_get_drvdata(pdev);
381 struct geodefb_par *par = info->par; 456 struct gxfb_par *par = info->par;
382 457
383 unregister_framebuffer(info); 458 unregister_framebuffer(info);
384 459
@@ -391,15 +466,16 @@ static void gxfb_remove(struct pci_dev *pdev)
391 iounmap(par->dc_regs); 466 iounmap(par->dc_regs);
392 pci_release_region(pdev, 2); 467 pci_release_region(pdev, 2);
393 468
469 iounmap(par->gp_regs);
470 pci_release_region(pdev, 1);
471
394 pci_set_drvdata(pdev, NULL); 472 pci_set_drvdata(pdev, NULL);
395 473
396 framebuffer_release(info); 474 framebuffer_release(info);
397} 475}
398 476
399static struct pci_device_id gxfb_id_table[] = { 477static struct pci_device_id gxfb_id_table[] = {
400 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO, 478 { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_GX_VIDEO) },
401 PCI_ANY_ID, PCI_ANY_ID, PCI_BASE_CLASS_DISPLAY << 16,
402 0xff0000, 0 },
403 { 0, } 479 { 0, }
404}; 480};
405 481
@@ -410,6 +486,10 @@ static struct pci_driver gxfb_driver = {
410 .id_table = gxfb_id_table, 486 .id_table = gxfb_id_table,
411 .probe = gxfb_probe, 487 .probe = gxfb_probe,
412 .remove = gxfb_remove, 488 .remove = gxfb_remove,
489#ifdef CONFIG_PM
490 .suspend = gxfb_suspend,
491 .resume = gxfb_resume,
492#endif
413}; 493};
414 494
415#ifndef MODULE 495#ifndef MODULE
@@ -456,5 +536,11 @@ module_exit(gxfb_cleanup);
456module_param(mode_option, charp, 0); 536module_param(mode_option, charp, 0);
457MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])"); 537MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])");
458 538
539module_param(vram, int, 0);
540MODULE_PARM_DESC(vram, "video memory size");
541
542module_param(vt_switch, int, 0);
543MODULE_PARM_DESC(vt_switch, "enable VT switch during suspend/resume");
544
459MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode GX"); 545MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode GX");
460MODULE_LICENSE("GPL"); 546MODULE_LICENSE("GPL");
diff --git a/drivers/video/geode/lxfb.h b/drivers/video/geode/lxfb.h
index ca13c48d19b0..3b9416f4ee20 100644
--- a/drivers/video/geode/lxfb.h
+++ b/drivers/video/geode/lxfb.h
@@ -3,17 +3,46 @@
3 3
4#include <linux/fb.h> 4#include <linux/fb.h>
5 5
6#define GP_REG_COUNT (0x7c / 4)
7#define DC_REG_COUNT (0xf0 / 4)
8#define VP_REG_COUNT (0x158 / 8)
9#define FP_REG_COUNT (0x60 / 8)
10
11#define DC_PAL_COUNT 0x104
12#define DC_HFILT_COUNT 0x100
13#define DC_VFILT_COUNT 0x100
14#define VP_COEFF_SIZE 0x1000
15
6#define OUTPUT_CRT 0x01 16#define OUTPUT_CRT 0x01
7#define OUTPUT_PANEL 0x02 17#define OUTPUT_PANEL 0x02
8 18
9struct lxfb_par { 19struct lxfb_par {
10 int output; 20 int output;
11 int panel_width;
12 int panel_height;
13 21
14 void __iomem *gp_regs; 22 void __iomem *gp_regs;
15 void __iomem *dc_regs; 23 void __iomem *dc_regs;
16 void __iomem *df_regs; 24 void __iomem *vp_regs;
25#ifdef CONFIG_PM
26 int powered_down;
27
28 /* register state, for power mgmt functionality */
29 struct {
30 uint64_t padsel;
31 uint64_t dotpll;
32 uint64_t dfglcfg;
33 uint64_t dcspare;
34 } msr;
35
36 uint32_t gp[GP_REG_COUNT];
37 uint32_t dc[DC_REG_COUNT];
38 uint64_t vp[VP_REG_COUNT];
39 uint64_t fp[FP_REG_COUNT];
40
41 uint32_t pal[DC_PAL_COUNT];
42 uint32_t hcoeff[DC_HFILT_COUNT * 2];
43 uint32_t vcoeff[DC_VFILT_COUNT];
44 uint32_t vp_coeff[VP_COEFF_SIZE / 4];
45#endif
17}; 46};
18 47
19static inline unsigned int lx_get_pitch(unsigned int xres, int bpp) 48static inline unsigned int lx_get_pitch(unsigned int xres, int bpp)
@@ -29,171 +58,383 @@ int lx_blank_display(struct fb_info *, int);
29void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int, 58void lx_set_palette_reg(struct fb_info *, unsigned int, unsigned int,
30 unsigned int, unsigned int); 59 unsigned int, unsigned int);
31 60
32/* MSRS */ 61#ifdef CONFIG_PM
62int lx_powerdown(struct fb_info *info);
63int lx_powerup(struct fb_info *info);
64#endif
65
66
67/* Graphics Processor registers (table 6-29 from the data book) */
68enum gp_registers {
69 GP_DST_OFFSET = 0,
70 GP_SRC_OFFSET,
71 GP_STRIDE,
72 GP_WID_HEIGHT,
73
74 GP_SRC_COLOR_FG,
75 GP_SRC_COLOR_BG,
76 GP_PAT_COLOR_0,
77 GP_PAT_COLOR_1,
78
79 GP_PAT_COLOR_2,
80 GP_PAT_COLOR_3,
81 GP_PAT_COLOR_4,
82 GP_PAT_COLOR_5,
83
84 GP_PAT_DATA_0,
85 GP_PAT_DATA_1,
86 GP_RASTER_MODE,
87 GP_VECTOR_MODE,
88
89 GP_BLT_MODE,
90 GP_BLT_STATUS,
91 GP_HST_SRC,
92 GP_BASE_OFFSET,
93
94 GP_CMD_TOP,
95 GP_CMD_BOT,
96 GP_CMD_READ,
97 GP_CMD_WRITE,
98
99 GP_CH3_OFFSET,
100 GP_CH3_MODE_STR,
101 GP_CH3_WIDHI,
102 GP_CH3_HSRC,
103
104 GP_LUT_INDEX,
105 GP_LUT_DATA,
106 GP_INT_CNTRL, /* 0x78 */
107};
108
109#define GP_BLT_STATUS_CE (1 << 4) /* cmd buf empty */
110#define GP_BLT_STATUS_PB (1 << 0) /* primative busy */
111
112
113/* Display Controller registers (table 6-47 from the data book) */
114enum dc_registers {
115 DC_UNLOCK = 0,
116 DC_GENERAL_CFG,
117 DC_DISPLAY_CFG,
118 DC_ARB_CFG,
119
120 DC_FB_ST_OFFSET,
121 DC_CB_ST_OFFSET,
122 DC_CURS_ST_OFFSET,
123 DC_RSVD_0,
124
125 DC_VID_Y_ST_OFFSET,
126 DC_VID_U_ST_OFFSET,
127 DC_VID_V_ST_OFFSET,
128 DC_DV_TOP,
129
130 DC_LINE_SIZE,
131 DC_GFX_PITCH,
132 DC_VID_YUV_PITCH,
133 DC_RSVD_1,
134
135 DC_H_ACTIVE_TIMING,
136 DC_H_BLANK_TIMING,
137 DC_H_SYNC_TIMING,
138 DC_RSVD_2,
139
140 DC_V_ACTIVE_TIMING,
141 DC_V_BLANK_TIMING,
142 DC_V_SYNC_TIMING,
143 DC_FB_ACTIVE,
144
145 DC_CURSOR_X,
146 DC_CURSOR_Y,
147 DC_RSVD_3,
148 DC_LINE_CNT,
149
150 DC_PAL_ADDRESS,
151 DC_PAL_DATA,
152 DC_DFIFO_DIAG,
153 DC_CFIFO_DIAG,
154
155 DC_VID_DS_DELTA,
156 DC_GLIU0_MEM_OFFSET,
157 DC_DV_CTL,
158 DC_DV_ACCESS,
159
160 DC_GFX_SCALE,
161 DC_IRQ_FILT_CTL,
162 DC_FILT_COEFF1,
163 DC_FILT_COEFF2,
164
165 DC_VBI_EVEN_CTL,
166 DC_VBI_ODD_CTL,
167 DC_VBI_HOR,
168 DC_VBI_LN_ODD,
169
170 DC_VBI_LN_EVEN,
171 DC_VBI_PITCH,
172 DC_CLR_KEY,
173 DC_CLR_KEY_MASK,
174
175 DC_CLR_KEY_X,
176 DC_CLR_KEY_Y,
177 DC_IRQ,
178 DC_RSVD_4,
179
180 DC_RSVD_5,
181 DC_GENLK_CTL,
182 DC_VID_EVEN_Y_ST_OFFSET,
183 DC_VID_EVEN_U_ST_OFFSET,
184
185 DC_VID_EVEN_V_ST_OFFSET,
186 DC_V_ACTIVE_EVEN_TIMING,
187 DC_V_BLANK_EVEN_TIMING,
188 DC_V_SYNC_EVEN_TIMING, /* 0xec */
189};
190
191#define DC_UNLOCK_LOCK 0x00000000
192#define DC_UNLOCK_UNLOCK 0x00004758 /* magic value */
193
194#define DC_GENERAL_CFG_FDTY (1 << 17)
195#define DC_GENERAL_CFG_DFHPEL_SHIFT (12)
196#define DC_GENERAL_CFG_DFHPSL_SHIFT (8)
197#define DC_GENERAL_CFG_VGAE (1 << 7)
198#define DC_GENERAL_CFG_DECE (1 << 6)
199#define DC_GENERAL_CFG_CMPE (1 << 5)
200#define DC_GENERAL_CFG_VIDE (1 << 3)
201#define DC_GENERAL_CFG_DFLE (1 << 0)
202
203#define DC_DISPLAY_CFG_VISL (1 << 27)
204#define DC_DISPLAY_CFG_PALB (1 << 25)
205#define DC_DISPLAY_CFG_DCEN (1 << 24)
206#define DC_DISPLAY_CFG_DISP_MODE_24BPP (1 << 9)
207#define DC_DISPLAY_CFG_DISP_MODE_16BPP (1 << 8)
208#define DC_DISPLAY_CFG_DISP_MODE_8BPP (0)
209#define DC_DISPLAY_CFG_TRUP (1 << 6)
210#define DC_DISPLAY_CFG_VDEN (1 << 4)
211#define DC_DISPLAY_CFG_GDEN (1 << 3)
212#define DC_DISPLAY_CFG_TGEN (1 << 0)
213
214#define DC_DV_TOP_DV_TOP_EN (1 << 0)
215
216#define DC_DV_CTL_DV_LINE_SIZE ((1 << 10) | (1 << 11))
217#define DC_DV_CTL_DV_LINE_SIZE_1K (0)
218#define DC_DV_CTL_DV_LINE_SIZE_2K (1 << 10)
219#define DC_DV_CTL_DV_LINE_SIZE_4K (1 << 11)
220#define DC_DV_CTL_DV_LINE_SIZE_8K ((1 << 10) | (1 << 11))
221#define DC_DV_CTL_CLEAR_DV_RAM (1 << 0)
222
223#define DC_IRQ_FILT_CTL_H_FILT_SEL (1 << 10)
224
225#define DC_CLR_KEY_CLR_KEY_EN (1 << 24)
226
227#define DC_IRQ_VIP_VSYNC_IRQ_STATUS (1 << 21) /* undocumented? */
228#define DC_IRQ_STATUS (1 << 20) /* undocumented? */
229#define DC_IRQ_VIP_VSYNC_LOSS_IRQ_MASK (1 << 1)
230#define DC_IRQ_MASK (1 << 0)
33 231
34#define MSR_LX_GLD_CONFIG 0x48002001 232#define DC_GENLK_CTL_FLICK_SEL_MASK (0x0F << 28)
35#define MSR_LX_GLCP_DOTPLL 0x4c000015 233#define DC_GENLK_CTL_ALPHA_FLICK_EN (1 << 25)
36#define MSR_LX_DF_PADSEL 0x48002011 234#define DC_GENLK_CTL_FLICK_EN (1 << 24)
37#define MSR_LX_DC_SPARE 0x80000011 235#define DC_GENLK_CTL_GENLK_EN (1 << 18)
38#define MSR_LX_DF_GLCONFIG 0x48002001
39
40#define MSR_LX_GLIU0_P2D_RO0 0x10000029
41
42#define GLCP_DOTPLL_RESET (1 << 0)
43#define GLCP_DOTPLL_BYPASS (1 << 15)
44#define GLCP_DOTPLL_HALFPIX (1 << 24)
45#define GLCP_DOTPLL_LOCK (1 << 25)
46
47#define DF_CONFIG_OUTPUT_MASK 0x38
48#define DF_OUTPUT_PANEL 0x08
49#define DF_OUTPUT_CRT 0x00
50#define DF_SIMULTANEOUS_CRT_AND_FP (1 << 15)
51
52#define DF_DEFAULT_TFT_PAD_SEL_LOW 0xDFFFFFFF
53#define DF_DEFAULT_TFT_PAD_SEL_HIGH 0x0000003F
54
55#define DC_SPARE_DISABLE_CFIFO_HGO 0x00000800
56#define DC_SPARE_VFIFO_ARB_SELECT 0x00000400
57#define DC_SPARE_WM_LPEN_OVRD 0x00000200
58#define DC_SPARE_LOAD_WM_LPEN_MASK 0x00000100
59#define DC_SPARE_DISABLE_INIT_VID_PRI 0x00000080
60#define DC_SPARE_DISABLE_VFIFO_WM 0x00000040
61#define DC_SPARE_DISABLE_CWD_CHECK 0x00000020
62#define DC_SPARE_PIX8_PAN_FIX 0x00000010
63#define DC_SPARE_FIRST_REQ_MASK 0x00000002
64
65/* Registers */
66
67#define DC_UNLOCK 0x00
68#define DC_UNLOCK_CODE 0x4758
69 236
70#define DC_GENERAL_CFG 0x04
71#define DC_GCFG_DFLE (1 << 0)
72#define DC_GCFG_VIDE (1 << 3)
73#define DC_GCFG_VGAE (1 << 7)
74#define DC_GCFG_CMPE (1 << 5)
75#define DC_GCFG_DECE (1 << 6)
76#define DC_GCFG_FDTY (1 << 17)
77 237
78#define DC_DISPLAY_CFG 0x08 238/*
79#define DC_DCFG_TGEN (1 << 0) 239 * Video Processor registers (table 6-71).
80#define DC_DCFG_GDEN (1 << 3) 240 * There is space for 64 bit values, but we never use more than the
81#define DC_DCFG_VDEN (1 << 4) 241 * lower 32 bits. The actual register save/restore code only bothers
82#define DC_DCFG_TRUP (1 << 6) 242 * to restore those 32 bits.
83#define DC_DCFG_DCEN (1 << 24) 243 */
84#define DC_DCFG_PALB (1 << 25) 244enum vp_registers {
85#define DC_DCFG_VISL (1 << 27) 245 VP_VCFG = 0,
246 VP_DCFG,
86 247
87#define DC_DCFG_16BPP 0x0 248 VP_VX,
249 VP_VY,
88 250
89#define DC_DCFG_DISP_MODE_MASK 0x00000300 251 VP_SCL,
90#define DC_DCFG_DISP_MODE_8BPP 0x00000000 252 VP_VCK,
91#define DC_DCFG_DISP_MODE_16BPP 0x00000100
92#define DC_DCFG_DISP_MODE_24BPP 0x00000200
93#define DC_DCFG_DISP_MODE_32BPP 0x00000300
94 253
254 VP_VCM,
255 VP_PAR,
95 256
96#define DC_ARB_CFG 0x0C 257 VP_PDR,
258 VP_SLR,
97 259
98#define DC_FB_START 0x10 260 VP_MISC,
99#define DC_CB_START 0x14 261 VP_CCS,
100#define DC_CURSOR_START 0x18
101 262
102#define DC_DV_TOP 0x2C 263 VP_VYS,
103#define DC_DV_TOP_ENABLE (1 << 0) 264 VP_VXS,
104 265
105#define DC_LINE_SIZE 0x30 266 VP_RSVD_0,
106#define DC_GRAPHICS_PITCH 0x34 267 VP_VDC,
107#define DC_H_ACTIVE_TIMING 0x40 268
108#define DC_H_BLANK_TIMING 0x44 269 VP_RSVD_1,
109#define DC_H_SYNC_TIMING 0x48 270 VP_CRC,
110#define DC_V_ACTIVE_TIMING 0x50 271
111#define DC_V_BLANK_TIMING 0x54 272 VP_CRC32,
112#define DC_V_SYNC_TIMING 0x58 273 VP_VDE,
113#define DC_FB_ACTIVE 0x5C 274
275 VP_CCK,
276 VP_CCM,
277
278 VP_CC1,
279 VP_CC2,
280
281 VP_A1X,
282 VP_A1Y,
283
284 VP_A1C,
285 VP_A1T,
286
287 VP_A2X,
288 VP_A2Y,
289
290 VP_A2C,
291 VP_A2T,
292
293 VP_A3X,
294 VP_A3Y,
295
296 VP_A3C,
297 VP_A3T,
298
299 VP_VRR,
300 VP_AWT,
301
302 VP_VTM,
303 VP_VYE,
304
305 VP_A1YE,
306 VP_A2YE,
307
308 VP_A3YE, /* 0x150 */
309
310 VP_VCR = 0x1000, /* 0x1000 - 0x1fff */
311};
114 312
115#define DC_PAL_ADDRESS 0x70 313#define VP_VCFG_VID_EN (1 << 0)
116#define DC_PAL_DATA 0x74
117 314
118#define DC_PHY_MEM_OFFSET 0x84 315#define VP_DCFG_GV_GAM (1 << 21)
316#define VP_DCFG_PWR_SEQ_DELAY ((1 << 17) | (1 << 18) | (1 << 19))
317#define VP_DCFG_PWR_SEQ_DELAY_DEFAULT (1 << 19) /* undocumented */
318#define VP_DCFG_CRT_SYNC_SKW ((1 << 14) | (1 << 15) | (1 << 16))
319#define VP_DCFG_CRT_SYNC_SKW_DEFAULT (1 << 16)
320#define VP_DCFG_CRT_VSYNC_POL (1 << 9)
321#define VP_DCFG_CRT_HSYNC_POL (1 << 8)
322#define VP_DCFG_DAC_BL_EN (1 << 3)
323#define VP_DCFG_VSYNC_EN (1 << 2)
324#define VP_DCFG_HSYNC_EN (1 << 1)
325#define VP_DCFG_CRT_EN (1 << 0)
119 326
120#define DC_DV_CTL 0x88 327#define VP_MISC_APWRDN (1 << 11)
121#define DC_DV_LINE_SIZE_MASK 0x00000C00 328#define VP_MISC_DACPWRDN (1 << 10)
122#define DC_DV_LINE_SIZE_1024 0x00000000 329#define VP_MISC_BYP_BOTH (1 << 0)
123#define DC_DV_LINE_SIZE_2048 0x00000400
124#define DC_DV_LINE_SIZE_4096 0x00000800
125#define DC_DV_LINE_SIZE_8192 0x00000C00
126 330
127 331
128#define DC_GFX_SCALE 0x90 332/*
129#define DC_IRQ_FILT_CTL 0x94 333 * Flat Panel registers (table 6-71).
334 * Also 64 bit registers; see above note about 32-bit handling.
335 */
130 336
337/* we're actually in the VP register space, starting at address 0x400 */
338#define VP_FP_START 0x400
131 339
132#define DC_IRQ 0xC8 340enum fp_registers {
133#define DC_IRQ_MASK (1 << 0) 341 FP_PT1 = 0,
134#define DC_VSYNC_IRQ_MASK (1 << 1) 342 FP_PT2,
135#define DC_IRQ_STATUS (1 << 20)
136#define DC_VSYNC_IRQ_STATUS (1 << 21)
137
138#define DC_GENLCK_CTRL 0xD4
139#define DC_GENLCK_ENABLE (1 << 18)
140#define DC_GC_ALPHA_FLICK_ENABLE (1 << 25)
141#define DC_GC_FLICKER_FILTER_ENABLE (1 << 24)
142#define DC_GC_FLICKER_FILTER_MASK (0x0F << 28)
143
144#define DC_COLOR_KEY 0xB8
145#define DC_CLR_KEY_ENABLE (1 << 24)
146
147
148#define DC3_DV_LINE_SIZE_MASK 0x00000C00
149#define DC3_DV_LINE_SIZE_1024 0x00000000
150#define DC3_DV_LINE_SIZE_2048 0x00000400
151#define DC3_DV_LINE_SIZE_4096 0x00000800
152#define DC3_DV_LINE_SIZE_8192 0x00000C00
153
154#define DF_VIDEO_CFG 0x0
155#define DF_VCFG_VID_EN (1 << 0)
156
157#define DF_DISPLAY_CFG 0x08
158
159#define DF_DCFG_CRT_EN (1 << 0)
160#define DF_DCFG_HSYNC_EN (1 << 1)
161#define DF_DCFG_VSYNC_EN (1 << 2)
162#define DF_DCFG_DAC_BL_EN (1 << 3)
163#define DF_DCFG_CRT_HSYNC_POL (1 << 8)
164#define DF_DCFG_CRT_VSYNC_POL (1 << 9)
165#define DF_DCFG_GV_PAL_BYP (1 << 21)
166 343
167#define DF_DCFG_CRT_SYNC_SKW_INIT 0x10000 344 FP_PM,
168#define DF_DCFG_CRT_SYNC_SKW_MASK 0x1c000 345 FP_DFC,
169 346
170#define DF_DCFG_PWR_SEQ_DLY_INIT 0x80000 347 FP_RSVD_0,
171#define DF_DCFG_PWR_SEQ_DLY_MASK 0xe0000 348 FP_RSVD_1,
172 349
173#define DF_MISC 0x50 350 FP_RSVD_2,
351 FP_RSVD_3,
352
353 FP_RSVD_4,
354 FP_DCA,
355
356 FP_DMD,
357 FP_CRC, /* 0x458 */
358};
359
360#define FP_PT2_SCRC (1 << 27) /* shfclk free */
361
362#define FP_PM_P (1 << 24) /* panel power ctl */
363#define FP_PM_PANEL_PWR_UP (1 << 3) /* r/o */
364#define FP_PM_PANEL_PWR_DOWN (1 << 2) /* r/o */
365#define FP_PM_PANEL_OFF (1 << 1) /* r/o */
366#define FP_PM_PANEL_ON (1 << 0) /* r/o */
367
368#define FP_DFC_BC ((1 << 4) | (1 << 5) | (1 << 6))
369
370
371/* register access functions */
372
373static inline uint32_t read_gp(struct lxfb_par *par, int reg)
374{
375 return readl(par->gp_regs + 4*reg);
376}
377
378static inline void write_gp(struct lxfb_par *par, int reg, uint32_t val)
379{
380 writel(val, par->gp_regs + 4*reg);
381}
382
383static inline uint32_t read_dc(struct lxfb_par *par, int reg)
384{
385 return readl(par->dc_regs + 4*reg);
386}
387
388static inline void write_dc(struct lxfb_par *par, int reg, uint32_t val)
389{
390 writel(val, par->dc_regs + 4*reg);
391}
392
393static inline uint32_t read_vp(struct lxfb_par *par, int reg)
394{
395 return readl(par->vp_regs + 8*reg);
396}
397
398static inline void write_vp(struct lxfb_par *par, int reg, uint32_t val)
399{
400 writel(val, par->vp_regs + 8*reg);
401}
402
403static inline uint32_t read_fp(struct lxfb_par *par, int reg)
404{
405 return readl(par->vp_regs + 8*reg + VP_FP_START);
406}
407
408static inline void write_fp(struct lxfb_par *par, int reg, uint32_t val)
409{
410 writel(val, par->vp_regs + 8*reg + VP_FP_START);
411}
174 412
175#define DF_MISC_GAM_BYPASS (1 << 0)
176#define DF_MISC_DAC_PWRDN (1 << 10)
177#define DF_MISC_A_PWRDN (1 << 11)
178 413
179#define DF_PAR 0x38 414/* MSRs are defined in asm/geode.h; their bitfields are here */
180#define DF_PDR 0x40
181#define DF_ALPHA_CONTROL_1 0xD8
182#define DF_VIDEO_REQUEST 0x120
183 415
184#define DF_PANEL_TIM1 0x400 416#define MSR_GLCP_DOTPLL_LOCK (1 << 25) /* r/o */
185#define DF_DEFAULT_TFT_PMTIM1 0x0 417#define MSR_GLCP_DOTPLL_HALFPIX (1 << 24)
418#define MSR_GLCP_DOTPLL_BYPASS (1 << 15)
419#define MSR_GLCP_DOTPLL_DOTRESET (1 << 0)
186 420
187#define DF_PANEL_TIM2 0x408 421/* note: this is actually the VP's GLD_MSR_CONFIG */
188#define DF_DEFAULT_TFT_PMTIM2 0x08000000 422#define MSR_LX_GLD_MSR_CONFIG_FMT ((1 << 3) | (1 << 4) | (1 << 5))
423#define MSR_LX_GLD_MSR_CONFIG_FMT_FP (1 << 3)
424#define MSR_LX_GLD_MSR_CONFIG_FMT_CRT (0)
425#define MSR_LX_GLD_MSR_CONFIG_FPC (1 << 15) /* FP *and* CRT */
189 426
190#define DF_FP_PM 0x410 427#define MSR_LX_MSR_PADSEL_TFT_SEL_LOW 0xDFFFFFFF /* ??? */
191#define DF_FP_PM_P (1 << 24) 428#define MSR_LX_MSR_PADSEL_TFT_SEL_HIGH 0x0000003F /* ??? */
192 429
193#define DF_DITHER_CONTROL 0x418 430#define MSR_LX_SPARE_MSR_DIS_CFIFO_HGO (1 << 11) /* undocumented */
194#define DF_DEFAULT_TFT_DITHCTL 0x00000070 431#define MSR_LX_SPARE_MSR_VFIFO_ARB_SEL (1 << 10) /* undocumented */
195#define GP_BLT_STATUS 0x44 432#define MSR_LX_SPARE_MSR_WM_LPEN_OVRD (1 << 9) /* undocumented */
196#define GP_BS_BLT_BUSY (1 << 0) 433#define MSR_LX_SPARE_MSR_LOAD_WM_LPEN_M (1 << 8) /* undocumented */
197#define GP_BS_CB_EMPTY (1 << 4) 434#define MSR_LX_SPARE_MSR_DIS_INIT_V_PRI (1 << 7) /* undocumented */
435#define MSR_LX_SPARE_MSR_DIS_VIFO_WM (1 << 6)
436#define MSR_LX_SPARE_MSR_DIS_CWD_CHECK (1 << 5) /* undocumented */
437#define MSR_LX_SPARE_MSR_PIX8_PAN_FIX (1 << 4) /* undocumented */
438#define MSR_LX_SPARE_MSR_FIRST_REQ_MASK (1 << 1) /* undocumented */
198 439
199#endif 440#endif
diff --git a/drivers/video/geode/lxfb_core.c b/drivers/video/geode/lxfb_core.c
index eb6b88171538..2cd9b74d2225 100644
--- a/drivers/video/geode/lxfb_core.c
+++ b/drivers/video/geode/lxfb_core.c
@@ -17,6 +17,7 @@
17#include <linux/console.h> 17#include <linux/console.h>
18#include <linux/mm.h> 18#include <linux/mm.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/suspend.h>
20#include <linux/delay.h> 21#include <linux/delay.h>
21#include <linux/fb.h> 22#include <linux/fb.h>
22#include <linux/init.h> 23#include <linux/init.h>
@@ -27,14 +28,15 @@
27 28
28static char *mode_option; 29static char *mode_option;
29static int noclear, nopanel, nocrt; 30static int noclear, nopanel, nocrt;
30static int fbsize; 31static int vram;
32static int vt_switch;
31 33
32/* Most of these modes are sorted in ascending order, but 34/* Most of these modes are sorted in ascending order, but
33 * since the first entry in this table is the "default" mode, 35 * since the first entry in this table is the "default" mode,
34 * we try to make it something sane - 640x480-60 is sane 36 * we try to make it something sane - 640x480-60 is sane
35 */ 37 */
36 38
37static const struct fb_videomode geode_modedb[] __initdata = { 39static struct fb_videomode geode_modedb[] __initdata = {
38 /* 640x480-60 */ 40 /* 640x480-60 */
39 { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2, 41 { NULL, 60, 640, 480, 39682, 48, 8, 25, 2, 88, 2,
40 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, 42 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
@@ -215,6 +217,35 @@ static const struct fb_videomode geode_modedb[] __initdata = {
215 0, FB_VMODE_NONINTERLACED, 0 }, 217 0, FB_VMODE_NONINTERLACED, 0 },
216}; 218};
217 219
220#ifdef CONFIG_OLPC
221#include <asm/olpc.h>
222
223static struct fb_videomode olpc_dcon_modedb[] __initdata = {
224 /* The only mode the DCON has is 1200x900 */
225 { NULL, 50, 1200, 900, 17460, 24, 8, 4, 5, 8, 3,
226 FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
227 FB_VMODE_NONINTERLACED, 0 }
228};
229
230static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size)
231{
232 if (olpc_has_dcon()) {
233 *modedb = (struct fb_videomode *) olpc_dcon_modedb;
234 *size = ARRAY_SIZE(olpc_dcon_modedb);
235 } else {
236 *modedb = (struct fb_videomode *) geode_modedb;
237 *size = ARRAY_SIZE(geode_modedb);
238 }
239}
240
241#else
242static void __init get_modedb(struct fb_videomode **modedb, unsigned int *size)
243{
244 *modedb = (struct fb_videomode *) geode_modedb;
245 *size = ARRAY_SIZE(geode_modedb);
246}
247#endif
248
218static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) 249static int lxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
219{ 250{
220 if (var->xres > 1920 || var->yres > 1440) 251 if (var->xres > 1920 || var->yres > 1440)
@@ -333,13 +364,13 @@ static int __init lxfb_map_video_memory(struct fb_info *info,
333 if (ret) 364 if (ret)
334 return ret; 365 return ret;
335 366
336 ret = pci_request_region(dev, 3, "lxfb-vip"); 367 ret = pci_request_region(dev, 3, "lxfb-vp");
337 368
338 if (ret) 369 if (ret)
339 return ret; 370 return ret;
340 371
341 info->fix.smem_start = pci_resource_start(dev, 0); 372 info->fix.smem_start = pci_resource_start(dev, 0);
342 info->fix.smem_len = fbsize ? fbsize : lx_framebuffer_size(); 373 info->fix.smem_len = vram ? vram : lx_framebuffer_size();
343 374
344 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len); 375 info->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);
345 376
@@ -360,18 +391,15 @@ static int __init lxfb_map_video_memory(struct fb_info *info,
360 if (par->dc_regs == NULL) 391 if (par->dc_regs == NULL)
361 return ret; 392 return ret;
362 393
363 par->df_regs = ioremap(pci_resource_start(dev, 3), 394 par->vp_regs = ioremap(pci_resource_start(dev, 3),
364 pci_resource_len(dev, 3)); 395 pci_resource_len(dev, 3));
365 396
366 if (par->df_regs == NULL) 397 if (par->vp_regs == NULL)
367 return ret; 398 return ret;
368 399
369 writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK); 400 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
370 401 write_dc(par, DC_GLIU0_MEM_OFFSET, info->fix.smem_start & 0xFF000000);
371 writel(info->fix.smem_start & 0xFF000000, 402 write_dc(par, DC_UNLOCK, DC_UNLOCK_LOCK);
372 par->dc_regs + DC_PHY_MEM_OFFSET);
373
374 writel(0, par->dc_regs + DC_UNLOCK);
375 403
376 dev_info(&dev->dev, "%d KB of video memory at 0x%lx\n", 404 dev_info(&dev->dev, "%d KB of video memory at 0x%lx\n",
377 info->fix.smem_len / 1024, info->fix.smem_start); 405 info->fix.smem_len / 1024, info->fix.smem_start);
@@ -431,6 +459,45 @@ static struct fb_info * __init lxfb_init_fbinfo(struct device *dev)
431 return info; 459 return info;
432} 460}
433 461
462#ifdef CONFIG_PM
463static int lxfb_suspend(struct pci_dev *pdev, pm_message_t state)
464{
465 struct fb_info *info = pci_get_drvdata(pdev);
466
467 if (state.event == PM_EVENT_SUSPEND) {
468 acquire_console_sem();
469 lx_powerdown(info);
470 fb_set_suspend(info, 1);
471 release_console_sem();
472 }
473
474 /* there's no point in setting PCI states; we emulate PCI, so
475 * we don't end up getting power savings anyways */
476
477 return 0;
478}
479
480static int lxfb_resume(struct pci_dev *pdev)
481{
482 struct fb_info *info = pci_get_drvdata(pdev);
483 int ret;
484
485 acquire_console_sem();
486 ret = lx_powerup(info);
487 if (ret) {
488 printk(KERN_ERR "lxfb: power up failed!\n");
489 return ret;
490 }
491
492 fb_set_suspend(info, 0);
493 release_console_sem();
494 return 0;
495}
496#else
497#define lxfb_suspend NULL
498#define lxfb_resume NULL
499#endif
500
434static int __init lxfb_probe(struct pci_dev *pdev, 501static int __init lxfb_probe(struct pci_dev *pdev,
435 const struct pci_device_id *id) 502 const struct pci_device_id *id)
436{ 503{
@@ -439,7 +506,7 @@ static int __init lxfb_probe(struct pci_dev *pdev,
439 int ret; 506 int ret;
440 507
441 struct fb_videomode *modedb_ptr; 508 struct fb_videomode *modedb_ptr;
442 int modedb_size; 509 unsigned int modedb_size;
443 510
444 info = lxfb_init_fbinfo(&pdev->dev); 511 info = lxfb_init_fbinfo(&pdev->dev);
445 512
@@ -464,9 +531,7 @@ static int __init lxfb_probe(struct pci_dev *pdev,
464 531
465 /* Set up the mode database */ 532 /* Set up the mode database */
466 533
467 modedb_ptr = (struct fb_videomode *) geode_modedb; 534 get_modedb(&modedb_ptr, &modedb_size);
468 modedb_size = ARRAY_SIZE(geode_modedb);
469
470 ret = fb_find_mode(&info->var, info, mode_option, 535 ret = fb_find_mode(&info->var, info, mode_option,
471 modedb_ptr, modedb_size, NULL, 16); 536 modedb_ptr, modedb_size, NULL, 16);
472 537
@@ -487,6 +552,8 @@ static int __init lxfb_probe(struct pci_dev *pdev,
487 lxfb_check_var(&info->var, info); 552 lxfb_check_var(&info->var, info);
488 lxfb_set_par(info); 553 lxfb_set_par(info);
489 554
555 pm_set_vt_switch(vt_switch);
556
490 if (register_framebuffer(info) < 0) { 557 if (register_framebuffer(info) < 0) {
491 ret = -EINVAL; 558 ret = -EINVAL;
492 goto err; 559 goto err;
@@ -510,8 +577,8 @@ err:
510 iounmap(par->dc_regs); 577 iounmap(par->dc_regs);
511 pci_release_region(pdev, 2); 578 pci_release_region(pdev, 2);
512 } 579 }
513 if (par->df_regs) { 580 if (par->vp_regs) {
514 iounmap(par->df_regs); 581 iounmap(par->vp_regs);
515 pci_release_region(pdev, 3); 582 pci_release_region(pdev, 3);
516 } 583 }
517 584
@@ -537,7 +604,7 @@ static void lxfb_remove(struct pci_dev *pdev)
537 iounmap(par->dc_regs); 604 iounmap(par->dc_regs);
538 pci_release_region(pdev, 2); 605 pci_release_region(pdev, 2);
539 606
540 iounmap(par->df_regs); 607 iounmap(par->vp_regs);
541 pci_release_region(pdev, 3); 608 pci_release_region(pdev, 3);
542 609
543 pci_set_drvdata(pdev, NULL); 610 pci_set_drvdata(pdev, NULL);
@@ -556,6 +623,8 @@ static struct pci_driver lxfb_driver = {
556 .id_table = lxfb_id_table, 623 .id_table = lxfb_id_table,
557 .probe = lxfb_probe, 624 .probe = lxfb_probe,
558 .remove = lxfb_remove, 625 .remove = lxfb_remove,
626 .suspend = lxfb_suspend,
627 .resume = lxfb_resume,
559}; 628};
560 629
561#ifndef MODULE 630#ifndef MODULE
@@ -570,9 +639,7 @@ static int __init lxfb_setup(char *options)
570 if (!*opt) 639 if (!*opt)
571 continue; 640 continue;
572 641
573 if (!strncmp(opt, "fbsize:", 7)) 642 if (!strcmp(opt, "noclear"))
574 fbsize = simple_strtoul(opt+7, NULL, 0);
575 else if (!strcmp(opt, "noclear"))
576 noclear = 1; 643 noclear = 1;
577 else if (!strcmp(opt, "nopanel")) 644 else if (!strcmp(opt, "nopanel"))
578 nopanel = 1; 645 nopanel = 1;
@@ -609,8 +676,11 @@ module_exit(lxfb_cleanup);
609module_param(mode_option, charp, 0); 676module_param(mode_option, charp, 0);
610MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])"); 677MODULE_PARM_DESC(mode_option, "video mode (<x>x<y>[-<bpp>][@<refr>])");
611 678
612module_param(fbsize, int, 0); 679module_param(vram, int, 0);
613MODULE_PARM_DESC(fbsize, "video memory size"); 680MODULE_PARM_DESC(vram, "video memory size");
681
682module_param(vt_switch, int, 0);
683MODULE_PARM_DESC(vt_switch, "enable VT switch during suspend/resume");
614 684
615MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode LX"); 685MODULE_DESCRIPTION("Framebuffer driver for the AMD Geode LX");
616MODULE_LICENSE("GPL"); 686MODULE_LICENSE("GPL");
diff --git a/drivers/video/geode/lxfb_ops.c b/drivers/video/geode/lxfb_ops.c
index 4fbc99be96ef..cd9d4cc26954 100644
--- a/drivers/video/geode/lxfb_ops.c
+++ b/drivers/video/geode/lxfb_ops.c
@@ -13,6 +13,7 @@
13#include <linux/fb.h> 13#include <linux/fb.h>
14#include <linux/uaccess.h> 14#include <linux/uaccess.h>
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <asm/geode.h>
16 17
17#include "lxfb.h" 18#include "lxfb.h"
18 19
@@ -34,35 +35,85 @@ static const struct {
34 unsigned int pllval; 35 unsigned int pllval;
35 unsigned int freq; 36 unsigned int freq;
36} pll_table[] = { 37} pll_table[] = {
37 { 0x000031AC, 24923 }, 38 { 0x000131AC, 6231 },
38 { 0x0000215D, 25175 }, 39 { 0x0001215D, 6294 },
39 { 0x00001087, 27000 }, 40 { 0x00011087, 6750 },
40 { 0x0000216C, 28322 }, 41 { 0x0001216C, 7081 },
41 { 0x0000218D, 28560 }, 42 { 0x0001218D, 7140 },
42 { 0x000010C9, 31200 }, 43 { 0x000110C9, 7800 },
43 { 0x00003147, 31500 }, 44 { 0x00013147, 7875 },
44 { 0x000010A7, 33032 }, 45 { 0x000110A7, 8258 },
45 { 0x00002159, 35112 }, 46 { 0x00012159, 8778 },
46 { 0x00004249, 35500 }, 47 { 0x00014249, 8875 },
47 { 0x00000057, 36000 }, 48 { 0x00010057, 9000 },
48 { 0x0000219A, 37889 }, 49 { 0x0001219A, 9472 },
49 { 0x00002158, 39168 }, 50 { 0x00012158, 9792 },
50 { 0x00000045, 40000 }, 51 { 0x00010045, 10000 },
51 { 0x00000089, 43163 }, 52 { 0x00010089, 10791 },
52 { 0x000010E7, 44900 }, 53 { 0x000110E7, 11225 },
53 { 0x00002136, 45720 }, 54 { 0x00012136, 11430 },
54 { 0x00003207, 49500 }, 55 { 0x00013207, 12375 },
55 { 0x00002187, 50000 }, 56 { 0x00012187, 12500 },
56 { 0x00004286, 56250 }, 57 { 0x00014286, 14063 },
57 { 0x000010E5, 60065 }, 58 { 0x000110E5, 15016 },
58 { 0x00004214, 65000 }, 59 { 0x00014214, 16250 },
59 { 0x00001105, 68179 }, 60 { 0x00011105, 17045 },
60 { 0x000031E4, 74250 }, 61 { 0x000131E4, 18563 },
61 { 0x00003183, 75000 }, 62 { 0x00013183, 18750 },
62 { 0x00004284, 78750 }, 63 { 0x00014284, 19688 },
63 { 0x00001104, 81600 }, 64 { 0x00011104, 20400 },
64 { 0x00006363, 94500 }, 65 { 0x00016363, 23625 },
65 { 0x00005303, 97520 }, 66 { 0x00015303, 24380 },
67 { 0x000031AC, 24923 },
68 { 0x0000215D, 25175 },
69 { 0x00001087, 27000 },
70 { 0x0000216C, 28322 },
71 { 0x0000218D, 28560 },
72 { 0x00010041, 29913 },
73 { 0x000010C9, 31200 },
74 { 0x00003147, 31500 },
75 { 0x000141A1, 32400 },
76 { 0x000010A7, 33032 },
77 { 0x00012182, 33375 },
78 { 0x000141B1, 33750 },
79 { 0x00002159, 35112 },
80 { 0x00004249, 35500 },
81 { 0x00000057, 36000 },
82 { 0x000141E1, 37125 },
83 { 0x0000219A, 37889 },
84 { 0x00002158, 39168 },
85 { 0x00000045, 40000 },
86 { 0x000131A1, 40500 },
87 { 0x00010061, 42301 },
88 { 0x00000089, 43163 },
89 { 0x00012151, 43875 },
90 { 0x000010E7, 44900 },
91 { 0x00002136, 45720 },
92 { 0x000152E1, 47250 },
93 { 0x00010071, 48000 },
94 { 0x00003207, 49500 },
95 { 0x00002187, 50000 },
96 { 0x00014291, 50625 },
97 { 0x00011101, 51188 },
98 { 0x00017481, 54563 },
99 { 0x00004286, 56250 },
100 { 0x00014170, 57375 },
101 { 0x00016210, 58500 },
102 { 0x000010E5, 60065 },
103 { 0x00013140, 62796 },
104 { 0x00004214, 65000 },
105 { 0x00016250, 65250 },
106 { 0x00001105, 68179 },
107 { 0x000141C0, 69600 },
108 { 0x00015220, 70160 },
109 { 0x00010050, 72000 },
110 { 0x000031E4, 74250 },
111 { 0x00003183, 75000 },
112 { 0x00004284, 78750 },
113 { 0x00012130, 80052 },
114 { 0x00001104, 81600 },
115 { 0x00006363, 94500 },
116 { 0x00005303, 97520 },
66 { 0x00002183, 100187 }, 117 { 0x00002183, 100187 },
67 { 0x00002122, 101420 }, 118 { 0x00002122, 101420 },
68 { 0x00001081, 108000 }, 119 { 0x00001081, 108000 },
@@ -101,16 +152,16 @@ static void lx_set_dotpll(u32 pllval)
101 u32 dotpll_lo, dotpll_hi; 152 u32 dotpll_lo, dotpll_hi;
102 int i; 153 int i;
103 154
104 rdmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); 155 rdmsr(MSR_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
105 156
106 if ((dotpll_lo & GLCP_DOTPLL_LOCK) && (dotpll_hi == pllval)) 157 if ((dotpll_lo & MSR_GLCP_DOTPLL_LOCK) && (dotpll_hi == pllval))
107 return; 158 return;
108 159
109 dotpll_hi = pllval; 160 dotpll_hi = pllval;
110 dotpll_lo &= ~(GLCP_DOTPLL_BYPASS | GLCP_DOTPLL_HALFPIX); 161 dotpll_lo &= ~(MSR_GLCP_DOTPLL_BYPASS | MSR_GLCP_DOTPLL_HALFPIX);
111 dotpll_lo |= GLCP_DOTPLL_RESET; 162 dotpll_lo |= MSR_GLCP_DOTPLL_DOTRESET;
112 163
113 wrmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); 164 wrmsr(MSR_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
114 165
115 /* Wait 100us for the PLL to lock */ 166 /* Wait 100us for the PLL to lock */
116 167
@@ -119,15 +170,15 @@ static void lx_set_dotpll(u32 pllval)
119 /* Now, loop for the lock bit */ 170 /* Now, loop for the lock bit */
120 171
121 for (i = 0; i < 1000; i++) { 172 for (i = 0; i < 1000; i++) {
122 rdmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); 173 rdmsr(MSR_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
123 if (dotpll_lo & GLCP_DOTPLL_LOCK) 174 if (dotpll_lo & MSR_GLCP_DOTPLL_LOCK)
124 break; 175 break;
125 } 176 }
126 177
127 /* Clear the reset bit */ 178 /* Clear the reset bit */
128 179
129 dotpll_lo &= ~GLCP_DOTPLL_RESET; 180 dotpll_lo &= ~MSR_GLCP_DOTPLL_DOTRESET;
130 wrmsr(MSR_LX_GLCP_DOTPLL, dotpll_lo, dotpll_hi); 181 wrmsr(MSR_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
131} 182}
132 183
133/* Set the clock based on the frequency specified by the current mode */ 184/* Set the clock based on the frequency specified by the current mode */
@@ -137,7 +188,7 @@ static void lx_set_clock(struct fb_info *info)
137 unsigned int diff, min, best = 0; 188 unsigned int diff, min, best = 0;
138 unsigned int freq, i; 189 unsigned int freq, i;
139 190
140 freq = (unsigned int) (0x3b9aca00 / info->var.pixclock); 191 freq = (unsigned int) (1000000000 / info->var.pixclock);
141 192
142 min = abs(pll_table[0].freq - freq); 193 min = abs(pll_table[0].freq - freq);
143 194
@@ -149,7 +200,7 @@ static void lx_set_clock(struct fb_info *info)
149 } 200 }
150 } 201 }
151 202
152 lx_set_dotpll(pll_table[best].pllval & 0x7FFF); 203 lx_set_dotpll(pll_table[best].pllval & 0x00017FFF);
153} 204}
154 205
155static void lx_graphics_disable(struct fb_info *info) 206static void lx_graphics_disable(struct fb_info *info)
@@ -159,63 +210,62 @@ static void lx_graphics_disable(struct fb_info *info)
159 210
160 /* Note: This assumes that the video is in a quitet state */ 211 /* Note: This assumes that the video is in a quitet state */
161 212
162 writel(0, par->df_regs + DF_ALPHA_CONTROL_1); 213 write_vp(par, VP_A1T, 0);
163 writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 32); 214 write_vp(par, VP_A2T, 0);
164 writel(0, par->df_regs + DF_ALPHA_CONTROL_1 + 64); 215 write_vp(par, VP_A3T, 0);
165 216
166 /* Turn off the VGA and video enable */ 217 /* Turn off the VGA and video enable */
167 val = readl (par->dc_regs + DC_GENERAL_CFG) & 218 val = read_dc(par, DC_GENERAL_CFG) & ~(DC_GENERAL_CFG_VGAE |
168 ~(DC_GCFG_VGAE | DC_GCFG_VIDE); 219 DC_GENERAL_CFG_VIDE);
169 220
170 writel(val, par->dc_regs + DC_GENERAL_CFG); 221 write_dc(par, DC_GENERAL_CFG, val);
171 222
172 val = readl(par->df_regs + DF_VIDEO_CFG) & ~DF_VCFG_VID_EN; 223 val = read_vp(par, VP_VCFG) & ~VP_VCFG_VID_EN;
173 writel(val, par->df_regs + DF_VIDEO_CFG); 224 write_vp(par, VP_VCFG, val);
174 225
175 writel( DC_IRQ_MASK | DC_VSYNC_IRQ_MASK | 226 write_dc(par, DC_IRQ, DC_IRQ_MASK | DC_IRQ_VIP_VSYNC_LOSS_IRQ_MASK |
176 DC_IRQ_STATUS | DC_VSYNC_IRQ_STATUS, 227 DC_IRQ_STATUS | DC_IRQ_VIP_VSYNC_IRQ_STATUS);
177 par->dc_regs + DC_IRQ);
178 228
179 val = readl(par->dc_regs + DC_GENLCK_CTRL) & ~DC_GENLCK_ENABLE; 229 val = read_dc(par, DC_GENLK_CTL) & ~DC_GENLK_CTL_GENLK_EN;
180 writel(val, par->dc_regs + DC_GENLCK_CTRL); 230 write_dc(par, DC_GENLK_CTL, val);
181 231
182 val = readl(par->dc_regs + DC_COLOR_KEY) & ~DC_CLR_KEY_ENABLE; 232 val = read_dc(par, DC_CLR_KEY);
183 writel(val & ~DC_CLR_KEY_ENABLE, par->dc_regs + DC_COLOR_KEY); 233 write_dc(par, DC_CLR_KEY, val & ~DC_CLR_KEY_CLR_KEY_EN);
184 234
185 /* We don't actually blank the panel, due to the long latency 235 /* turn off the panel */
186 involved with bringing it back */ 236 write_fp(par, FP_PM, read_fp(par, FP_PM) & ~FP_PM_P);
187 237
188 val = readl(par->df_regs + DF_MISC) | DF_MISC_DAC_PWRDN; 238 val = read_vp(par, VP_MISC) | VP_MISC_DACPWRDN;
189 writel(val, par->df_regs + DF_MISC); 239 write_vp(par, VP_MISC, val);
190 240
191 /* Turn off the display */ 241 /* Turn off the display */
192 242
193 val = readl(par->df_regs + DF_DISPLAY_CFG); 243 val = read_vp(par, VP_DCFG);
194 writel(val & ~(DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN | 244 write_vp(par, VP_DCFG, val & ~(VP_DCFG_CRT_EN | VP_DCFG_HSYNC_EN |
195 DF_DCFG_DAC_BL_EN), par->df_regs + DF_DISPLAY_CFG); 245 VP_DCFG_VSYNC_EN | VP_DCFG_DAC_BL_EN));
196 246
197 gcfg = readl(par->dc_regs + DC_GENERAL_CFG); 247 gcfg = read_dc(par, DC_GENERAL_CFG);
198 gcfg &= ~(DC_GCFG_CMPE | DC_GCFG_DECE); 248 gcfg &= ~(DC_GENERAL_CFG_CMPE | DC_GENERAL_CFG_DECE);
199 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 249 write_dc(par, DC_GENERAL_CFG, gcfg);
200 250
201 /* Turn off the TGEN */ 251 /* Turn off the TGEN */
202 val = readl(par->dc_regs + DC_DISPLAY_CFG); 252 val = read_dc(par, DC_DISPLAY_CFG);
203 val &= ~DC_DCFG_TGEN; 253 val &= ~DC_DISPLAY_CFG_TGEN;
204 writel(val, par->dc_regs + DC_DISPLAY_CFG); 254 write_dc(par, DC_DISPLAY_CFG, val);
205 255
206 /* Wait 1000 usecs to ensure that the TGEN is clear */ 256 /* Wait 1000 usecs to ensure that the TGEN is clear */
207 udelay(1000); 257 udelay(1000);
208 258
209 /* Turn off the FIFO loader */ 259 /* Turn off the FIFO loader */
210 260
211 gcfg &= ~DC_GCFG_DFLE; 261 gcfg &= ~DC_GENERAL_CFG_DFLE;
212 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 262 write_dc(par, DC_GENERAL_CFG, gcfg);
213 263
214 /* Lastly, wait for the GP to go idle */ 264 /* Lastly, wait for the GP to go idle */
215 265
216 do { 266 do {
217 val = readl(par->gp_regs + GP_BLT_STATUS); 267 val = read_gp(par, GP_BLT_STATUS);
218 } while ((val & GP_BS_BLT_BUSY) || !(val & GP_BS_CB_EMPTY)); 268 } while ((val & GP_BLT_STATUS_PB) || !(val & GP_BLT_STATUS_CE));
219} 269}
220 270
221static void lx_graphics_enable(struct fb_info *info) 271static void lx_graphics_enable(struct fb_info *info)
@@ -224,80 +274,85 @@ static void lx_graphics_enable(struct fb_info *info)
224 u32 temp, config; 274 u32 temp, config;
225 275
226 /* Set the video request register */ 276 /* Set the video request register */
227 writel(0, par->df_regs + DF_VIDEO_REQUEST); 277 write_vp(par, VP_VRR, 0);
228 278
229 /* Set up the polarities */ 279 /* Set up the polarities */
230 280
231 config = readl(par->df_regs + DF_DISPLAY_CFG); 281 config = read_vp(par, VP_DCFG);
232 282
233 config &= ~(DF_DCFG_CRT_SYNC_SKW_MASK | DF_DCFG_PWR_SEQ_DLY_MASK | 283 config &= ~(VP_DCFG_CRT_SYNC_SKW | VP_DCFG_PWR_SEQ_DELAY |
234 DF_DCFG_CRT_HSYNC_POL | DF_DCFG_CRT_VSYNC_POL); 284 VP_DCFG_CRT_HSYNC_POL | VP_DCFG_CRT_VSYNC_POL);
235 285
236 config |= (DF_DCFG_CRT_SYNC_SKW_INIT | DF_DCFG_PWR_SEQ_DLY_INIT | 286 config |= (VP_DCFG_CRT_SYNC_SKW_DEFAULT | VP_DCFG_PWR_SEQ_DELAY_DEFAULT
237 DF_DCFG_GV_PAL_BYP); 287 | VP_DCFG_GV_GAM);
238 288
239 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) 289 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT)
240 config |= DF_DCFG_CRT_HSYNC_POL; 290 config |= VP_DCFG_CRT_HSYNC_POL;
241 291
242 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) 292 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT)
243 config |= DF_DCFG_CRT_VSYNC_POL; 293 config |= VP_DCFG_CRT_VSYNC_POL;
244 294
245 if (par->output & OUTPUT_PANEL) { 295 if (par->output & OUTPUT_PANEL) {
246 u32 msrlo, msrhi; 296 u32 msrlo, msrhi;
247 297
248 writel(DF_DEFAULT_TFT_PMTIM1, 298 write_fp(par, FP_PT1, 0);
249 par->df_regs + DF_PANEL_TIM1); 299 write_fp(par, FP_PT2, FP_PT2_SCRC);
250 writel(DF_DEFAULT_TFT_PMTIM2, 300 write_fp(par, FP_DFC, FP_DFC_BC);
251 par->df_regs + DF_PANEL_TIM2);
252 writel(DF_DEFAULT_TFT_DITHCTL,
253 par->df_regs + DF_DITHER_CONTROL);
254 301
255 msrlo = DF_DEFAULT_TFT_PAD_SEL_LOW; 302 msrlo = MSR_LX_MSR_PADSEL_TFT_SEL_LOW;
256 msrhi = DF_DEFAULT_TFT_PAD_SEL_HIGH; 303 msrhi = MSR_LX_MSR_PADSEL_TFT_SEL_HIGH;
257 304
258 wrmsr(MSR_LX_DF_PADSEL, msrlo, msrhi); 305 wrmsr(MSR_LX_MSR_PADSEL, msrlo, msrhi);
259 } 306 }
260 307
261 if (par->output & OUTPUT_CRT) { 308 if (par->output & OUTPUT_CRT) {
262 config |= DF_DCFG_CRT_EN | DF_DCFG_HSYNC_EN | 309 config |= VP_DCFG_CRT_EN | VP_DCFG_HSYNC_EN |
263 DF_DCFG_VSYNC_EN | DF_DCFG_DAC_BL_EN; 310 VP_DCFG_VSYNC_EN | VP_DCFG_DAC_BL_EN;
264 } 311 }
265 312
266 writel(config, par->df_regs + DF_DISPLAY_CFG); 313 write_vp(par, VP_DCFG, config);
267 314
268 /* Turn the CRT dacs back on */ 315 /* Turn the CRT dacs back on */
269 316
270 if (par->output & OUTPUT_CRT) { 317 if (par->output & OUTPUT_CRT) {
271 temp = readl(par->df_regs + DF_MISC); 318 temp = read_vp(par, VP_MISC);
272 temp &= ~(DF_MISC_DAC_PWRDN | DF_MISC_A_PWRDN); 319 temp &= ~(VP_MISC_DACPWRDN | VP_MISC_APWRDN);
273 writel(temp, par->df_regs + DF_MISC); 320 write_vp(par, VP_MISC, temp);
274 } 321 }
275 322
276 /* Turn the panel on (if it isn't already) */ 323 /* Turn the panel on (if it isn't already) */
277 324 if (par->output & OUTPUT_PANEL)
278 if (par->output & OUTPUT_PANEL) { 325 write_fp(par, FP_PM, read_fp(par, FP_PM) | FP_PM_P);
279 temp = readl(par->df_regs + DF_FP_PM);
280
281 if (!(temp & 0x09))
282 writel(temp | DF_FP_PM_P, par->df_regs + DF_FP_PM);
283 }
284
285 temp = readl(par->df_regs + DF_MISC);
286 temp = readl(par->df_regs + DF_DISPLAY_CFG);
287} 326}
288 327
289unsigned int lx_framebuffer_size(void) 328unsigned int lx_framebuffer_size(void)
290{ 329{
291 unsigned int val; 330 unsigned int val;
292 331
332 if (!geode_has_vsa2()) {
333 uint32_t hi, lo;
334
335 /* The number of pages is (PMAX - PMIN)+1 */
336 rdmsr(MSR_GLIU_P2D_RO0, lo, hi);
337
338 /* PMAX */
339 val = ((hi & 0xff) << 12) | ((lo & 0xfff00000) >> 20);
340 /* PMIN */
341 val -= (lo & 0x000fffff);
342 val += 1;
343
344 /* The page size is 4k */
345 return (val << 12);
346 }
347
293 /* The frame buffer size is reported by a VSM in VSA II */ 348 /* The frame buffer size is reported by a VSM in VSA II */
294 /* Virtual Register Class = 0x02 */ 349 /* Virtual Register Class = 0x02 */
295 /* VG_MEM_SIZE (1MB units) = 0x00 */ 350 /* VG_MEM_SIZE (1MB units) = 0x00 */
296 351
297 outw(0xFC53, 0xAC1C); 352 outw(VSA_VR_UNLOCK, VSA_VRC_INDEX);
298 outw(0x0200, 0xAC1C); 353 outw(VSA_VR_MEM_SIZE, VSA_VRC_INDEX);
299 354
300 val = (unsigned int)(inw(0xAC1E)) & 0xFE; 355 val = (unsigned int)(inw(VSA_VRC_DATA)) & 0xFE;
301 return (val << 20); 356 return (val << 20);
302} 357}
303 358
@@ -313,7 +368,7 @@ void lx_set_mode(struct fb_info *info)
313 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal; 368 int vactive, vblankstart, vsyncstart, vsyncend, vblankend, vtotal;
314 369
315 /* Unlock the DC registers */ 370 /* Unlock the DC registers */
316 writel(DC_UNLOCK_CODE, par->dc_regs + DC_UNLOCK); 371 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
317 372
318 lx_graphics_disable(info); 373 lx_graphics_disable(info);
319 374
@@ -321,102 +376,104 @@ void lx_set_mode(struct fb_info *info)
321 376
322 /* Set output mode */ 377 /* Set output mode */
323 378
324 rdmsrl(MSR_LX_DF_GLCONFIG, msrval); 379 rdmsrl(MSR_LX_GLD_MSR_CONFIG, msrval);
325 msrval &= ~DF_CONFIG_OUTPUT_MASK; 380 msrval &= ~MSR_LX_GLD_MSR_CONFIG_FMT;
326 381
327 if (par->output & OUTPUT_PANEL) { 382 if (par->output & OUTPUT_PANEL) {
328 msrval |= DF_OUTPUT_PANEL; 383 msrval |= MSR_LX_GLD_MSR_CONFIG_FMT_FP;
329 384
330 if (par->output & OUTPUT_CRT) 385 if (par->output & OUTPUT_CRT)
331 msrval |= DF_SIMULTANEOUS_CRT_AND_FP; 386 msrval |= MSR_LX_GLD_MSR_CONFIG_FPC;
332 else 387 else
333 msrval &= ~DF_SIMULTANEOUS_CRT_AND_FP; 388 msrval &= ~MSR_LX_GLD_MSR_CONFIG_FPC;
334 } else { 389 } else
335 msrval |= DF_OUTPUT_CRT; 390 msrval |= MSR_LX_GLD_MSR_CONFIG_FMT_CRT;
336 }
337 391
338 wrmsrl(MSR_LX_DF_GLCONFIG, msrval); 392 wrmsrl(MSR_LX_GLD_MSR_CONFIG, msrval);
339 393
340 /* Clear the various buffers */ 394 /* Clear the various buffers */
341 /* FIXME: Adjust for panning here */ 395 /* FIXME: Adjust for panning here */
342 396
343 writel(0, par->dc_regs + DC_FB_START); 397 write_dc(par, DC_FB_ST_OFFSET, 0);
344 writel(0, par->dc_regs + DC_CB_START); 398 write_dc(par, DC_CB_ST_OFFSET, 0);
345 writel(0, par->dc_regs + DC_CURSOR_START); 399 write_dc(par, DC_CURS_ST_OFFSET, 0);
346 400
347 /* FIXME: Add support for interlacing */ 401 /* FIXME: Add support for interlacing */
348 /* FIXME: Add support for scaling */ 402 /* FIXME: Add support for scaling */
349 403
350 val = readl(par->dc_regs + DC_GENLCK_CTRL); 404 val = read_dc(par, DC_GENLK_CTL);
351 val &= ~(DC_GC_ALPHA_FLICK_ENABLE | 405 val &= ~(DC_GENLK_CTL_ALPHA_FLICK_EN | DC_GENLK_CTL_FLICK_EN |
352 DC_GC_FLICKER_FILTER_ENABLE | DC_GC_FLICKER_FILTER_MASK); 406 DC_GENLK_CTL_FLICK_SEL_MASK);
353 407
354 /* Default scaling params */ 408 /* Default scaling params */
355 409
356 writel((0x4000 << 16) | 0x4000, par->dc_regs + DC_GFX_SCALE); 410 write_dc(par, DC_GFX_SCALE, (0x4000 << 16) | 0x4000);
357 writel(0, par->dc_regs + DC_IRQ_FILT_CTL); 411 write_dc(par, DC_IRQ_FILT_CTL, 0);
358 writel(val, par->dc_regs + DC_GENLCK_CTRL); 412 write_dc(par, DC_GENLK_CTL, val);
359 413
360 /* FIXME: Support compression */ 414 /* FIXME: Support compression */
361 415
362 if (info->fix.line_length > 4096) 416 if (info->fix.line_length > 4096)
363 dv = DC_DV_LINE_SIZE_8192; 417 dv = DC_DV_CTL_DV_LINE_SIZE_8K;
364 else if (info->fix.line_length > 2048) 418 else if (info->fix.line_length > 2048)
365 dv = DC_DV_LINE_SIZE_4096; 419 dv = DC_DV_CTL_DV_LINE_SIZE_4K;
366 else if (info->fix.line_length > 1024) 420 else if (info->fix.line_length > 1024)
367 dv = DC_DV_LINE_SIZE_2048; 421 dv = DC_DV_CTL_DV_LINE_SIZE_2K;
368 else 422 else
369 dv = DC_DV_LINE_SIZE_1024; 423 dv = DC_DV_CTL_DV_LINE_SIZE_1K;
370 424
371 max = info->fix.line_length * info->var.yres; 425 max = info->fix.line_length * info->var.yres;
372 max = (max + 0x3FF) & 0xFFFFFC00; 426 max = (max + 0x3FF) & 0xFFFFFC00;
373 427
374 writel(max | DC_DV_TOP_ENABLE, par->dc_regs + DC_DV_TOP); 428 write_dc(par, DC_DV_TOP, max | DC_DV_TOP_DV_TOP_EN);
375 429
376 val = readl(par->dc_regs + DC_DV_CTL) & ~DC_DV_LINE_SIZE_MASK; 430 val = read_dc(par, DC_DV_CTL) & ~DC_DV_CTL_DV_LINE_SIZE;
377 writel(val | dv, par->dc_regs + DC_DV_CTL); 431 write_dc(par, DC_DV_CTL, val | dv);
378 432
379 size = info->var.xres * (info->var.bits_per_pixel >> 3); 433 size = info->var.xres * (info->var.bits_per_pixel >> 3);
380 434
381 writel(info->fix.line_length >> 3, par->dc_regs + DC_GRAPHICS_PITCH); 435 write_dc(par, DC_GFX_PITCH, info->fix.line_length >> 3);
382 writel((size + 7) >> 3, par->dc_regs + DC_LINE_SIZE); 436 write_dc(par, DC_LINE_SIZE, (size + 7) >> 3);
383 437
384 /* Set default watermark values */ 438 /* Set default watermark values */
385 439
386 rdmsrl(MSR_LX_DC_SPARE, msrval); 440 rdmsrl(MSR_LX_SPARE_MSR, msrval);
387 441
388 msrval &= ~(DC_SPARE_DISABLE_CFIFO_HGO | DC_SPARE_VFIFO_ARB_SELECT | 442 msrval &= ~(MSR_LX_SPARE_MSR_DIS_CFIFO_HGO
389 DC_SPARE_LOAD_WM_LPEN_MASK | DC_SPARE_WM_LPEN_OVRD | 443 | MSR_LX_SPARE_MSR_VFIFO_ARB_SEL
390 DC_SPARE_DISABLE_INIT_VID_PRI | DC_SPARE_DISABLE_VFIFO_WM); 444 | MSR_LX_SPARE_MSR_LOAD_WM_LPEN_M
391 msrval |= DC_SPARE_DISABLE_VFIFO_WM | DC_SPARE_DISABLE_INIT_VID_PRI; 445 | MSR_LX_SPARE_MSR_WM_LPEN_OVRD);
392 wrmsrl(MSR_LX_DC_SPARE, msrval); 446 msrval |= MSR_LX_SPARE_MSR_DIS_VIFO_WM |
393 447 MSR_LX_SPARE_MSR_DIS_INIT_V_PRI;
394 gcfg = DC_GCFG_DFLE; /* Display fifo enable */ 448 wrmsrl(MSR_LX_SPARE_MSR, msrval);
395 gcfg |= 0xB600; /* Set default priority */ 449
396 gcfg |= DC_GCFG_FDTY; /* Set the frame dirty mode */ 450 gcfg = DC_GENERAL_CFG_DFLE; /* Display fifo enable */
397 451 gcfg |= (0x6 << DC_GENERAL_CFG_DFHPSL_SHIFT) | /* default priority */
398 dcfg = DC_DCFG_VDEN; /* Enable video data */ 452 (0xb << DC_GENERAL_CFG_DFHPEL_SHIFT);
399 dcfg |= DC_DCFG_GDEN; /* Enable graphics */ 453 gcfg |= DC_GENERAL_CFG_FDTY; /* Set the frame dirty mode */
400 dcfg |= DC_DCFG_TGEN; /* Turn on the timing generator */ 454
401 dcfg |= DC_DCFG_TRUP; /* Update timings immediately */ 455 dcfg = DC_DISPLAY_CFG_VDEN; /* Enable video data */
402 dcfg |= DC_DCFG_PALB; /* Palette bypass in > 8 bpp modes */ 456 dcfg |= DC_DISPLAY_CFG_GDEN; /* Enable graphics */
403 dcfg |= DC_DCFG_VISL; 457 dcfg |= DC_DISPLAY_CFG_TGEN; /* Turn on the timing generator */
404 dcfg |= DC_DCFG_DCEN; /* Always center the display */ 458 dcfg |= DC_DISPLAY_CFG_TRUP; /* Update timings immediately */
459 dcfg |= DC_DISPLAY_CFG_PALB; /* Palette bypass in > 8 bpp modes */
460 dcfg |= DC_DISPLAY_CFG_VISL;
461 dcfg |= DC_DISPLAY_CFG_DCEN; /* Always center the display */
405 462
406 /* Set the current BPP mode */ 463 /* Set the current BPP mode */
407 464
408 switch (info->var.bits_per_pixel) { 465 switch (info->var.bits_per_pixel) {
409 case 8: 466 case 8:
410 dcfg |= DC_DCFG_DISP_MODE_8BPP; 467 dcfg |= DC_DISPLAY_CFG_DISP_MODE_8BPP;
411 break; 468 break;
412 469
413 case 16: 470 case 16:
414 dcfg |= DC_DCFG_DISP_MODE_16BPP | DC_DCFG_16BPP; 471 dcfg |= DC_DISPLAY_CFG_DISP_MODE_16BPP;
415 break; 472 break;
416 473
417 case 32: 474 case 32:
418 case 24: 475 case 24:
419 dcfg |= DC_DCFG_DISP_MODE_24BPP; 476 dcfg |= DC_DISPLAY_CFG_DISP_MODE_24BPP;
420 break; 477 break;
421 } 478 }
422 479
@@ -436,35 +493,31 @@ void lx_set_mode(struct fb_info *info)
436 vblankend = vsyncend + info->var.upper_margin; 493 vblankend = vsyncend + info->var.upper_margin;
437 vtotal = vblankend; 494 vtotal = vblankend;
438 495
439 writel((hactive - 1) | ((htotal - 1) << 16), 496 write_dc(par, DC_H_ACTIVE_TIMING, (hactive - 1) | ((htotal - 1) << 16));
440 par->dc_regs + DC_H_ACTIVE_TIMING); 497 write_dc(par, DC_H_BLANK_TIMING,
441 writel((hblankstart - 1) | ((hblankend - 1) << 16), 498 (hblankstart - 1) | ((hblankend - 1) << 16));
442 par->dc_regs + DC_H_BLANK_TIMING); 499 write_dc(par, DC_H_SYNC_TIMING,
443 writel((hsyncstart - 1) | ((hsyncend - 1) << 16), 500 (hsyncstart - 1) | ((hsyncend - 1) << 16));
444 par->dc_regs + DC_H_SYNC_TIMING);
445
446 writel((vactive - 1) | ((vtotal - 1) << 16),
447 par->dc_regs + DC_V_ACTIVE_TIMING);
448 501
449 writel((vblankstart - 1) | ((vblankend - 1) << 16), 502 write_dc(par, DC_V_ACTIVE_TIMING, (vactive - 1) | ((vtotal - 1) << 16));
450 par->dc_regs + DC_V_BLANK_TIMING); 503 write_dc(par, DC_V_BLANK_TIMING,
504 (vblankstart - 1) | ((vblankend - 1) << 16));
505 write_dc(par, DC_V_SYNC_TIMING,
506 (vsyncstart - 1) | ((vsyncend - 1) << 16));
451 507
452 writel((vsyncstart - 1) | ((vsyncend - 1) << 16), 508 write_dc(par, DC_FB_ACTIVE,
453 par->dc_regs + DC_V_SYNC_TIMING); 509 (info->var.xres - 1) << 16 | (info->var.yres - 1));
454
455 writel( (info->var.xres - 1) << 16 | (info->var.yres - 1),
456 par->dc_regs + DC_FB_ACTIVE);
457 510
458 /* And re-enable the graphics output */ 511 /* And re-enable the graphics output */
459 lx_graphics_enable(info); 512 lx_graphics_enable(info);
460 513
461 /* Write the two main configuration registers */ 514 /* Write the two main configuration registers */
462 writel(dcfg, par->dc_regs + DC_DISPLAY_CFG); 515 write_dc(par, DC_DISPLAY_CFG, dcfg);
463 writel(0, par->dc_regs + DC_ARB_CFG); 516 write_dc(par, DC_ARB_CFG, 0);
464 writel(gcfg, par->dc_regs + DC_GENERAL_CFG); 517 write_dc(par, DC_GENERAL_CFG, gcfg);
465 518
466 /* Lock the DC registers */ 519 /* Lock the DC registers */
467 writel(0, par->dc_regs + DC_UNLOCK); 520 write_dc(par, DC_UNLOCK, DC_UNLOCK_LOCK);
468} 521}
469 522
470void lx_set_palette_reg(struct fb_info *info, unsigned regno, 523void lx_set_palette_reg(struct fb_info *info, unsigned regno,
@@ -479,58 +532,310 @@ void lx_set_palette_reg(struct fb_info *info, unsigned regno,
479 val |= (green) & 0x00ff00; 532 val |= (green) & 0x00ff00;
480 val |= (blue >> 8) & 0x0000ff; 533 val |= (blue >> 8) & 0x0000ff;
481 534
482 writel(regno, par->dc_regs + DC_PAL_ADDRESS); 535 write_dc(par, DC_PAL_ADDRESS, regno);
483 writel(val, par->dc_regs + DC_PAL_DATA); 536 write_dc(par, DC_PAL_DATA, val);
484} 537}
485 538
486int lx_blank_display(struct fb_info *info, int blank_mode) 539int lx_blank_display(struct fb_info *info, int blank_mode)
487{ 540{
488 struct lxfb_par *par = info->par; 541 struct lxfb_par *par = info->par;
489 u32 dcfg, fp_pm; 542 u32 dcfg, fp_pm;
490 int blank, hsync, vsync; 543 int blank, hsync, vsync, crt;
491 544
492 /* CRT power saving modes. */ 545 /* CRT power saving modes. */
493 switch (blank_mode) { 546 switch (blank_mode) {
494 case FB_BLANK_UNBLANK: 547 case FB_BLANK_UNBLANK:
495 blank = 0; hsync = 1; vsync = 1; 548 blank = 0; hsync = 1; vsync = 1; crt = 1;
496 break; 549 break;
497 case FB_BLANK_NORMAL: 550 case FB_BLANK_NORMAL:
498 blank = 1; hsync = 1; vsync = 1; 551 blank = 1; hsync = 1; vsync = 1; crt = 1;
499 break; 552 break;
500 case FB_BLANK_VSYNC_SUSPEND: 553 case FB_BLANK_VSYNC_SUSPEND:
501 blank = 1; hsync = 1; vsync = 0; 554 blank = 1; hsync = 1; vsync = 0; crt = 1;
502 break; 555 break;
503 case FB_BLANK_HSYNC_SUSPEND: 556 case FB_BLANK_HSYNC_SUSPEND:
504 blank = 1; hsync = 0; vsync = 1; 557 blank = 1; hsync = 0; vsync = 1; crt = 1;
505 break; 558 break;
506 case FB_BLANK_POWERDOWN: 559 case FB_BLANK_POWERDOWN:
507 blank = 1; hsync = 0; vsync = 0; 560 blank = 1; hsync = 0; vsync = 0; crt = 0;
508 break; 561 break;
509 default: 562 default:
510 return -EINVAL; 563 return -EINVAL;
511 } 564 }
512 565
513 dcfg = readl(par->df_regs + DF_DISPLAY_CFG); 566 dcfg = read_vp(par, VP_DCFG);
514 dcfg &= ~(DF_DCFG_DAC_BL_EN 567 dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN |
515 | DF_DCFG_HSYNC_EN | DF_DCFG_VSYNC_EN); 568 VP_DCFG_CRT_EN);
516 if (!blank) 569 if (!blank)
517 dcfg |= DF_DCFG_DAC_BL_EN; 570 dcfg |= VP_DCFG_DAC_BL_EN;
518 if (hsync) 571 if (hsync)
519 dcfg |= DF_DCFG_HSYNC_EN; 572 dcfg |= VP_DCFG_HSYNC_EN;
520 if (vsync) 573 if (vsync)
521 dcfg |= DF_DCFG_VSYNC_EN; 574 dcfg |= VP_DCFG_VSYNC_EN;
522 writel(dcfg, par->df_regs + DF_DISPLAY_CFG); 575 if (crt)
576 dcfg |= VP_DCFG_CRT_EN;
577 write_vp(par, VP_DCFG, dcfg);
523 578
524 /* Power on/off flat panel */ 579 /* Power on/off flat panel */
525 580
526 if (par->output & OUTPUT_PANEL) { 581 if (par->output & OUTPUT_PANEL) {
527 fp_pm = readl(par->df_regs + DF_FP_PM); 582 fp_pm = read_fp(par, FP_PM);
528 if (blank_mode == FB_BLANK_POWERDOWN) 583 if (blank_mode == FB_BLANK_POWERDOWN)
529 fp_pm &= ~DF_FP_PM_P; 584 fp_pm &= ~FP_PM_P;
530 else 585 else
531 fp_pm |= DF_FP_PM_P; 586 fp_pm |= FP_PM_P;
532 writel(fp_pm, par->df_regs + DF_FP_PM); 587 write_fp(par, FP_PM, fp_pm);
533 } 588 }
534 589
535 return 0; 590 return 0;
536} 591}
592
593#ifdef CONFIG_PM
594
595static void lx_save_regs(struct lxfb_par *par)
596{
597 uint32_t filt;
598 int i;
599
600 /* wait for the BLT engine to stop being busy */
601 do {
602 i = read_gp(par, GP_BLT_STATUS);
603 } while ((i & GP_BLT_STATUS_PB) || !(i & GP_BLT_STATUS_CE));
604
605 /* save MSRs */
606 rdmsrl(MSR_LX_MSR_PADSEL, par->msr.padsel);
607 rdmsrl(MSR_GLCP_DOTPLL, par->msr.dotpll);
608 rdmsrl(MSR_LX_GLD_MSR_CONFIG, par->msr.dfglcfg);
609 rdmsrl(MSR_LX_SPARE_MSR, par->msr.dcspare);
610
611 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
612
613 /* save registers */
614 memcpy(par->gp, par->gp_regs, sizeof(par->gp));
615 memcpy(par->dc, par->dc_regs, sizeof(par->dc));
616 memcpy(par->vp, par->vp_regs, sizeof(par->vp));
617 memcpy(par->fp, par->vp_regs + VP_FP_START, sizeof(par->fp));
618
619 /* save the palette */
620 write_dc(par, DC_PAL_ADDRESS, 0);
621 for (i = 0; i < ARRAY_SIZE(par->pal); i++)
622 par->pal[i] = read_dc(par, DC_PAL_DATA);
623
624 /* save the horizontal filter coefficients */
625 filt = par->dc[DC_IRQ_FILT_CTL] | DC_IRQ_FILT_CTL_H_FILT_SEL;
626 for (i = 0; i < ARRAY_SIZE(par->hcoeff); i += 2) {
627 write_dc(par, DC_IRQ_FILT_CTL, (filt & 0xffffff00) | i);
628 par->hcoeff[i] = read_dc(par, DC_FILT_COEFF1);
629 par->hcoeff[i + 1] = read_dc(par, DC_FILT_COEFF2);
630 }
631
632 /* save the vertical filter coefficients */
633 filt &= ~DC_IRQ_FILT_CTL_H_FILT_SEL;
634 for (i = 0; i < ARRAY_SIZE(par->vcoeff); i++) {
635 write_dc(par, DC_IRQ_FILT_CTL, (filt & 0xffffff00) | i);
636 par->vcoeff[i] = read_dc(par, DC_FILT_COEFF1);
637 }
638
639 /* save video coeff ram */
640 memcpy(par->vp_coeff, par->vp_regs + VP_VCR, sizeof(par->vp_coeff));
641}
642
643static void lx_restore_gfx_proc(struct lxfb_par *par)
644{
645 int i;
646
647 /* a bunch of registers require GP_RASTER_MODE to be set first */
648 write_gp(par, GP_RASTER_MODE, par->gp[GP_RASTER_MODE]);
649
650 for (i = 0; i < ARRAY_SIZE(par->gp); i++) {
651 switch (i) {
652 case GP_RASTER_MODE:
653 case GP_VECTOR_MODE:
654 case GP_BLT_MODE:
655 case GP_BLT_STATUS:
656 case GP_HST_SRC:
657 /* FIXME: restore LUT data */
658 case GP_LUT_INDEX:
659 case GP_LUT_DATA:
660 /* don't restore these registers */
661 break;
662
663 default:
664 write_gp(par, i, par->gp[i]);
665 }
666 }
667}
668
669static void lx_restore_display_ctlr(struct lxfb_par *par)
670{
671 uint32_t filt;
672 int i;
673
674 wrmsrl(MSR_LX_SPARE_MSR, par->msr.dcspare);
675
676 for (i = 0; i < ARRAY_SIZE(par->dc); i++) {
677 switch (i) {
678 case DC_UNLOCK:
679 /* unlock the DC; runs first */
680 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
681 break;
682
683 case DC_GENERAL_CFG:
684 case DC_DISPLAY_CFG:
685 /* disable all while restoring */
686 write_dc(par, i, 0);
687 break;
688
689 case DC_DV_CTL:
690 /* set all ram to dirty */
691 write_dc(par, i, par->dc[i] | DC_DV_CTL_CLEAR_DV_RAM);
692
693 case DC_RSVD_1:
694 case DC_RSVD_2:
695 case DC_RSVD_3:
696 case DC_LINE_CNT:
697 case DC_PAL_ADDRESS:
698 case DC_PAL_DATA:
699 case DC_DFIFO_DIAG:
700 case DC_CFIFO_DIAG:
701 case DC_FILT_COEFF1:
702 case DC_FILT_COEFF2:
703 case DC_RSVD_4:
704 case DC_RSVD_5:
705 /* don't restore these registers */
706 break;
707
708 default:
709 write_dc(par, i, par->dc[i]);
710 }
711 }
712
713 /* restore the palette */
714 write_dc(par, DC_PAL_ADDRESS, 0);
715 for (i = 0; i < ARRAY_SIZE(par->pal); i++)
716 write_dc(par, DC_PAL_DATA, par->pal[i]);
717
718 /* restore the horizontal filter coefficients */
719 filt = par->dc[DC_IRQ_FILT_CTL] | DC_IRQ_FILT_CTL_H_FILT_SEL;
720 for (i = 0; i < ARRAY_SIZE(par->hcoeff); i += 2) {
721 write_dc(par, DC_IRQ_FILT_CTL, (filt & 0xffffff00) | i);
722 write_dc(par, DC_FILT_COEFF1, par->hcoeff[i]);
723 write_dc(par, DC_FILT_COEFF2, par->hcoeff[i + 1]);
724 }
725
726 /* restore the vertical filter coefficients */
727 filt &= ~DC_IRQ_FILT_CTL_H_FILT_SEL;
728 for (i = 0; i < ARRAY_SIZE(par->vcoeff); i++) {
729 write_dc(par, DC_IRQ_FILT_CTL, (filt & 0xffffff00) | i);
730 write_dc(par, DC_FILT_COEFF1, par->vcoeff[i]);
731 }
732}
733
734static void lx_restore_video_proc(struct lxfb_par *par)
735{
736 int i;
737
738 wrmsrl(MSR_LX_GLD_MSR_CONFIG, par->msr.dfglcfg);
739 wrmsrl(MSR_LX_MSR_PADSEL, par->msr.padsel);
740
741 for (i = 0; i < ARRAY_SIZE(par->vp); i++) {
742 switch (i) {
743 case VP_VCFG:
744 case VP_DCFG:
745 case VP_PAR:
746 case VP_PDR:
747 case VP_CCS:
748 case VP_RSVD_0:
749 /* case VP_VDC: */ /* why should this not be restored? */
750 case VP_RSVD_1:
751 case VP_CRC32:
752 /* don't restore these registers */
753 break;
754
755 default:
756 write_vp(par, i, par->vp[i]);
757 }
758 }
759
760 /* restore video coeff ram */
761 memcpy(par->vp_regs + VP_VCR, par->vp_coeff, sizeof(par->vp_coeff));
762}
763
764static void lx_restore_regs(struct lxfb_par *par)
765{
766 int i;
767
768 lx_set_dotpll((u32) (par->msr.dotpll >> 32));
769 lx_restore_gfx_proc(par);
770 lx_restore_display_ctlr(par);
771 lx_restore_video_proc(par);
772
773 /* Flat Panel */
774 for (i = 0; i < ARRAY_SIZE(par->fp); i++) {
775 switch (i) {
776 case FP_PM:
777 case FP_RSVD_0:
778 case FP_RSVD_1:
779 case FP_RSVD_2:
780 case FP_RSVD_3:
781 case FP_RSVD_4:
782 /* don't restore these registers */
783 break;
784
785 default:
786 write_fp(par, i, par->fp[i]);
787 }
788 }
789
790 /* control the panel */
791 if (par->fp[FP_PM] & FP_PM_P) {
792 /* power on the panel if not already power{ed,ing} on */
793 if (!(read_fp(par, FP_PM) &
794 (FP_PM_PANEL_ON|FP_PM_PANEL_PWR_UP)))
795 write_fp(par, FP_PM, par->fp[FP_PM]);
796 } else {
797 /* power down the panel if not already power{ed,ing} down */
798 if (!(read_fp(par, FP_PM) &
799 (FP_PM_PANEL_OFF|FP_PM_PANEL_PWR_DOWN)))
800 write_fp(par, FP_PM, par->fp[FP_PM]);
801 }
802
803 /* turn everything on */
804 write_vp(par, VP_VCFG, par->vp[VP_VCFG]);
805 write_vp(par, VP_DCFG, par->vp[VP_DCFG]);
806 write_dc(par, DC_DISPLAY_CFG, par->dc[DC_DISPLAY_CFG]);
807 /* do this last; it will enable the FIFO load */
808 write_dc(par, DC_GENERAL_CFG, par->dc[DC_GENERAL_CFG]);
809
810 /* lock the door behind us */
811 write_dc(par, DC_UNLOCK, DC_UNLOCK_LOCK);
812}
813
814int lx_powerdown(struct fb_info *info)
815{
816 struct lxfb_par *par = info->par;
817
818 if (par->powered_down)
819 return 0;
820
821 lx_save_regs(par);
822 lx_graphics_disable(info);
823
824 par->powered_down = 1;
825 return 0;
826}
827
828int lx_powerup(struct fb_info *info)
829{
830 struct lxfb_par *par = info->par;
831
832 if (!par->powered_down)
833 return 0;
834
835 lx_restore_regs(par);
836
837 par->powered_down = 0;
838 return 0;
839}
840
841#endif
diff --git a/drivers/video/geode/suspend_gx.c b/drivers/video/geode/suspend_gx.c
new file mode 100644
index 000000000000..9aff32ef8bb6
--- /dev/null
+++ b/drivers/video/geode/suspend_gx.c
@@ -0,0 +1,267 @@
1/*
2 * Copyright (C) 2007 Advanced Micro Devices, Inc.
3 * Copyright (C) 2008 Andres Salomon <dilinger@debian.org>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 */
10#include <linux/fb.h>
11#include <asm/io.h>
12#include <asm/msr.h>
13#include <asm/geode.h>
14#include <asm/delay.h>
15
16#include "gxfb.h"
17
18#ifdef CONFIG_PM
19
20static void gx_save_regs(struct gxfb_par *par)
21{
22 int i;
23
24 /* wait for the BLT engine to stop being busy */
25 do {
26 i = read_gp(par, GP_BLT_STATUS);
27 } while (i & (GP_BLT_STATUS_BLT_PENDING | GP_BLT_STATUS_BLT_BUSY));
28
29 /* save MSRs */
30 rdmsrl(MSR_GX_MSR_PADSEL, par->msr.padsel);
31 rdmsrl(MSR_GLCP_DOTPLL, par->msr.dotpll);
32
33 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
34
35 /* save registers */
36 memcpy(par->gp, par->gp_regs, sizeof(par->gp));
37 memcpy(par->dc, par->dc_regs, sizeof(par->dc));
38 memcpy(par->vp, par->vid_regs, sizeof(par->vp));
39 memcpy(par->fp, par->vid_regs + VP_FP_START, sizeof(par->fp));
40
41 /* save the palette */
42 write_dc(par, DC_PAL_ADDRESS, 0);
43 for (i = 0; i < ARRAY_SIZE(par->pal); i++)
44 par->pal[i] = read_dc(par, DC_PAL_DATA);
45}
46
47static void gx_set_dotpll(uint32_t dotpll_hi)
48{
49 uint32_t dotpll_lo;
50 int i;
51
52 rdmsrl(MSR_GLCP_DOTPLL, dotpll_lo);
53 dotpll_lo |= MSR_GLCP_DOTPLL_DOTRESET;
54 dotpll_lo &= ~MSR_GLCP_DOTPLL_BYPASS;
55 wrmsr(MSR_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
56
57 /* wait for the PLL to lock */
58 for (i = 0; i < 200; i++) {
59 rdmsrl(MSR_GLCP_DOTPLL, dotpll_lo);
60 if (dotpll_lo & MSR_GLCP_DOTPLL_LOCK)
61 break;
62 udelay(1);
63 }
64
65 /* PLL set, unlock */
66 dotpll_lo &= ~MSR_GLCP_DOTPLL_DOTRESET;
67 wrmsr(MSR_GLCP_DOTPLL, dotpll_lo, dotpll_hi);
68}
69
70static void gx_restore_gfx_proc(struct gxfb_par *par)
71{
72 int i;
73
74 for (i = 0; i < ARRAY_SIZE(par->gp); i++) {
75 switch (i) {
76 case GP_VECTOR_MODE:
77 case GP_BLT_MODE:
78 case GP_BLT_STATUS:
79 case GP_HST_SRC:
80 /* don't restore these registers */
81 break;
82 default:
83 write_gp(par, i, par->gp[i]);
84 }
85 }
86}
87
88static void gx_restore_display_ctlr(struct gxfb_par *par)
89{
90 int i;
91
92 for (i = 0; i < ARRAY_SIZE(par->dc); i++) {
93 switch (i) {
94 case DC_UNLOCK:
95 /* unlock the DC; runs first */
96 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
97 break;
98
99 case DC_GENERAL_CFG:
100 /* write without the enables */
101 write_dc(par, i, par->dc[i] & ~(DC_GENERAL_CFG_VIDE |
102 DC_GENERAL_CFG_ICNE |
103 DC_GENERAL_CFG_CURE |
104 DC_GENERAL_CFG_DFLE));
105 break;
106
107 case DC_DISPLAY_CFG:
108 /* write without the enables */
109 write_dc(par, i, par->dc[i] & ~(DC_DISPLAY_CFG_VDEN |
110 DC_DISPLAY_CFG_GDEN |
111 DC_DISPLAY_CFG_TGEN));
112 break;
113
114 case DC_RSVD_0:
115 case DC_RSVD_1:
116 case DC_RSVD_2:
117 case DC_RSVD_3:
118 case DC_RSVD_4:
119 case DC_LINE_CNT:
120 case DC_PAL_ADDRESS:
121 case DC_PAL_DATA:
122 case DC_DFIFO_DIAG:
123 case DC_CFIFO_DIAG:
124 case DC_RSVD_5:
125 /* don't restore these registers */
126 break;
127 default:
128 write_dc(par, i, par->dc[i]);
129 }
130 }
131
132 /* restore the palette */
133 write_dc(par, DC_PAL_ADDRESS, 0);
134 for (i = 0; i < ARRAY_SIZE(par->pal); i++)
135 write_dc(par, DC_PAL_DATA, par->pal[i]);
136}
137
138static void gx_restore_video_proc(struct gxfb_par *par)
139{
140 int i;
141
142 wrmsrl(MSR_GX_MSR_PADSEL, par->msr.padsel);
143
144 for (i = 0; i < ARRAY_SIZE(par->vp); i++) {
145 switch (i) {
146 case VP_VCFG:
147 /* don't enable video yet */
148 write_vp(par, i, par->vp[i] & ~VP_VCFG_VID_EN);
149 break;
150
151 case VP_DCFG:
152 /* don't enable CRT yet */
153 write_vp(par, i, par->vp[i] &
154 ~(VP_DCFG_DAC_BL_EN | VP_DCFG_VSYNC_EN |
155 VP_DCFG_HSYNC_EN | VP_DCFG_CRT_EN));
156 break;
157
158 case VP_GAR:
159 case VP_GDR:
160 case VP_RSVD_0:
161 case VP_RSVD_1:
162 case VP_RSVD_2:
163 case VP_RSVD_3:
164 case VP_CRC32:
165 case VP_AWT:
166 case VP_VTM:
167 /* don't restore these registers */
168 break;
169 default:
170 write_vp(par, i, par->vp[i]);
171 }
172 }
173}
174
175static void gx_restore_regs(struct gxfb_par *par)
176{
177 int i;
178
179 gx_set_dotpll((uint32_t) (par->msr.dotpll >> 32));
180 gx_restore_gfx_proc(par);
181 gx_restore_display_ctlr(par);
182 gx_restore_video_proc(par);
183
184 /* Flat Panel */
185 for (i = 0; i < ARRAY_SIZE(par->fp); i++) {
186 if (i != FP_PM && i != FP_RSVD_0)
187 write_fp(par, i, par->fp[i]);
188 }
189}
190
191static void gx_disable_graphics(struct gxfb_par *par)
192{
193 /* shut down the engine */
194 write_vp(par, VP_VCFG, par->vp[VP_VCFG] & ~VP_VCFG_VID_EN);
195 write_vp(par, VP_DCFG, par->vp[VP_DCFG] & ~(VP_DCFG_DAC_BL_EN |
196 VP_DCFG_VSYNC_EN | VP_DCFG_HSYNC_EN | VP_DCFG_CRT_EN));
197
198 /* turn off the flat panel */
199 write_fp(par, FP_PM, par->fp[FP_PM] & ~FP_PM_P);
200
201
202 /* turn off display */
203 write_dc(par, DC_UNLOCK, DC_UNLOCK_UNLOCK);
204 write_dc(par, DC_GENERAL_CFG, par->dc[DC_GENERAL_CFG] &
205 ~(DC_GENERAL_CFG_VIDE | DC_GENERAL_CFG_ICNE |
206 DC_GENERAL_CFG_CURE | DC_GENERAL_CFG_DFLE));
207 write_dc(par, DC_DISPLAY_CFG, par->dc[DC_DISPLAY_CFG] &
208 ~(DC_DISPLAY_CFG_VDEN | DC_DISPLAY_CFG_GDEN |
209 DC_DISPLAY_CFG_TGEN));
210 write_dc(par, DC_UNLOCK, DC_UNLOCK_LOCK);
211}
212
213static void gx_enable_graphics(struct gxfb_par *par)
214{
215 uint32_t fp;
216
217 fp = read_fp(par, FP_PM);
218 if (par->fp[FP_PM] & FP_PM_P) {
219 /* power on the panel if not already power{ed,ing} on */
220 if (!(fp & (FP_PM_PANEL_ON|FP_PM_PANEL_PWR_UP)))
221 write_fp(par, FP_PM, par->fp[FP_PM]);
222 } else {
223 /* power down the panel if not already power{ed,ing} down */
224 if (!(fp & (FP_PM_PANEL_OFF|FP_PM_PANEL_PWR_DOWN)))
225 write_fp(par, FP_PM, par->fp[FP_PM]);
226 }
227
228 /* turn everything on */
229 write_vp(par, VP_VCFG, par->vp[VP_VCFG]);
230 write_vp(par, VP_DCFG, par->vp[VP_DCFG]);
231 write_dc(par, DC_DISPLAY_CFG, par->dc[DC_DISPLAY_CFG]);
232 /* do this last; it will enable the FIFO load */
233 write_dc(par, DC_GENERAL_CFG, par->dc[DC_GENERAL_CFG]);
234
235 /* lock the door behind us */
236 write_dc(par, DC_UNLOCK, DC_UNLOCK_LOCK);
237}
238
239int gx_powerdown(struct fb_info *info)
240{
241 struct gxfb_par *par = info->par;
242
243 if (par->powered_down)
244 return 0;
245
246 gx_save_regs(par);
247 gx_disable_graphics(par);
248
249 par->powered_down = 1;
250 return 0;
251}
252
253int gx_powerup(struct fb_info *info)
254{
255 struct gxfb_par *par = info->par;
256
257 if (!par->powered_down)
258 return 0;
259
260 gx_restore_regs(par);
261 gx_enable_graphics(par);
262
263 par->powered_down = 0;
264 return 0;
265}
266
267#endif
diff --git a/drivers/video/geode/video_gx.c b/drivers/video/geode/video_gx.c
index febf09c63492..b8d52a8360db 100644
--- a/drivers/video/geode/video_gx.c
+++ b/drivers/video/geode/video_gx.c
@@ -16,9 +16,9 @@
16#include <asm/io.h> 16#include <asm/io.h>
17#include <asm/delay.h> 17#include <asm/delay.h>
18#include <asm/msr.h> 18#include <asm/msr.h>
19#include <asm/geode.h>
19 20
20#include "geodefb.h" 21#include "gxfb.h"
21#include "video_gx.h"
22 22
23 23
24/* 24/*
@@ -117,7 +117,7 @@ static const struct gx_pll_entry gx_pll_table_14MHz[] = {
117 { 4357, 0, 0x0000057D }, /* 229.5000 */ 117 { 4357, 0, 0x0000057D }, /* 229.5000 */
118}; 118};
119 119
120static void gx_set_dclk_frequency(struct fb_info *info) 120void gx_set_dclk_frequency(struct fb_info *info)
121{ 121{
122 const struct gx_pll_entry *pll_table; 122 const struct gx_pll_entry *pll_table;
123 int pll_table_len; 123 int pll_table_len;
@@ -178,110 +178,116 @@ static void gx_set_dclk_frequency(struct fb_info *info)
178static void 178static void
179gx_configure_tft(struct fb_info *info) 179gx_configure_tft(struct fb_info *info)
180{ 180{
181 struct geodefb_par *par = info->par; 181 struct gxfb_par *par = info->par;
182 unsigned long val; 182 unsigned long val;
183 unsigned long fp; 183 unsigned long fp;
184 184
185 /* Set up the DF pad select MSR */ 185 /* Set up the DF pad select MSR */
186 186
187 rdmsrl(GX_VP_MSR_PAD_SELECT, val); 187 rdmsrl(MSR_GX_MSR_PADSEL, val);
188 val &= ~GX_VP_PAD_SELECT_MASK; 188 val &= ~MSR_GX_MSR_PADSEL_MASK;
189 val |= GX_VP_PAD_SELECT_TFT; 189 val |= MSR_GX_MSR_PADSEL_TFT;
190 wrmsrl(GX_VP_MSR_PAD_SELECT, val); 190 wrmsrl(MSR_GX_MSR_PADSEL, val);
191 191
192 /* Turn off the panel */ 192 /* Turn off the panel */
193 193
194 fp = readl(par->vid_regs + GX_FP_PM); 194 fp = read_fp(par, FP_PM);
195 fp &= ~GX_FP_PM_P; 195 fp &= ~FP_PM_P;
196 writel(fp, par->vid_regs + GX_FP_PM); 196 write_fp(par, FP_PM, fp);
197 197
198 /* Set timing 1 */ 198 /* Set timing 1 */
199 199
200 fp = readl(par->vid_regs + GX_FP_PT1); 200 fp = read_fp(par, FP_PT1);
201 fp &= GX_FP_PT1_VSIZE_MASK; 201 fp &= FP_PT1_VSIZE_MASK;
202 fp |= info->var.yres << GX_FP_PT1_VSIZE_SHIFT; 202 fp |= info->var.yres << FP_PT1_VSIZE_SHIFT;
203 writel(fp, par->vid_regs + GX_FP_PT1); 203 write_fp(par, FP_PT1, fp);
204 204
205 /* Timing 2 */ 205 /* Timing 2 */
206 /* Set bits that are always on for TFT */ 206 /* Set bits that are always on for TFT */
207 207
208 fp = 0x0F100000; 208 fp = 0x0F100000;
209 209
210 /* Add sync polarity */ 210 /* Configure sync polarity */
211 211
212 if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT)) 212 if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT))
213 fp |= GX_FP_PT2_VSP; 213 fp |= FP_PT2_VSP;
214 214
215 if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT)) 215 if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
216 fp |= GX_FP_PT2_HSP; 216 fp |= FP_PT2_HSP;
217 217
218 writel(fp, par->vid_regs + GX_FP_PT2); 218 write_fp(par, FP_PT2, fp);
219 219
220 /* Set the dither control */ 220 /* Set the dither control */
221 writel(0x70, par->vid_regs + GX_FP_DFC); 221 write_fp(par, FP_DFC, FP_DFC_NFI);
222 222
223 /* Enable the FP data and power (in case the BIOS didn't) */ 223 /* Enable the FP data and power (in case the BIOS didn't) */
224 224
225 fp = readl(par->vid_regs + GX_DCFG); 225 fp = read_vp(par, VP_DCFG);
226 fp |= GX_DCFG_FP_PWR_EN | GX_DCFG_FP_DATA_EN; 226 fp |= VP_DCFG_FP_PWR_EN | VP_DCFG_FP_DATA_EN;
227 writel(fp, par->vid_regs + GX_DCFG); 227 write_vp(par, VP_DCFG, fp);
228 228
229 /* Unblank the panel */ 229 /* Unblank the panel */
230 230
231 fp = readl(par->vid_regs + GX_FP_PM); 231 fp = read_fp(par, FP_PM);
232 fp |= GX_FP_PM_P; 232 fp |= FP_PM_P;
233 writel(fp, par->vid_regs + GX_FP_PM); 233 write_fp(par, FP_PM, fp);
234} 234}
235 235
236static void gx_configure_display(struct fb_info *info) 236void gx_configure_display(struct fb_info *info)
237{ 237{
238 struct geodefb_par *par = info->par; 238 struct gxfb_par *par = info->par;
239 u32 dcfg, misc; 239 u32 dcfg, misc;
240 240
241 /* Set up the MISC register */
242
243 misc = readl(par->vid_regs + GX_MISC);
244
245 /* Power up the DAC */
246 misc &= ~(GX_MISC_A_PWRDN | GX_MISC_DAC_PWRDN);
247
248 /* Disable gamma correction */
249 misc |= GX_MISC_GAM_EN;
250
251 writel(misc, par->vid_regs + GX_MISC);
252
253 /* Write the display configuration */ 241 /* Write the display configuration */
254 dcfg = readl(par->vid_regs + GX_DCFG); 242 dcfg = read_vp(par, VP_DCFG);
255 243
256 /* Disable hsync and vsync */ 244 /* Disable hsync and vsync */
257 dcfg &= ~(GX_DCFG_VSYNC_EN | GX_DCFG_HSYNC_EN); 245 dcfg &= ~(VP_DCFG_VSYNC_EN | VP_DCFG_HSYNC_EN);
258 writel(dcfg, par->vid_regs + GX_DCFG); 246 write_vp(par, VP_DCFG, dcfg);
259 247
260 /* Clear bits from existing mode. */ 248 /* Clear bits from existing mode. */
261 dcfg &= ~(GX_DCFG_CRT_SYNC_SKW_MASK 249 dcfg &= ~(VP_DCFG_CRT_SYNC_SKW
262 | GX_DCFG_CRT_HSYNC_POL | GX_DCFG_CRT_VSYNC_POL 250 | VP_DCFG_CRT_HSYNC_POL | VP_DCFG_CRT_VSYNC_POL
263 | GX_DCFG_VSYNC_EN | GX_DCFG_HSYNC_EN); 251 | VP_DCFG_VSYNC_EN | VP_DCFG_HSYNC_EN);
264 252
265 /* Set default sync skew. */ 253 /* Set default sync skew. */
266 dcfg |= GX_DCFG_CRT_SYNC_SKW_DFLT; 254 dcfg |= VP_DCFG_CRT_SYNC_SKW_DEFAULT;
267 255
268 /* Enable hsync and vsync. */ 256 /* Enable hsync and vsync. */
269 dcfg |= GX_DCFG_HSYNC_EN | GX_DCFG_VSYNC_EN; 257 dcfg |= VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN;
270 258
271 /* Sync polarities. */ 259 misc = read_vp(par, VP_MISC);
272 if (info->var.sync & FB_SYNC_HOR_HIGH_ACT) 260
273 dcfg |= GX_DCFG_CRT_HSYNC_POL; 261 /* Disable gamma correction */
274 if (info->var.sync & FB_SYNC_VERT_HIGH_ACT) 262 misc |= VP_MISC_GAM_EN;
275 dcfg |= GX_DCFG_CRT_VSYNC_POL; 263
264 if (par->enable_crt) {
265
266 /* Power up the CRT DACs */
267 misc &= ~(VP_MISC_APWRDN | VP_MISC_DACPWRDN);
268 write_vp(par, VP_MISC, misc);
269
270 /* Only change the sync polarities if we are running
271 * in CRT mode. The FP polarities will be handled in
272 * gxfb_configure_tft */
273 if (!(info->var.sync & FB_SYNC_HOR_HIGH_ACT))
274 dcfg |= VP_DCFG_CRT_HSYNC_POL;
275 if (!(info->var.sync & FB_SYNC_VERT_HIGH_ACT))
276 dcfg |= VP_DCFG_CRT_VSYNC_POL;
277 } else {
278 /* Power down the CRT DACs if in FP mode */
279 misc |= (VP_MISC_APWRDN | VP_MISC_DACPWRDN);
280 write_vp(par, VP_MISC, misc);
281 }
276 282
277 /* Enable the display logic */ 283 /* Enable the display logic */
278 /* Set up the DACS to blank normally */ 284 /* Set up the DACS to blank normally */
279 285
280 dcfg |= GX_DCFG_CRT_EN | GX_DCFG_DAC_BL_EN; 286 dcfg |= VP_DCFG_CRT_EN | VP_DCFG_DAC_BL_EN;
281 287
282 /* Enable the external DAC VREF? */ 288 /* Enable the external DAC VREF? */
283 289
284 writel(dcfg, par->vid_regs + GX_DCFG); 290 write_vp(par, VP_DCFG, dcfg);
285 291
286 /* Set up the flat panel (if it is enabled) */ 292 /* Set up the flat panel (if it is enabled) */
287 293
@@ -289,59 +295,55 @@ static void gx_configure_display(struct fb_info *info)
289 gx_configure_tft(info); 295 gx_configure_tft(info);
290} 296}
291 297
292static int gx_blank_display(struct fb_info *info, int blank_mode) 298int gx_blank_display(struct fb_info *info, int blank_mode)
293{ 299{
294 struct geodefb_par *par = info->par; 300 struct gxfb_par *par = info->par;
295 u32 dcfg, fp_pm; 301 u32 dcfg, fp_pm;
296 int blank, hsync, vsync; 302 int blank, hsync, vsync, crt;
297 303
298 /* CRT power saving modes. */ 304 /* CRT power saving modes. */
299 switch (blank_mode) { 305 switch (blank_mode) {
300 case FB_BLANK_UNBLANK: 306 case FB_BLANK_UNBLANK:
301 blank = 0; hsync = 1; vsync = 1; 307 blank = 0; hsync = 1; vsync = 1; crt = 1;
302 break; 308 break;
303 case FB_BLANK_NORMAL: 309 case FB_BLANK_NORMAL:
304 blank = 1; hsync = 1; vsync = 1; 310 blank = 1; hsync = 1; vsync = 1; crt = 1;
305 break; 311 break;
306 case FB_BLANK_VSYNC_SUSPEND: 312 case FB_BLANK_VSYNC_SUSPEND:
307 blank = 1; hsync = 1; vsync = 0; 313 blank = 1; hsync = 1; vsync = 0; crt = 1;
308 break; 314 break;
309 case FB_BLANK_HSYNC_SUSPEND: 315 case FB_BLANK_HSYNC_SUSPEND:
310 blank = 1; hsync = 0; vsync = 1; 316 blank = 1; hsync = 0; vsync = 1; crt = 1;
311 break; 317 break;
312 case FB_BLANK_POWERDOWN: 318 case FB_BLANK_POWERDOWN:
313 blank = 1; hsync = 0; vsync = 0; 319 blank = 1; hsync = 0; vsync = 0; crt = 0;
314 break; 320 break;
315 default: 321 default:
316 return -EINVAL; 322 return -EINVAL;
317 } 323 }
318 dcfg = readl(par->vid_regs + GX_DCFG); 324 dcfg = read_vp(par, VP_DCFG);
319 dcfg &= ~(GX_DCFG_DAC_BL_EN 325 dcfg &= ~(VP_DCFG_DAC_BL_EN | VP_DCFG_HSYNC_EN | VP_DCFG_VSYNC_EN |
320 | GX_DCFG_HSYNC_EN | GX_DCFG_VSYNC_EN); 326 VP_DCFG_CRT_EN);
321 if (!blank) 327 if (!blank)
322 dcfg |= GX_DCFG_DAC_BL_EN; 328 dcfg |= VP_DCFG_DAC_BL_EN;
323 if (hsync) 329 if (hsync)
324 dcfg |= GX_DCFG_HSYNC_EN; 330 dcfg |= VP_DCFG_HSYNC_EN;
325 if (vsync) 331 if (vsync)
326 dcfg |= GX_DCFG_VSYNC_EN; 332 dcfg |= VP_DCFG_VSYNC_EN;
327 writel(dcfg, par->vid_regs + GX_DCFG); 333 if (crt)
334 dcfg |= VP_DCFG_CRT_EN;
335 write_vp(par, VP_DCFG, dcfg);
328 336
329 /* Power on/off flat panel. */ 337 /* Power on/off flat panel. */
330 338
331 if (par->enable_crt == 0) { 339 if (par->enable_crt == 0) {
332 fp_pm = readl(par->vid_regs + GX_FP_PM); 340 fp_pm = read_fp(par, FP_PM);
333 if (blank_mode == FB_BLANK_POWERDOWN) 341 if (blank_mode == FB_BLANK_POWERDOWN)
334 fp_pm &= ~GX_FP_PM_P; 342 fp_pm &= ~FP_PM_P;
335 else 343 else
336 fp_pm |= GX_FP_PM_P; 344 fp_pm |= FP_PM_P;
337 writel(fp_pm, par->vid_regs + GX_FP_PM); 345 write_fp(par, FP_PM, fp_pm);
338 } 346 }
339 347
340 return 0; 348 return 0;
341} 349}
342
343struct geode_vid_ops gx_vid_ops = {
344 .set_dclk = gx_set_dclk_frequency,
345 .configure_display = gx_configure_display,
346 .blank_display = gx_blank_display,
347};
diff --git a/drivers/video/geode/video_gx.h b/drivers/video/geode/video_gx.h
deleted file mode 100644
index ce28d8f382dc..000000000000
--- a/drivers/video/geode/video_gx.h
+++ /dev/null
@@ -1,72 +0,0 @@
1/*
2 * Geode GX video device
3 *
4 * Copyright (C) 2006 Arcom Control Systems Ltd.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11#ifndef __VIDEO_GX_H__
12#define __VIDEO_GX_H__
13
14extern struct geode_vid_ops gx_vid_ops;
15
16/* GX Flatpanel control MSR */
17#define GX_VP_MSR_PAD_SELECT 0xC0002011
18#define GX_VP_PAD_SELECT_MASK 0x3FFFFFFF
19#define GX_VP_PAD_SELECT_TFT 0x1FFFFFFF
20
21/* Geode GX video processor registers */
22
23#define GX_DCFG 0x0008
24# define GX_DCFG_CRT_EN 0x00000001
25# define GX_DCFG_HSYNC_EN 0x00000002
26# define GX_DCFG_VSYNC_EN 0x00000004
27# define GX_DCFG_DAC_BL_EN 0x00000008
28# define GX_DCFG_FP_PWR_EN 0x00000040
29# define GX_DCFG_FP_DATA_EN 0x00000080
30# define GX_DCFG_CRT_HSYNC_POL 0x00000100
31# define GX_DCFG_CRT_VSYNC_POL 0x00000200
32# define GX_DCFG_CRT_SYNC_SKW_MASK 0x0001C000
33# define GX_DCFG_CRT_SYNC_SKW_DFLT 0x00010000
34# define GX_DCFG_VG_CK 0x00100000
35# define GX_DCFG_GV_GAM 0x00200000
36# define GX_DCFG_DAC_VREF 0x04000000
37
38/* Geode GX MISC video configuration */
39
40#define GX_MISC 0x50
41#define GX_MISC_GAM_EN 0x00000001
42#define GX_MISC_DAC_PWRDN 0x00000400
43#define GX_MISC_A_PWRDN 0x00000800
44
45/* Geode GX flat panel display control registers */
46
47#define GX_FP_PT1 0x0400
48#define GX_FP_PT1_VSIZE_MASK 0x7FF0000
49#define GX_FP_PT1_VSIZE_SHIFT 16
50
51#define GX_FP_PT2 0x408
52#define GX_FP_PT2_VSP (1 << 23)
53#define GX_FP_PT2_HSP (1 << 22)
54
55#define GX_FP_PM 0x410
56# define GX_FP_PM_P 0x01000000
57
58#define GX_FP_DFC 0x418
59
60/* Geode GX clock control MSRs */
61
62#define MSR_GLCP_SYS_RSTPLL 0x4c000014
63# define MSR_GLCP_SYS_RSTPLL_DOTPREDIV2 (0x0000000000000002ull)
64# define MSR_GLCP_SYS_RSTPLL_DOTPREMULT2 (0x0000000000000004ull)
65# define MSR_GLCP_SYS_RSTPLL_DOTPOSTDIV3 (0x0000000000000008ull)
66
67#define MSR_GLCP_DOTPLL 0x4c000015
68# define MSR_GLCP_DOTPLL_DOTRESET (0x0000000000000001ull)
69# define MSR_GLCP_DOTPLL_BYPASS (0x0000000000008000ull)
70# define MSR_GLCP_DOTPLL_LOCK (0x0000000002000000ull)
71
72#endif /* !__VIDEO_GX_H__ */
diff --git a/drivers/video/gxt4500.c b/drivers/video/gxt4500.c
index e92337bef50d..564557792bed 100644
--- a/drivers/video/gxt4500.c
+++ b/drivers/video/gxt4500.c
@@ -238,7 +238,7 @@ static int calc_pll(int period_ps, struct gxt4500_par *par)
238 for (pdiv1 = 1; pdiv1 <= 8; ++pdiv1) { 238 for (pdiv1 = 1; pdiv1 <= 8; ++pdiv1) {
239 for (pdiv2 = 1; pdiv2 <= pdiv1; ++pdiv2) { 239 for (pdiv2 = 1; pdiv2 <= pdiv1; ++pdiv2) {
240 postdiv = pdiv1 * pdiv2; 240 postdiv = pdiv1 * pdiv2;
241 pll_period = (period_ps + postdiv - 1) / postdiv; 241 pll_period = DIV_ROUND_UP(period_ps, postdiv);
242 /* keep pll in range 350..600 MHz */ 242 /* keep pll in range 350..600 MHz */
243 if (pll_period < 1666 || pll_period > 2857) 243 if (pll_period < 1666 || pll_period > 2857)
244 continue; 244 continue;
diff --git a/drivers/video/hecubafb.c b/drivers/video/hecubafb.c
index 94e0df8a6f60..0b4bffbe67c8 100644
--- a/drivers/video/hecubafb.c
+++ b/drivers/video/hecubafb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/drivers/video/hecubafb.c -- FB driver for Hecuba controller 2 * linux/drivers/video/hecubafb.c -- FB driver for Hecuba/Apollo controller
3 * 3 *
4 * Copyright (C) 2006, Jaya Kumar 4 * Copyright (C) 2006, Jaya Kumar
5 * This work was sponsored by CIS(M) Sdn Bhd 5 * This work was sponsored by CIS(M) Sdn Bhd
@@ -17,18 +17,13 @@
17 * values. There are other commands that the display is capable of, 17 * values. There are other commands that the display is capable of,
18 * beyond the 5 used here but they are more complex. 18 * beyond the 5 used here but they are more complex.
19 * 19 *
20 * This driver is written to be used with the Hecuba display controller 20 * This driver is written to be used with the Hecuba display architecture.
21 * board, and tested with the EInk 800x600 display in 1 bit mode. 21 * The actual display chip is called Apollo and the interface electronics
22 * The interface between Hecuba and the host is TTL based GPIO. The 22 * it needs is called Hecuba.
23 * GPIO requirements are 8 writable data lines and 6 lines for control.
24 * Only 4 of the controls are actually used here but 6 for future use.
25 * The driver requires the IO addresses for data and control GPIO at
26 * load time. It is also possible to use this display with a standard
27 * PC parallel port.
28 * 23 *
29 * General notes: 24 * It is intended to be architecture independent. A board specific driver
30 * - User must set hecubafb_enable=1 to enable it 25 * must be used to perform all the physical IO interactions. An example
31 * - User must set dio_addr=0xIOADDR cio_addr=0xIOADDR c2io_addr=0xIOADDR 26 * is provided as n411.c
32 * 27 *
33 */ 28 */
34 29
@@ -47,34 +42,12 @@
47#include <linux/list.h> 42#include <linux/list.h>
48#include <linux/uaccess.h> 43#include <linux/uaccess.h>
49 44
50/* Apollo controller specific defines */ 45#include <video/hecubafb.h>
51#define APOLLO_START_NEW_IMG 0xA0
52#define APOLLO_STOP_IMG_DATA 0xA1
53#define APOLLO_DISPLAY_IMG 0xA2
54#define APOLLO_ERASE_DISPLAY 0xA3
55#define APOLLO_INIT_DISPLAY 0xA4
56
57/* Hecuba interface specific defines */
58/* WUP is inverted, CD is inverted, DS is inverted */
59#define HCB_NWUP_BIT 0x01
60#define HCB_NDS_BIT 0x02
61#define HCB_RW_BIT 0x04
62#define HCB_NCD_BIT 0x08
63#define HCB_ACK_BIT 0x80
64 46
65/* Display specific information */ 47/* Display specific information */
66#define DPY_W 600 48#define DPY_W 600
67#define DPY_H 800 49#define DPY_H 800
68 50
69struct hecubafb_par {
70 unsigned long dio_addr;
71 unsigned long cio_addr;
72 unsigned long c2io_addr;
73 unsigned char ctl;
74 struct fb_info *info;
75 unsigned int irq;
76};
77
78static struct fb_fix_screeninfo hecubafb_fix __devinitdata = { 51static struct fb_fix_screeninfo hecubafb_fix __devinitdata = {
79 .id = "hecubafb", 52 .id = "hecubafb",
80 .type = FB_TYPE_PACKED_PIXELS, 53 .type = FB_TYPE_PACKED_PIXELS,
@@ -82,6 +55,7 @@ static struct fb_fix_screeninfo hecubafb_fix __devinitdata = {
82 .xpanstep = 0, 55 .xpanstep = 0,
83 .ypanstep = 0, 56 .ypanstep = 0,
84 .ywrapstep = 0, 57 .ywrapstep = 0,
58 .line_length = DPY_W,
85 .accel = FB_ACCEL_NONE, 59 .accel = FB_ACCEL_NONE,
86}; 60};
87 61
@@ -94,136 +68,51 @@ static struct fb_var_screeninfo hecubafb_var __devinitdata = {
94 .nonstd = 1, 68 .nonstd = 1,
95}; 69};
96 70
97static unsigned long dio_addr; 71/* main hecubafb functions */
98static unsigned long cio_addr;
99static unsigned long c2io_addr;
100static unsigned long splashval;
101static unsigned int nosplash;
102static unsigned int hecubafb_enable;
103static unsigned int irq;
104
105static DECLARE_WAIT_QUEUE_HEAD(hecubafb_waitq);
106
107static void hcb_set_ctl(struct hecubafb_par *par)
108{
109 outb(par->ctl, par->cio_addr);
110}
111
112static unsigned char hcb_get_ctl(struct hecubafb_par *par)
113{
114 return inb(par->c2io_addr);
115}
116
117static void hcb_set_data(struct hecubafb_par *par, unsigned char value)
118{
119 outb(value, par->dio_addr);
120}
121
122static int __devinit apollo_init_control(struct hecubafb_par *par)
123{
124 unsigned char ctl;
125 /* for init, we want the following setup to be set:
126 WUP = lo
127 ACK = hi
128 DS = hi
129 RW = hi
130 CD = lo
131 */
132
133 /* write WUP to lo, DS to hi, RW to hi, CD to lo */
134 par->ctl = HCB_NWUP_BIT | HCB_RW_BIT | HCB_NCD_BIT ;
135 par->ctl &= ~HCB_NDS_BIT;
136 hcb_set_ctl(par);
137
138 /* check ACK is not lo */
139 ctl = hcb_get_ctl(par);
140 if ((ctl & HCB_ACK_BIT)) {
141 printk(KERN_ERR "Fail because ACK is already low\n");
142 return -ENXIO;
143 }
144
145 return 0;
146}
147
148static void hcb_wait_for_ack(struct hecubafb_par *par)
149{
150
151 int timeout;
152 unsigned char ctl;
153
154 timeout=500;
155 do {
156 ctl = hcb_get_ctl(par);
157 if ((ctl & HCB_ACK_BIT))
158 return;
159 udelay(1);
160 } while (timeout--);
161 printk(KERN_ERR "timed out waiting for ack\n");
162}
163
164static void hcb_wait_for_ack_clear(struct hecubafb_par *par)
165{
166
167 int timeout;
168 unsigned char ctl;
169
170 timeout=500;
171 do {
172 ctl = hcb_get_ctl(par);
173 if (!(ctl & HCB_ACK_BIT))
174 return;
175 udelay(1);
176 } while (timeout--);
177 printk(KERN_ERR "timed out waiting for clear\n");
178}
179 72
180static void apollo_send_data(struct hecubafb_par *par, unsigned char data) 73static void apollo_send_data(struct hecubafb_par *par, unsigned char data)
181{ 74{
182 /* set data */ 75 /* set data */
183 hcb_set_data(par, data); 76 par->board->set_data(par, data);
184 77
185 /* set DS low */ 78 /* set DS low */
186 par->ctl |= HCB_NDS_BIT; 79 par->board->set_ctl(par, HCB_DS_BIT, 0);
187 hcb_set_ctl(par);
188 80
189 hcb_wait_for_ack(par); 81 /* wait for ack */
82 par->board->wait_for_ack(par, 0);
190 83
191 /* set DS hi */ 84 /* set DS hi */
192 par->ctl &= ~(HCB_NDS_BIT); 85 par->board->set_ctl(par, HCB_DS_BIT, 1);
193 hcb_set_ctl(par);
194 86
195 hcb_wait_for_ack_clear(par); 87 /* wait for ack to clear */
88 par->board->wait_for_ack(par, 1);
196} 89}
197 90
198static void apollo_send_command(struct hecubafb_par *par, unsigned char data) 91static void apollo_send_command(struct hecubafb_par *par, unsigned char data)
199{ 92{
200 /* command so set CD to high */ 93 /* command so set CD to high */
201 par->ctl &= ~(HCB_NCD_BIT); 94 par->board->set_ctl(par, HCB_CD_BIT, 1);
202 hcb_set_ctl(par);
203 95
204 /* actually strobe with command */ 96 /* actually strobe with command */
205 apollo_send_data(par, data); 97 apollo_send_data(par, data);
206 98
207 /* clear CD back to low */ 99 /* clear CD back to low */
208 par->ctl |= (HCB_NCD_BIT); 100 par->board->set_ctl(par, HCB_CD_BIT, 0);
209 hcb_set_ctl(par);
210} 101}
211 102
212/* main hecubafb functions */
213
214static void hecubafb_dpy_update(struct hecubafb_par *par) 103static void hecubafb_dpy_update(struct hecubafb_par *par)
215{ 104{
216 int i; 105 int i;
217 unsigned char *buf = (unsigned char __force *)par->info->screen_base; 106 unsigned char *buf = (unsigned char __force *)par->info->screen_base;
218 107
219 apollo_send_command(par, 0xA0); 108 apollo_send_command(par, APOLLO_START_NEW_IMG);
220 109
221 for (i=0; i < (DPY_W*DPY_H/8); i++) { 110 for (i=0; i < (DPY_W*DPY_H/8); i++) {
222 apollo_send_data(par, *(buf++)); 111 apollo_send_data(par, *(buf++));
223 } 112 }
224 113
225 apollo_send_command(par, 0xA1); 114 apollo_send_command(par, APOLLO_STOP_IMG_DATA);
226 apollo_send_command(par, 0xA2); 115 apollo_send_command(par, APOLLO_DISPLAY_IMG);
227} 116}
228 117
229/* this is called back from the deferred io workqueue */ 118/* this is called back from the deferred io workqueue */
@@ -270,41 +159,43 @@ static void hecubafb_imageblit(struct fb_info *info,
270static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf, 159static ssize_t hecubafb_write(struct fb_info *info, const char __user *buf,
271 size_t count, loff_t *ppos) 160 size_t count, loff_t *ppos)
272{ 161{
273 unsigned long p; 162 struct hecubafb_par *par = info->par;
274 int err=-EINVAL; 163 unsigned long p = *ppos;
275 struct hecubafb_par *par; 164 void *dst;
276 unsigned int xres; 165 int err = 0;
277 unsigned int fbmemlength; 166 unsigned long total_size;
278 167
279 p = *ppos; 168 if (info->state != FBINFO_STATE_RUNNING)
280 par = info->par; 169 return -EPERM;
281 xres = info->var.xres;
282 fbmemlength = (xres * info->var.yres)/8;
283 170
284 if (p > fbmemlength) 171 total_size = info->fix.smem_len;
285 return -ENOSPC;
286 172
287 err = 0; 173 if (p > total_size)
288 if ((count + p) > fbmemlength) { 174 return -EFBIG;
289 count = fbmemlength - p; 175
290 err = -ENOSPC; 176 if (count > total_size) {
177 err = -EFBIG;
178 count = total_size;
291 } 179 }
292 180
293 if (count) { 181 if (count + p > total_size) {
294 char *base_addr; 182 if (!err)
183 err = -ENOSPC;
295 184
296 base_addr = (char __force *)info->screen_base; 185 count = total_size - p;
297 count -= copy_from_user(base_addr + p, buf, count);
298 *ppos += count;
299 err = -EFAULT;
300 } 186 }
301 187
302 hecubafb_dpy_update(par); 188 dst = (void __force *) (info->screen_base + p);
189
190 if (copy_from_user(dst, buf, count))
191 err = -EFAULT;
303 192
304 if (count) 193 if (!err)
305 return count; 194 *ppos += count;
306 195
307 return err; 196 hecubafb_dpy_update(par);
197
198 return (err) ? err : count;
308} 199}
309 200
310static struct fb_ops hecubafb_ops = { 201static struct fb_ops hecubafb_ops = {
@@ -324,11 +215,21 @@ static struct fb_deferred_io hecubafb_defio = {
324static int __devinit hecubafb_probe(struct platform_device *dev) 215static int __devinit hecubafb_probe(struct platform_device *dev)
325{ 216{
326 struct fb_info *info; 217 struct fb_info *info;
218 struct hecuba_board *board;
327 int retval = -ENOMEM; 219 int retval = -ENOMEM;
328 int videomemorysize; 220 int videomemorysize;
329 unsigned char *videomemory; 221 unsigned char *videomemory;
330 struct hecubafb_par *par; 222 struct hecubafb_par *par;
331 223
224 /* pick up board specific routines */
225 board = dev->dev.platform_data;
226 if (!board)
227 return -EINVAL;
228
229 /* try to count device specific driver, if can't, platform recalls */
230 if (!try_module_get(board->owner))
231 return -ENODEV;
232
332 videomemorysize = (DPY_W*DPY_H)/8; 233 videomemorysize = (DPY_W*DPY_H)/8;
333 234
334 if (!(videomemory = vmalloc(videomemorysize))) 235 if (!(videomemory = vmalloc(videomemorysize)))
@@ -338,9 +239,9 @@ static int __devinit hecubafb_probe(struct platform_device *dev)
338 239
339 info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev); 240 info = framebuffer_alloc(sizeof(struct hecubafb_par), &dev->dev);
340 if (!info) 241 if (!info)
341 goto err; 242 goto err_fballoc;
342 243
343 info->screen_base = (char __iomem *) videomemory; 244 info->screen_base = (char __force __iomem *)videomemory;
344 info->fbops = &hecubafb_ops; 245 info->fbops = &hecubafb_ops;
345 246
346 info->var = hecubafb_var; 247 info->var = hecubafb_var;
@@ -348,14 +249,10 @@ static int __devinit hecubafb_probe(struct platform_device *dev)
348 info->fix.smem_len = videomemorysize; 249 info->fix.smem_len = videomemorysize;
349 par = info->par; 250 par = info->par;
350 par->info = info; 251 par->info = info;
252 par->board = board;
253 par->send_command = apollo_send_command;
254 par->send_data = apollo_send_data;
351 255
352 if (!dio_addr || !cio_addr || !c2io_addr) {
353 printk(KERN_WARNING "no IO addresses supplied\n");
354 goto err1;
355 }
356 par->dio_addr = dio_addr;
357 par->cio_addr = cio_addr;
358 par->c2io_addr = c2io_addr;
359 info->flags = FBINFO_FLAG_DEFAULT; 256 info->flags = FBINFO_FLAG_DEFAULT;
360 257
361 info->fbdefio = &hecubafb_defio; 258 info->fbdefio = &hecubafb_defio;
@@ -363,7 +260,7 @@ static int __devinit hecubafb_probe(struct platform_device *dev)
363 260
364 retval = register_framebuffer(info); 261 retval = register_framebuffer(info);
365 if (retval < 0) 262 if (retval < 0)
366 goto err1; 263 goto err_fbreg;
367 platform_set_drvdata(dev, info); 264 platform_set_drvdata(dev, info);
368 265
369 printk(KERN_INFO 266 printk(KERN_INFO
@@ -371,25 +268,16 @@ static int __devinit hecubafb_probe(struct platform_device *dev)
371 info->node, videomemorysize >> 10); 268 info->node, videomemorysize >> 10);
372 269
373 /* this inits the dpy */ 270 /* this inits the dpy */
374 apollo_init_control(par); 271 retval = par->board->init(par);
375 272 if (retval < 0)
376 apollo_send_command(par, APOLLO_INIT_DISPLAY); 273 goto err_fbreg;
377 apollo_send_data(par, 0x81);
378
379 /* have to wait while display resets */
380 udelay(1000);
381
382 /* if we were told to splash the screen, we just clear it */
383 if (!nosplash) {
384 apollo_send_command(par, APOLLO_ERASE_DISPLAY);
385 apollo_send_data(par, splashval);
386 }
387 274
388 return 0; 275 return 0;
389err1: 276err_fbreg:
390 framebuffer_release(info); 277 framebuffer_release(info);
391err: 278err_fballoc:
392 vfree(videomemory); 279 vfree(videomemory);
280 module_put(board->owner);
393 return retval; 281 return retval;
394} 282}
395 283
@@ -398,9 +286,13 @@ static int __devexit hecubafb_remove(struct platform_device *dev)
398 struct fb_info *info = platform_get_drvdata(dev); 286 struct fb_info *info = platform_get_drvdata(dev);
399 287
400 if (info) { 288 if (info) {
289 struct hecubafb_par *par = info->par;
401 fb_deferred_io_cleanup(info); 290 fb_deferred_io_cleanup(info);
402 unregister_framebuffer(info); 291 unregister_framebuffer(info);
403 vfree((void __force *)info->screen_base); 292 vfree((void __force *)info->screen_base);
293 if (par->board->remove)
294 par->board->remove(par);
295 module_put(par->board->owner);
404 framebuffer_release(info); 296 framebuffer_release(info);
405 } 297 }
406 return 0; 298 return 0;
@@ -410,62 +302,24 @@ static struct platform_driver hecubafb_driver = {
410 .probe = hecubafb_probe, 302 .probe = hecubafb_probe,
411 .remove = hecubafb_remove, 303 .remove = hecubafb_remove,
412 .driver = { 304 .driver = {
305 .owner = THIS_MODULE,
413 .name = "hecubafb", 306 .name = "hecubafb",
414 }, 307 },
415}; 308};
416 309
417static struct platform_device *hecubafb_device;
418
419static int __init hecubafb_init(void) 310static int __init hecubafb_init(void)
420{ 311{
421 int ret; 312 return platform_driver_register(&hecubafb_driver);
422
423 if (!hecubafb_enable) {
424 printk(KERN_ERR "Use hecubafb_enable to enable the device\n");
425 return -ENXIO;
426 }
427
428 ret = platform_driver_register(&hecubafb_driver);
429 if (!ret) {
430 hecubafb_device = platform_device_alloc("hecubafb", 0);
431 if (hecubafb_device)
432 ret = platform_device_add(hecubafb_device);
433 else
434 ret = -ENOMEM;
435
436 if (ret) {
437 platform_device_put(hecubafb_device);
438 platform_driver_unregister(&hecubafb_driver);
439 }
440 }
441 return ret;
442
443} 313}
444 314
445static void __exit hecubafb_exit(void) 315static void __exit hecubafb_exit(void)
446{ 316{
447 platform_device_unregister(hecubafb_device);
448 platform_driver_unregister(&hecubafb_driver); 317 platform_driver_unregister(&hecubafb_driver);
449} 318}
450 319
451module_param(nosplash, uint, 0);
452MODULE_PARM_DESC(nosplash, "Disable doing the splash screen");
453module_param(hecubafb_enable, uint, 0);
454MODULE_PARM_DESC(hecubafb_enable, "Enable communication with Hecuba board");
455module_param(dio_addr, ulong, 0);
456MODULE_PARM_DESC(dio_addr, "IO address for data, eg: 0x480");
457module_param(cio_addr, ulong, 0);
458MODULE_PARM_DESC(cio_addr, "IO address for control, eg: 0x400");
459module_param(c2io_addr, ulong, 0);
460MODULE_PARM_DESC(c2io_addr, "IO address for secondary control, eg: 0x408");
461module_param(splashval, ulong, 0);
462MODULE_PARM_DESC(splashval, "Splash pattern: 0x00 is black, 0x01 is white");
463module_param(irq, uint, 0);
464MODULE_PARM_DESC(irq, "IRQ for the Hecuba board");
465
466module_init(hecubafb_init); 320module_init(hecubafb_init);
467module_exit(hecubafb_exit); 321module_exit(hecubafb_exit);
468 322
469MODULE_DESCRIPTION("fbdev driver for Hecuba board"); 323MODULE_DESCRIPTION("fbdev driver for Hecuba/Apollo controller");
470MODULE_AUTHOR("Jaya Kumar"); 324MODULE_AUTHOR("Jaya Kumar");
471MODULE_LICENSE("GPL"); 325MODULE_LICENSE("GPL");
diff --git a/drivers/video/imsttfb.c b/drivers/video/imsttfb.c
index 3ab91bf21576..15d50b9906ce 100644
--- a/drivers/video/imsttfb.c
+++ b/drivers/video/imsttfb.c
@@ -1151,8 +1151,10 @@ imsttfb_load_cursor_image(struct imstt_par *par, int width, int height, __u8 fgc
1151 par->cmap_regs[TVPCRDAT] = 0xff; eieio(); 1151 par->cmap_regs[TVPCRDAT] = 0xff; eieio();
1152 } 1152 }
1153 par->cmap_regs[TVPCADRW] = 0x00; eieio(); 1153 par->cmap_regs[TVPCADRW] = 0x00; eieio();
1154 for (x = 0; x < 12; x++) 1154 for (x = 0; x < 12; x++) {
1155 par->cmap_regs[TVPCDATA] = fgc; eieio(); 1155 par->cmap_regs[TVPCDATA] = fgc;
1156 eieio();
1157 }
1156 } 1158 }
1157 return 1; 1159 return 1;
1158} 1160}
@@ -1476,7 +1478,7 @@ imsttfb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1476 1478
1477 dp = pci_device_to_OF_node(pdev); 1479 dp = pci_device_to_OF_node(pdev);
1478 if(dp) 1480 if(dp)
1479 printk(KERN_INFO "%s: OF name %s\n",__FUNCTION__, dp->name); 1481 printk(KERN_INFO "%s: OF name %s\n",__func__, dp->name);
1480 else 1482 else
1481 printk(KERN_ERR "imsttfb: no OF node for pci device\n"); 1483 printk(KERN_ERR "imsttfb: no OF node for pci device\n");
1482#endif /* CONFIG_PPC_OF */ 1484#endif /* CONFIG_PPC_OF */
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index 11609552a387..94e4d3ac1a05 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -415,7 +415,7 @@ static void imxfb_setup_gpio(struct imxfb_info *fbi)
415static int imxfb_suspend(struct platform_device *dev, pm_message_t state) 415static int imxfb_suspend(struct platform_device *dev, pm_message_t state)
416{ 416{
417 struct imxfb_info *fbi = platform_get_drvdata(dev); 417 struct imxfb_info *fbi = platform_get_drvdata(dev);
418 pr_debug("%s\n",__FUNCTION__); 418 pr_debug("%s\n",__func__);
419 419
420 imxfb_disable_controller(fbi); 420 imxfb_disable_controller(fbi);
421 return 0; 421 return 0;
@@ -424,7 +424,7 @@ static int imxfb_suspend(struct platform_device *dev, pm_message_t state)
424static int imxfb_resume(struct platform_device *dev) 424static int imxfb_resume(struct platform_device *dev)
425{ 425{
426 struct imxfb_info *fbi = platform_get_drvdata(dev); 426 struct imxfb_info *fbi = platform_get_drvdata(dev);
427 pr_debug("%s\n",__FUNCTION__); 427 pr_debug("%s\n",__func__);
428 428
429 imxfb_enable_controller(fbi); 429 imxfb_enable_controller(fbi);
430 return 0; 430 return 0;
@@ -440,7 +440,7 @@ static int __init imxfb_init_fbinfo(struct device *dev)
440 struct fb_info *info = dev_get_drvdata(dev); 440 struct fb_info *info = dev_get_drvdata(dev);
441 struct imxfb_info *fbi = info->par; 441 struct imxfb_info *fbi = info->par;
442 442
443 pr_debug("%s\n",__FUNCTION__); 443 pr_debug("%s\n",__func__);
444 444
445 info->pseudo_palette = kmalloc( sizeof(u32) * 16, GFP_KERNEL); 445 info->pseudo_palette = kmalloc( sizeof(u32) * 16, GFP_KERNEL);
446 if (!info->pseudo_palette) 446 if (!info->pseudo_palette)
diff --git a/drivers/video/intelfb/intelfb.h b/drivers/video/intelfb/intelfb.h
index 836796177942..3325fbd68ab3 100644
--- a/drivers/video/intelfb/intelfb.h
+++ b/drivers/video/intelfb/intelfb.h
@@ -12,9 +12,9 @@
12#endif 12#endif
13 13
14/*** Version/name ***/ 14/*** Version/name ***/
15#define INTELFB_VERSION "0.9.4" 15#define INTELFB_VERSION "0.9.5"
16#define INTELFB_MODULE_NAME "intelfb" 16#define INTELFB_MODULE_NAME "intelfb"
17#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM" 17#define SUPPORTED_CHIPSETS "830M/845G/852GM/855GM/865G/915G/915GM/945G/945GM/965G/965GM"
18 18
19 19
20/*** Debug/feature defines ***/ 20/*** Debug/feature defines ***/
@@ -58,6 +58,8 @@
58#define PCI_DEVICE_ID_INTEL_915GM 0x2592 58#define PCI_DEVICE_ID_INTEL_915GM 0x2592
59#define PCI_DEVICE_ID_INTEL_945G 0x2772 59#define PCI_DEVICE_ID_INTEL_945G 0x2772
60#define PCI_DEVICE_ID_INTEL_945GM 0x27A2 60#define PCI_DEVICE_ID_INTEL_945GM 0x27A2
61#define PCI_DEVICE_ID_INTEL_965G 0x29A2
62#define PCI_DEVICE_ID_INTEL_965GM 0x2A02
61 63
62/* Size of MMIO region */ 64/* Size of MMIO region */
63#define INTEL_REG_SIZE 0x80000 65#define INTEL_REG_SIZE 0x80000
@@ -158,6 +160,8 @@ enum intel_chips {
158 INTEL_915GM, 160 INTEL_915GM,
159 INTEL_945G, 161 INTEL_945G,
160 INTEL_945GM, 162 INTEL_945GM,
163 INTEL_965G,
164 INTEL_965GM,
161}; 165};
162 166
163struct intelfb_hwstate { 167struct intelfb_hwstate {
@@ -358,7 +362,9 @@ struct intelfb_info {
358#define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G) || \ 362#define IS_I9XX(dinfo) (((dinfo)->chipset == INTEL_915G) || \
359 ((dinfo)->chipset == INTEL_915GM) || \ 363 ((dinfo)->chipset == INTEL_915GM) || \
360 ((dinfo)->chipset == INTEL_945G) || \ 364 ((dinfo)->chipset == INTEL_945G) || \
361 ((dinfo)->chipset==INTEL_945GM)) 365 ((dinfo)->chipset == INTEL_945GM) || \
366 ((dinfo)->chipset == INTEL_965G) || \
367 ((dinfo)->chipset == INTEL_965GM))
362 368
363#ifndef FBIO_WAITFORVSYNC 369#ifndef FBIO_WAITFORVSYNC
364#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32) 370#define FBIO_WAITFORVSYNC _IOW('F', 0x20, __u32)
diff --git a/drivers/video/intelfb/intelfb_i2c.c b/drivers/video/intelfb/intelfb_i2c.c
index 94c08bb5acf1..ca95f09d8b43 100644
--- a/drivers/video/intelfb/intelfb_i2c.c
+++ b/drivers/video/intelfb/intelfb_i2c.c
@@ -169,6 +169,8 @@ void intelfb_create_i2c_busses(struct intelfb_info *dinfo)
169 /* has some LVDS + tv-out */ 169 /* has some LVDS + tv-out */
170 case INTEL_945G: 170 case INTEL_945G:
171 case INTEL_945GM: 171 case INTEL_945GM:
172 case INTEL_965G:
173 case INTEL_965GM:
172 /* SDVO ports have a single control bus - 2 devices */ 174 /* SDVO ports have a single control bus - 2 devices */
173 dinfo->output[i].type = INTELFB_OUTPUT_SDVO; 175 dinfo->output[i].type = INTELFB_OUTPUT_SDVO;
174 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].i2c_bus, 176 intelfb_setup_i2c_bus(dinfo, &dinfo->output[i].i2c_bus,
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 481d58f7535d..e44303f9bc52 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -2,7 +2,7 @@
2 * intelfb 2 * intelfb
3 * 3 *
4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/ 4 * Linux framebuffer driver for Intel(R) 830M/845G/852GM/855GM/865G/915G/915GM/
5 * 945G/945GM integrated graphics chips. 5 * 945G/945GM/965G/965GM integrated graphics chips.
6 * 6 *
7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org> 7 * Copyright © 2002, 2003 David Dawes <dawes@xfree86.org>
8 * 2004 Sylvain Meyer 8 * 2004 Sylvain Meyer
@@ -99,6 +99,9 @@
99 * Add vram option to reserve more memory than stolen by BIOS 99 * Add vram option to reserve more memory than stolen by BIOS
100 * Fix intelfbhw_pan_display typo 100 * Fix intelfbhw_pan_display typo
101 * Add __initdata annotations 101 * Add __initdata annotations
102 *
103 * 04/2008 - Version 0.9.5
104 * Add support for 965G/965GM. (Maik Broemme <mbroemme@plusserver.de>)
102 */ 105 */
103 106
104#include <linux/module.h> 107#include <linux/module.h>
@@ -180,6 +183,8 @@ static struct pci_device_id intelfb_pci_table[] __devinitdata = {
180 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM }, 183 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_915GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_915GM },
181 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G }, 184 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945G },
182 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GM }, 185 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_945GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_945GM },
186 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965G, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965G },
187 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_965GM, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_DISPLAY_VGA << 8, INTELFB_CLASS_MASK, INTEL_965GM },
183 { 0, } 188 { 0, }
184}; 189};
185 190
@@ -549,7 +554,10 @@ static int __devinit intelfb_pci_register(struct pci_dev *pdev,
549 if ((ent->device == PCI_DEVICE_ID_INTEL_915G) || 554 if ((ent->device == PCI_DEVICE_ID_INTEL_915G) ||
550 (ent->device == PCI_DEVICE_ID_INTEL_915GM) || 555 (ent->device == PCI_DEVICE_ID_INTEL_915GM) ||
551 (ent->device == PCI_DEVICE_ID_INTEL_945G) || 556 (ent->device == PCI_DEVICE_ID_INTEL_945G) ||
552 (ent->device == PCI_DEVICE_ID_INTEL_945GM)) { 557 (ent->device == PCI_DEVICE_ID_INTEL_945GM) ||
558 (ent->device == PCI_DEVICE_ID_INTEL_965G) ||
559 (ent->device == PCI_DEVICE_ID_INTEL_965GM)) {
560
553 aperture_bar = 2; 561 aperture_bar = 2;
554 mmio_bar = 0; 562 mmio_bar = 0;
555 } 563 }
diff --git a/drivers/video/intelfb/intelfbhw.c b/drivers/video/intelfb/intelfbhw.c
index fa1fff553565..8e6d6a4db0ad 100644
--- a/drivers/video/intelfb/intelfbhw.c
+++ b/drivers/video/intelfb/intelfbhw.c
@@ -143,6 +143,18 @@ int intelfbhw_get_chipset(struct pci_dev *pdev, struct intelfb_info *dinfo)
143 dinfo->mobile = 1; 143 dinfo->mobile = 1;
144 dinfo->pll_index = PLLS_I9xx; 144 dinfo->pll_index = PLLS_I9xx;
145 return 0; 145 return 0;
146 case PCI_DEVICE_ID_INTEL_965G:
147 dinfo->name = "Intel(R) 965G";
148 dinfo->chipset = INTEL_965G;
149 dinfo->mobile = 0;
150 dinfo->pll_index = PLLS_I9xx;
151 return 0;
152 case PCI_DEVICE_ID_INTEL_965GM:
153 dinfo->name = "Intel(R) 965GM";
154 dinfo->chipset = INTEL_965GM;
155 dinfo->mobile = 1;
156 dinfo->pll_index = PLLS_I9xx;
157 return 0;
146 default: 158 default:
147 return 1; 159 return 1;
148 } 160 }
@@ -174,7 +186,9 @@ int intelfbhw_get_memory(struct pci_dev *pdev, int *aperture_size,
174 case PCI_DEVICE_ID_INTEL_915GM: 186 case PCI_DEVICE_ID_INTEL_915GM:
175 case PCI_DEVICE_ID_INTEL_945G: 187 case PCI_DEVICE_ID_INTEL_945G:
176 case PCI_DEVICE_ID_INTEL_945GM: 188 case PCI_DEVICE_ID_INTEL_945GM:
177 /* 915 and 945 chipsets support a 256MB aperture. 189 case PCI_DEVICE_ID_INTEL_965G:
190 case PCI_DEVICE_ID_INTEL_965GM:
191 /* 915, 945 and 965 chipsets support a 256MB aperture.
178 Aperture size is determined by inspected the 192 Aperture size is determined by inspected the
179 base address of the aperture. */ 193 base address of the aperture. */
180 if (pci_resource_start(pdev, 2) & 0x08000000) 194 if (pci_resource_start(pdev, 2) & 0x08000000)
diff --git a/drivers/video/leo.c b/drivers/video/leo.c
index 45b9a5d55dec..f3160fc29795 100644
--- a/drivers/video/leo.c
+++ b/drivers/video/leo.c
@@ -614,7 +614,7 @@ static int __devinit leo_probe(struct of_device *op, const struct of_device_id *
614 614
615 dev_set_drvdata(&op->dev, info); 615 dev_set_drvdata(&op->dev, info);
616 616
617 printk("%s: leo at %lx:%lx\n", 617 printk(KERN_INFO "%s: leo at %lx:%lx\n",
618 dp->full_name, 618 dp->full_name,
619 par->which_io, par->physbase); 619 par->which_io, par->physbase);
620 620
diff --git a/drivers/video/matrox/matroxfb_DAC1064.c b/drivers/video/matrox/matroxfb_DAC1064.c
index c4b570b4a4df..0ce3b0a89798 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.c
+++ b/drivers/video/matrox/matroxfb_DAC1064.c
@@ -37,7 +37,7 @@ static void DAC1064_calcclock(CPMINFO unsigned int freq, unsigned int fmax, unsi
37 unsigned int fvco; 37 unsigned int fvco;
38 unsigned int p; 38 unsigned int p;
39 39
40 DBG(__FUNCTION__) 40 DBG(__func__)
41 41
42 /* only for devices older than G450 */ 42 /* only for devices older than G450 */
43 43
@@ -83,7 +83,7 @@ static const unsigned char MGA1064_DAC[] = {
83static void DAC1064_setpclk(WPMINFO unsigned long fout) { 83static void DAC1064_setpclk(WPMINFO unsigned long fout) {
84 unsigned int m, n, p; 84 unsigned int m, n, p;
85 85
86 DBG(__FUNCTION__) 86 DBG(__func__)
87 87
88 DAC1064_calcclock(PMINFO fout, ACCESS_FBINFO(max_pixel_clock), &m, &n, &p); 88 DAC1064_calcclock(PMINFO fout, ACCESS_FBINFO(max_pixel_clock), &m, &n, &p);
89 ACCESS_FBINFO(hw).DACclk[0] = m; 89 ACCESS_FBINFO(hw).DACclk[0] = m;
@@ -95,7 +95,7 @@ static void DAC1064_setmclk(WPMINFO int oscinfo, unsigned long fmem) {
95 u_int32_t mx; 95 u_int32_t mx;
96 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 96 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
97 97
98 DBG(__FUNCTION__) 98 DBG(__func__)
99 99
100 if (ACCESS_FBINFO(devflags.noinit)) { 100 if (ACCESS_FBINFO(devflags.noinit)) {
101 /* read MCLK and give up... */ 101 /* read MCLK and give up... */
@@ -338,7 +338,7 @@ void DAC1064_global_restore(WPMINFO2) {
338static int DAC1064_init_1(WPMINFO struct my_timming* m) { 338static int DAC1064_init_1(WPMINFO struct my_timming* m) {
339 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 339 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
340 340
341 DBG(__FUNCTION__) 341 DBG(__func__)
342 342
343 memcpy(hw->DACreg, MGA1064_DAC, sizeof(MGA1064_DAC_regs)); 343 memcpy(hw->DACreg, MGA1064_DAC, sizeof(MGA1064_DAC_regs));
344 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) { 344 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
@@ -374,7 +374,7 @@ static int DAC1064_init_1(WPMINFO struct my_timming* m) {
374static int DAC1064_init_2(WPMINFO struct my_timming* m) { 374static int DAC1064_init_2(WPMINFO struct my_timming* m) {
375 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 375 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
376 376
377 DBG(__FUNCTION__) 377 DBG(__func__)
378 378
379 if (ACCESS_FBINFO(fbcon).var.bits_per_pixel > 16) { /* 256 entries */ 379 if (ACCESS_FBINFO(fbcon).var.bits_per_pixel > 16) { /* 256 entries */
380 int i; 380 int i;
@@ -418,7 +418,7 @@ static void DAC1064_restore_1(WPMINFO2) {
418 418
419 CRITFLAGS 419 CRITFLAGS
420 420
421 DBG(__FUNCTION__) 421 DBG(__func__)
422 422
423 CRITBEGIN 423 CRITBEGIN
424 424
@@ -448,7 +448,7 @@ static void DAC1064_restore_2(WPMINFO2) {
448 unsigned int i; 448 unsigned int i;
449#endif 449#endif
450 450
451 DBG(__FUNCTION__) 451 DBG(__func__)
452 452
453#ifdef DEBUG 453#ifdef DEBUG
454 dprintk(KERN_DEBUG "DAC1064regs "); 454 dprintk(KERN_DEBUG "DAC1064regs ");
@@ -521,7 +521,7 @@ static struct matrox_altout g450out = {
521static int MGA1064_init(WPMINFO struct my_timming* m) { 521static int MGA1064_init(WPMINFO struct my_timming* m) {
522 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 522 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
523 523
524 DBG(__FUNCTION__) 524 DBG(__func__)
525 525
526 if (DAC1064_init_1(PMINFO m)) return 1; 526 if (DAC1064_init_1(PMINFO m)) return 1;
527 if (matroxfb_vgaHWinit(PMINFO m)) return 1; 527 if (matroxfb_vgaHWinit(PMINFO m)) return 1;
@@ -543,7 +543,7 @@ static int MGA1064_init(WPMINFO struct my_timming* m) {
543static int MGAG100_init(WPMINFO struct my_timming* m) { 543static int MGAG100_init(WPMINFO struct my_timming* m) {
544 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 544 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
545 545
546 DBG(__FUNCTION__) 546 DBG(__func__)
547 547
548 if (DAC1064_init_1(PMINFO m)) return 1; 548 if (DAC1064_init_1(PMINFO m)) return 1;
549 hw->MXoptionReg &= ~0x2000; 549 hw->MXoptionReg &= ~0x2000;
@@ -565,7 +565,7 @@ static int MGAG100_init(WPMINFO struct my_timming* m) {
565#ifdef CONFIG_FB_MATROX_MYSTIQUE 565#ifdef CONFIG_FB_MATROX_MYSTIQUE
566static void MGA1064_ramdac_init(WPMINFO2) { 566static void MGA1064_ramdac_init(WPMINFO2) {
567 567
568 DBG(__FUNCTION__) 568 DBG(__func__)
569 569
570 /* ACCESS_FBINFO(features.DAC1064.vco_freq_min) = 120000; */ 570 /* ACCESS_FBINFO(features.DAC1064.vco_freq_min) = 120000; */
571 ACCESS_FBINFO(features.pll.vco_freq_min) = 62000; 571 ACCESS_FBINFO(features.pll.vco_freq_min) = 62000;
@@ -594,7 +594,7 @@ static void MGAG100_progPixClock(CPMINFO int flags, int m, int n, int p) {
594 int selClk; 594 int selClk;
595 int clk; 595 int clk;
596 596
597 DBG(__FUNCTION__) 597 DBG(__func__)
598 598
599 outDAC1064(PMINFO M1064_XPIXCLKCTRL, inDAC1064(PMINFO M1064_XPIXCLKCTRL) | M1064_XPIXCLKCTRL_DIS | 599 outDAC1064(PMINFO M1064_XPIXCLKCTRL, inDAC1064(PMINFO M1064_XPIXCLKCTRL) | M1064_XPIXCLKCTRL_DIS |
600 M1064_XPIXCLKCTRL_PLL_UP); 600 M1064_XPIXCLKCTRL_PLL_UP);
@@ -636,7 +636,7 @@ static void MGAG100_progPixClock(CPMINFO int flags, int m, int n, int p) {
636static void MGAG100_setPixClock(CPMINFO int flags, int freq) { 636static void MGAG100_setPixClock(CPMINFO int flags, int freq) {
637 unsigned int m, n, p; 637 unsigned int m, n, p;
638 638
639 DBG(__FUNCTION__) 639 DBG(__func__)
640 640
641 DAC1064_calcclock(PMINFO freq, ACCESS_FBINFO(max_pixel_clock), &m, &n, &p); 641 DAC1064_calcclock(PMINFO freq, ACCESS_FBINFO(max_pixel_clock), &m, &n, &p);
642 MGAG100_progPixClock(PMINFO flags, m, n, p); 642 MGAG100_progPixClock(PMINFO flags, m, n, p);
@@ -650,7 +650,7 @@ static int MGA1064_preinit(WPMINFO2) {
650 2048, 0}; 650 2048, 0};
651 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 651 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
652 652
653 DBG(__FUNCTION__) 653 DBG(__func__)
654 654
655 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */ 655 /* ACCESS_FBINFO(capable.cfb4) = 0; ... preinitialized by 0 */
656 ACCESS_FBINFO(capable.text) = 1; 656 ACCESS_FBINFO(capable.text) = 1;
@@ -683,7 +683,7 @@ static int MGA1064_preinit(WPMINFO2) {
683 683
684static void MGA1064_reset(WPMINFO2) { 684static void MGA1064_reset(WPMINFO2) {
685 685
686 DBG(__FUNCTION__); 686 DBG(__func__);
687 687
688 MGA1064_ramdac_init(PMINFO2); 688 MGA1064_ramdac_init(PMINFO2);
689} 689}
@@ -819,7 +819,7 @@ static int MGAG100_preinit(WPMINFO2) {
819 u_int32_t q; 819 u_int32_t q;
820#endif 820#endif
821 821
822 DBG(__FUNCTION__) 822 DBG(__func__)
823 823
824 /* there are some instabilities if in_div > 19 && vco < 61000 */ 824 /* there are some instabilities if in_div > 19 && vco < 61000 */
825 if (ACCESS_FBINFO(devflags.g450dac)) { 825 if (ACCESS_FBINFO(devflags.g450dac)) {
@@ -956,7 +956,7 @@ static void MGAG100_reset(WPMINFO2) {
956 u_int8_t b; 956 u_int8_t b;
957 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 957 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
958 958
959 DBG(__FUNCTION__) 959 DBG(__func__)
960 960
961 { 961 {
962#ifdef G100_BROKEN_IBM_82351 962#ifdef G100_BROKEN_IBM_82351
@@ -1015,7 +1015,7 @@ static void MGA1064_restore(WPMINFO2) {
1015 1015
1016 CRITFLAGS 1016 CRITFLAGS
1017 1017
1018 DBG(__FUNCTION__) 1018 DBG(__func__)
1019 1019
1020 CRITBEGIN 1020 CRITBEGIN
1021 1021
@@ -1041,7 +1041,7 @@ static void MGAG100_restore(WPMINFO2) {
1041 1041
1042 CRITFLAGS 1042 CRITFLAGS
1043 1043
1044 DBG(__FUNCTION__) 1044 DBG(__func__)
1045 1045
1046 CRITBEGIN 1046 CRITBEGIN
1047 1047
diff --git a/drivers/video/matrox/matroxfb_Ti3026.c b/drivers/video/matrox/matroxfb_Ti3026.c
index 9445cdb759b1..13524821e242 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.c
+++ b/drivers/video/matrox/matroxfb_Ti3026.c
@@ -283,7 +283,7 @@ static int Ti3026_calcclock(CPMINFO unsigned int freq, unsigned int fmax, int* i
283 unsigned int fvco; 283 unsigned int fvco;
284 unsigned int lin, lfeed, lpost; 284 unsigned int lin, lfeed, lpost;
285 285
286 DBG(__FUNCTION__) 286 DBG(__func__)
287 287
288 fvco = PLL_calcclock(PMINFO freq, fmax, &lin, &lfeed, &lpost); 288 fvco = PLL_calcclock(PMINFO freq, fmax, &lin, &lfeed, &lpost);
289 fvco >>= (*post = lpost); 289 fvco >>= (*post = lpost);
@@ -297,7 +297,7 @@ static int Ti3026_setpclk(WPMINFO int clk) {
297 unsigned int pixfeed, pixin, pixpost; 297 unsigned int pixfeed, pixin, pixpost;
298 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 298 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
299 299
300 DBG(__FUNCTION__) 300 DBG(__func__)
301 301
302 f_pll = Ti3026_calcclock(PMINFO clk, ACCESS_FBINFO(max_pixel_clock), &pixin, &pixfeed, &pixpost); 302 f_pll = Ti3026_calcclock(PMINFO clk, ACCESS_FBINFO(max_pixel_clock), &pixin, &pixfeed, &pixpost);
303 303
@@ -365,7 +365,7 @@ static int Ti3026_init(WPMINFO struct my_timming* m) {
365 u_int8_t muxctrl = isInterleave(MINFO) ? TVP3026_XMUXCTRL_MEMORY_64BIT : TVP3026_XMUXCTRL_MEMORY_32BIT; 365 u_int8_t muxctrl = isInterleave(MINFO) ? TVP3026_XMUXCTRL_MEMORY_64BIT : TVP3026_XMUXCTRL_MEMORY_32BIT;
366 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 366 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
367 367
368 DBG(__FUNCTION__) 368 DBG(__func__)
369 369
370 memcpy(hw->DACreg, MGADACbpp32, sizeof(hw->DACreg)); 370 memcpy(hw->DACreg, MGADACbpp32, sizeof(hw->DACreg));
371 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) { 371 switch (ACCESS_FBINFO(fbcon).var.bits_per_pixel) {
@@ -440,7 +440,7 @@ static void ti3026_setMCLK(WPMINFO int fout){
440 unsigned int rfhcnt, mclk_ctl; 440 unsigned int rfhcnt, mclk_ctl;
441 int tmout; 441 int tmout;
442 442
443 DBG(__FUNCTION__) 443 DBG(__func__)
444 444
445 f_pll = Ti3026_calcclock(PMINFO fout, ACCESS_FBINFO(max_pixel_clock), &mclk_n, &mclk_m, &mclk_p); 445 f_pll = Ti3026_calcclock(PMINFO fout, ACCESS_FBINFO(max_pixel_clock), &mclk_n, &mclk_m, &mclk_p);
446 446
@@ -534,7 +534,7 @@ static void ti3026_setMCLK(WPMINFO int fout){
534 534
535static void ti3026_ramdac_init(WPMINFO2) { 535static void ti3026_ramdac_init(WPMINFO2) {
536 536
537 DBG(__FUNCTION__) 537 DBG(__func__)
538 538
539 ACCESS_FBINFO(features.pll.vco_freq_min) = 110000; 539 ACCESS_FBINFO(features.pll.vco_freq_min) = 110000;
540 ACCESS_FBINFO(features.pll.ref_freq) = 114545; 540 ACCESS_FBINFO(features.pll.ref_freq) = 114545;
@@ -554,7 +554,7 @@ static void Ti3026_restore(WPMINFO2) {
554 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 554 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
555 CRITFLAGS 555 CRITFLAGS
556 556
557 DBG(__FUNCTION__) 557 DBG(__func__)
558 558
559#ifdef DEBUG 559#ifdef DEBUG
560 dprintk(KERN_INFO "EXTVGA regs: "); 560 dprintk(KERN_INFO "EXTVGA regs: ");
@@ -662,7 +662,7 @@ static void Ti3026_restore(WPMINFO2) {
662 662
663static void Ti3026_reset(WPMINFO2) { 663static void Ti3026_reset(WPMINFO2) {
664 664
665 DBG(__FUNCTION__) 665 DBG(__func__)
666 666
667 ti3026_ramdac_init(PMINFO2); 667 ti3026_ramdac_init(PMINFO2);
668} 668}
@@ -680,7 +680,7 @@ static int Ti3026_preinit(WPMINFO2) {
680 2048, 0}; 680 2048, 0};
681 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw); 681 struct matrox_hw_state* hw = &ACCESS_FBINFO(hw);
682 682
683 DBG(__FUNCTION__) 683 DBG(__func__)
684 684
685 ACCESS_FBINFO(millenium) = 1; 685 ACCESS_FBINFO(millenium) = 1;
686 ACCESS_FBINFO(milleniumII) = (ACCESS_FBINFO(pcidev)->device != PCI_DEVICE_ID_MATROX_MIL); 686 ACCESS_FBINFO(milleniumII) = (ACCESS_FBINFO(pcidev)->device != PCI_DEVICE_ID_MATROX_MIL);
diff --git a/drivers/video/matrox/matroxfb_accel.c b/drivers/video/matrox/matroxfb_accel.c
index 3660d2673bdc..9c3aeee1cc4f 100644
--- a/drivers/video/matrox/matroxfb_accel.c
+++ b/drivers/video/matrox/matroxfb_accel.c
@@ -113,7 +113,7 @@ void matrox_cfbX_init(WPMINFO2) {
113 u_int32_t mopmode; 113 u_int32_t mopmode;
114 int accel; 114 int accel;
115 115
116 DBG(__FUNCTION__) 116 DBG(__func__)
117 117
118 mpitch = ACCESS_FBINFO(fbcon).var.xres_virtual; 118 mpitch = ACCESS_FBINFO(fbcon).var.xres_virtual;
119 119
@@ -199,7 +199,7 @@ static void matrox_accel_bmove(WPMINFO int vxres, int sy, int sx, int dy, int dx
199 int start, end; 199 int start, end;
200 CRITFLAGS 200 CRITFLAGS
201 201
202 DBG(__FUNCTION__) 202 DBG(__func__)
203 203
204 CRITBEGIN 204 CRITBEGIN
205 205
@@ -235,7 +235,7 @@ static void matrox_accel_bmove_lin(WPMINFO int vxres, int sy, int sx, int dy, in
235 int start, end; 235 int start, end;
236 CRITFLAGS 236 CRITFLAGS
237 237
238 DBG(__FUNCTION__) 238 DBG(__func__)
239 239
240 CRITBEGIN 240 CRITBEGIN
241 241
@@ -287,7 +287,7 @@ static void matroxfb_accel_clear(WPMINFO u_int32_t color, int sy, int sx, int he
287 int width) { 287 int width) {
288 CRITFLAGS 288 CRITFLAGS
289 289
290 DBG(__FUNCTION__) 290 DBG(__func__)
291 291
292 CRITBEGIN 292 CRITBEGIN
293 293
@@ -315,7 +315,7 @@ static void matroxfb_cfb4_clear(WPMINFO u_int32_t bgx, int sy, int sx, int heigh
315 int whattodo; 315 int whattodo;
316 CRITFLAGS 316 CRITFLAGS
317 317
318 DBG(__FUNCTION__) 318 DBG(__func__)
319 319
320 CRITBEGIN 320 CRITBEGIN
321 321
@@ -388,7 +388,7 @@ static void matroxfb_1bpp_imageblit(WPMINFO u_int32_t fgx, u_int32_t bgx,
388 int easy; 388 int easy;
389 CRITFLAGS 389 CRITFLAGS
390 390
391 DBG_HEAVY(__FUNCTION__); 391 DBG_HEAVY(__func__);
392 392
393 step = (width + 7) >> 3; 393 step = (width + 7) >> 3;
394 charcell = height * step; 394 charcell = height * step;
@@ -469,7 +469,7 @@ static void matroxfb_1bpp_imageblit(WPMINFO u_int32_t fgx, u_int32_t bgx,
469static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* image) { 469static void matroxfb_imageblit(struct fb_info* info, const struct fb_image* image) {
470 MINFO_FROM_INFO(info); 470 MINFO_FROM_INFO(info);
471 471
472 DBG_HEAVY(__FUNCTION__); 472 DBG_HEAVY(__func__);
473 473
474 if (image->depth == 1) { 474 if (image->depth == 1) {
475 u_int32_t fgx, bgx; 475 u_int32_t fgx, bgx;
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index b25972ac6eeb..54e82f35353d 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -312,7 +312,7 @@ static void matrox_pan_var(WPMINFO struct fb_var_screeninfo *var) {
312 312
313 CRITFLAGS 313 CRITFLAGS
314 314
315 DBG(__FUNCTION__) 315 DBG(__func__)
316 316
317 if (ACCESS_FBINFO(dead)) 317 if (ACCESS_FBINFO(dead))
318 return; 318 return;
@@ -392,7 +392,7 @@ static int matroxfb_open(struct fb_info *info, int user)
392{ 392{
393 MINFO_FROM_INFO(info); 393 MINFO_FROM_INFO(info);
394 394
395 DBG_LOOP(__FUNCTION__) 395 DBG_LOOP(__func__)
396 396
397 if (ACCESS_FBINFO(dead)) { 397 if (ACCESS_FBINFO(dead)) {
398 return -ENXIO; 398 return -ENXIO;
@@ -408,7 +408,7 @@ static int matroxfb_release(struct fb_info *info, int user)
408{ 408{
409 MINFO_FROM_INFO(info); 409 MINFO_FROM_INFO(info);
410 410
411 DBG_LOOP(__FUNCTION__) 411 DBG_LOOP(__func__)
412 412
413 if (user) { 413 if (user) {
414 if (0 == --ACCESS_FBINFO(userusecount)) { 414 if (0 == --ACCESS_FBINFO(userusecount)) {
@@ -425,7 +425,7 @@ static int matroxfb_pan_display(struct fb_var_screeninfo *var,
425 struct fb_info* info) { 425 struct fb_info* info) {
426 MINFO_FROM_INFO(info); 426 MINFO_FROM_INFO(info);
427 427
428 DBG(__FUNCTION__) 428 DBG(__func__)
429 429
430 matrox_pan_var(PMINFO var); 430 matrox_pan_var(PMINFO var);
431 return 0; 431 return 0;
@@ -434,7 +434,7 @@ static int matroxfb_pan_display(struct fb_var_screeninfo *var,
434static int matroxfb_get_final_bppShift(CPMINFO int bpp) { 434static int matroxfb_get_final_bppShift(CPMINFO int bpp) {
435 int bppshft2; 435 int bppshft2;
436 436
437 DBG(__FUNCTION__) 437 DBG(__func__)
438 438
439 bppshft2 = bpp; 439 bppshft2 = bpp;
440 if (!bppshft2) { 440 if (!bppshft2) {
@@ -451,7 +451,7 @@ static int matroxfb_test_and_set_rounding(CPMINFO int xres, int bpp) {
451 int over; 451 int over;
452 int rounding; 452 int rounding;
453 453
454 DBG(__FUNCTION__) 454 DBG(__func__)
455 455
456 switch (bpp) { 456 switch (bpp) {
457 case 0: return xres; 457 case 0: return xres;
@@ -482,7 +482,7 @@ static int matroxfb_pitch_adjust(CPMINFO int xres, int bpp) {
482 const int* width; 482 const int* width;
483 int xres_new; 483 int xres_new;
484 484
485 DBG(__FUNCTION__) 485 DBG(__func__)
486 486
487 if (!bpp) return xres; 487 if (!bpp) return xres;
488 488
@@ -504,7 +504,7 @@ static int matroxfb_pitch_adjust(CPMINFO int xres, int bpp) {
504 504
505static int matroxfb_get_cmap_len(struct fb_var_screeninfo *var) { 505static int matroxfb_get_cmap_len(struct fb_var_screeninfo *var) {
506 506
507 DBG(__FUNCTION__) 507 DBG(__func__)
508 508
509 switch (var->bits_per_pixel) { 509 switch (var->bits_per_pixel) {
510 case 4: 510 case 4:
@@ -548,7 +548,7 @@ static int matroxfb_decode_var(CPMINFO struct fb_var_screeninfo *var, int *visua
548 unsigned int vramlen; 548 unsigned int vramlen;
549 unsigned int memlen; 549 unsigned int memlen;
550 550
551 DBG(__FUNCTION__) 551 DBG(__func__)
552 552
553 switch (bpp) { 553 switch (bpp) {
554 case 4: if (!ACCESS_FBINFO(capable.cfb4)) return -EINVAL; 554 case 4: if (!ACCESS_FBINFO(capable.cfb4)) return -EINVAL;
@@ -648,7 +648,7 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
648 struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon); 648 struct matrox_fb_info* minfo = container_of(fb_info, struct matrox_fb_info, fbcon);
649#endif 649#endif
650 650
651 DBG(__FUNCTION__) 651 DBG(__func__)
652 652
653 /* 653 /*
654 * Set a single color register. The values supplied are 654 * Set a single color register. The values supplied are
@@ -707,7 +707,7 @@ static int matroxfb_setcolreg(unsigned regno, unsigned red, unsigned green,
707static void matroxfb_init_fix(WPMINFO2) 707static void matroxfb_init_fix(WPMINFO2)
708{ 708{
709 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix; 709 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix;
710 DBG(__FUNCTION__) 710 DBG(__func__)
711 711
712 strcpy(fix->id,"MATROX"); 712 strcpy(fix->id,"MATROX");
713 713
@@ -722,7 +722,7 @@ static void matroxfb_init_fix(WPMINFO2)
722static void matroxfb_update_fix(WPMINFO2) 722static void matroxfb_update_fix(WPMINFO2)
723{ 723{
724 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix; 724 struct fb_fix_screeninfo *fix = &ACCESS_FBINFO(fbcon).fix;
725 DBG(__FUNCTION__) 725 DBG(__func__)
726 726
727 fix->smem_start = ACCESS_FBINFO(video.base) + ACCESS_FBINFO(curr.ydstorg.bytes); 727 fix->smem_start = ACCESS_FBINFO(video.base) + ACCESS_FBINFO(curr.ydstorg.bytes);
728 fix->smem_len = ACCESS_FBINFO(video.len_usable) - ACCESS_FBINFO(curr.ydstorg.bytes); 728 fix->smem_len = ACCESS_FBINFO(video.len_usable) - ACCESS_FBINFO(curr.ydstorg.bytes);
@@ -753,7 +753,7 @@ static int matroxfb_set_par(struct fb_info *info)
753 struct fb_var_screeninfo *var; 753 struct fb_var_screeninfo *var;
754 MINFO_FROM_INFO(info); 754 MINFO_FROM_INFO(info);
755 755
756 DBG(__FUNCTION__) 756 DBG(__func__)
757 757
758 if (ACCESS_FBINFO(dead)) { 758 if (ACCESS_FBINFO(dead)) {
759 return -ENXIO; 759 return -ENXIO;
@@ -876,7 +876,7 @@ static int matroxfb_ioctl(struct fb_info *info,
876 void __user *argp = (void __user *)arg; 876 void __user *argp = (void __user *)arg;
877 MINFO_FROM_INFO(info); 877 MINFO_FROM_INFO(info);
878 878
879 DBG(__FUNCTION__) 879 DBG(__func__)
880 880
881 if (ACCESS_FBINFO(dead)) { 881 if (ACCESS_FBINFO(dead)) {
882 return -ENXIO; 882 return -ENXIO;
@@ -1175,7 +1175,7 @@ static int matroxfb_blank(int blank, struct fb_info *info)
1175 CRITFLAGS 1175 CRITFLAGS
1176 MINFO_FROM_INFO(info); 1176 MINFO_FROM_INFO(info);
1177 1177
1178 DBG(__FUNCTION__) 1178 DBG(__func__)
1179 1179
1180 if (ACCESS_FBINFO(dead)) 1180 if (ACCESS_FBINFO(dead))
1181 return 1; 1181 return 1;
@@ -1287,7 +1287,7 @@ static int matroxfb_getmemory(WPMINFO unsigned int maxSize, unsigned int *realSi
1287 unsigned char bytes[32]; 1287 unsigned char bytes[32];
1288 unsigned char* tmp; 1288 unsigned char* tmp;
1289 1289
1290 DBG(__FUNCTION__) 1290 DBG(__func__)
1291 1291
1292 vm = ACCESS_FBINFO(video.vbase); 1292 vm = ACCESS_FBINFO(video.vbase);
1293 maxSize &= ~0x1FFFFF; /* must be X*2MB (really it must be 2 or X*4MB) */ 1293 maxSize &= ~0x1FFFFF; /* must be X*2MB (really it must be 2 or X*4MB) */
@@ -1593,7 +1593,7 @@ static int initMatrox2(WPMINFO struct board* b){
1593 { }, 1593 { },
1594 }; 1594 };
1595 1595
1596 DBG(__FUNCTION__) 1596 DBG(__func__)
1597 1597
1598 /* set default values... */ 1598 /* set default values... */
1599 vesafb_defined.accel_flags = FB_ACCELF_TEXT; 1599 vesafb_defined.accel_flags = FB_ACCELF_TEXT;
@@ -2006,7 +2006,7 @@ static int matroxfb_probe(struct pci_dev* pdev, const struct pci_device_id* dumm
2006#ifndef CONFIG_FB_MATROX_MULTIHEAD 2006#ifndef CONFIG_FB_MATROX_MULTIHEAD
2007 static int registered = 0; 2007 static int registered = 0;
2008#endif 2008#endif
2009 DBG(__FUNCTION__) 2009 DBG(__func__)
2010 2010
2011 svid = pdev->subsystem_vendor; 2011 svid = pdev->subsystem_vendor;
2012 sid = pdev->subsystem_device; 2012 sid = pdev->subsystem_device;
@@ -2301,7 +2301,7 @@ static void __exit matrox_done(void) {
2301static int __init matroxfb_setup(char *options) { 2301static int __init matroxfb_setup(char *options) {
2302 char *this_opt; 2302 char *this_opt;
2303 2303
2304 DBG(__FUNCTION__) 2304 DBG(__func__)
2305 2305
2306 if (!options || !*options) 2306 if (!options || !*options)
2307 return 0; 2307 return 0;
@@ -2444,7 +2444,7 @@ static int __init matroxfb_init(void)
2444 char *option = NULL; 2444 char *option = NULL;
2445 int err = 0; 2445 int err = 0;
2446 2446
2447 DBG(__FUNCTION__) 2447 DBG(__func__)
2448 2448
2449 if (fb_get_options("matroxfb", &option)) 2449 if (fb_get_options("matroxfb", &option))
2450 return -ENODEV; 2450 return -ENODEV;
@@ -2556,7 +2556,7 @@ MODULE_PARM_DESC(cmode, "Specify the video depth that should be used (8bit defau
2556 2556
2557int __init init_module(void){ 2557int __init init_module(void){
2558 2558
2559 DBG(__FUNCTION__) 2559 DBG(__func__)
2560 2560
2561 if (disabled) 2561 if (disabled)
2562 return -ENXIO; 2562 return -ENXIO;
diff --git a/drivers/video/matrox/matroxfb_crtc2.c b/drivers/video/matrox/matroxfb_crtc2.c
index a6ab5b6a58d0..7ac4c5f6145d 100644
--- a/drivers/video/matrox/matroxfb_crtc2.c
+++ b/drivers/video/matrox/matroxfb_crtc2.c
@@ -420,7 +420,7 @@ static int matroxfb_dh_ioctl(struct fb_info *info,
420#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon)) 420#define m2info (container_of(info, struct matroxfb_dh_fb_info, fbcon))
421 MINFO_FROM(m2info->primary_dev); 421 MINFO_FROM(m2info->primary_dev);
422 422
423 DBG(__FUNCTION__) 423 DBG(__func__)
424 424
425 switch (cmd) { 425 switch (cmd) {
426 case FBIOGET_VBLANK: 426 case FBIOGET_VBLANK:
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c
index 0cd58f84fb46..89da27bd5c49 100644
--- a/drivers/video/matrox/matroxfb_maven.c
+++ b/drivers/video/matrox/matroxfb_maven.c
@@ -220,7 +220,7 @@ static int matroxfb_PLL_mavenclock(const struct matrox_pll_features2* pll,
220 unsigned int scrlen; 220 unsigned int scrlen;
221 unsigned int fmax; 221 unsigned int fmax;
222 222
223 DBG(__FUNCTION__) 223 DBG(__func__)
224 224
225 scrlen = htotal * (vtotal - 1); 225 scrlen = htotal * (vtotal - 1);
226 fwant = htotal * vtotal; 226 fwant = htotal * vtotal;
diff --git a/drivers/video/matrox/matroxfb_misc.c b/drivers/video/matrox/matroxfb_misc.c
index ab7fb50bc1de..aaa3e538e5da 100644
--- a/drivers/video/matrox/matroxfb_misc.c
+++ b/drivers/video/matrox/matroxfb_misc.c
@@ -90,13 +90,13 @@
90#include <linux/matroxfb.h> 90#include <linux/matroxfb.h>
91 91
92void matroxfb_DAC_out(CPMINFO int reg, int val) { 92void matroxfb_DAC_out(CPMINFO int reg, int val) {
93 DBG_REG(__FUNCTION__) 93 DBG_REG(__func__)
94 mga_outb(M_RAMDAC_BASE+M_X_INDEX, reg); 94 mga_outb(M_RAMDAC_BASE+M_X_INDEX, reg);
95 mga_outb(M_RAMDAC_BASE+M_X_DATAREG, val); 95 mga_outb(M_RAMDAC_BASE+M_X_DATAREG, val);
96} 96}
97 97
98int matroxfb_DAC_in(CPMINFO int reg) { 98int matroxfb_DAC_in(CPMINFO int reg) {
99 DBG_REG(__FUNCTION__) 99 DBG_REG(__func__)
100 mga_outb(M_RAMDAC_BASE+M_X_INDEX, reg); 100 mga_outb(M_RAMDAC_BASE+M_X_INDEX, reg);
101 return mga_inb(M_RAMDAC_BASE+M_X_DATAREG); 101 return mga_inb(M_RAMDAC_BASE+M_X_DATAREG);
102} 102}
@@ -104,7 +104,7 @@ int matroxfb_DAC_in(CPMINFO int reg) {
104void matroxfb_var2my(struct fb_var_screeninfo* var, struct my_timming* mt) { 104void matroxfb_var2my(struct fb_var_screeninfo* var, struct my_timming* mt) {
105 unsigned int pixclock = var->pixclock; 105 unsigned int pixclock = var->pixclock;
106 106
107 DBG(__FUNCTION__) 107 DBG(__func__)
108 108
109 if (!pixclock) pixclock = 10000; /* 10ns = 100MHz */ 109 if (!pixclock) pixclock = 10000; /* 10ns = 100MHz */
110 mt->pixclock = 1000000000 / pixclock; 110 mt->pixclock = 1000000000 / pixclock;
@@ -131,7 +131,7 @@ int matroxfb_PLL_calcclock(const struct matrox_pll_features* pll, unsigned int f
131 unsigned int fwant; 131 unsigned int fwant;
132 unsigned int p; 132 unsigned int p;
133 133
134 DBG(__FUNCTION__) 134 DBG(__func__)
135 135
136 fwant = freq; 136 fwant = freq;
137 137
@@ -192,7 +192,7 @@ int matroxfb_vgaHWinit(WPMINFO struct my_timming* m) {
192 int i; 192 int i;
193 struct matrox_hw_state * const hw = &ACCESS_FBINFO(hw); 193 struct matrox_hw_state * const hw = &ACCESS_FBINFO(hw);
194 194
195 DBG(__FUNCTION__) 195 DBG(__func__)
196 196
197 hw->SEQ[0] = 0x00; 197 hw->SEQ[0] = 0x00;
198 hw->SEQ[1] = 0x01; /* or 0x09 */ 198 hw->SEQ[1] = 0x01; /* or 0x09 */
@@ -336,7 +336,7 @@ void matroxfb_vgaHWrestore(WPMINFO2) {
336 struct matrox_hw_state * const hw = &ACCESS_FBINFO(hw); 336 struct matrox_hw_state * const hw = &ACCESS_FBINFO(hw);
337 CRITFLAGS 337 CRITFLAGS
338 338
339 DBG(__FUNCTION__) 339 DBG(__func__)
340 340
341 dprintk(KERN_INFO "MiscOutReg: %02X\n", hw->MiscOutReg); 341 dprintk(KERN_INFO "MiscOutReg: %02X\n", hw->MiscOutReg);
342 dprintk(KERN_INFO "SEQ regs: "); 342 dprintk(KERN_INFO "SEQ regs: ");
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c
index e9a89fd82757..249791286367 100644
--- a/drivers/video/metronomefb.c
+++ b/drivers/video/metronomefb.c
@@ -13,12 +13,10 @@
13 * Corporation. http://support.eink.com/community 13 * Corporation. http://support.eink.com/community
14 * 14 *
15 * This driver is written to be used with the Metronome display controller. 15 * This driver is written to be used with the Metronome display controller.
16 * It was tested with an E-Ink 800x600 Vizplex EPD on a Gumstix Connex board 16 * It is intended to be architecture independent. A board specific driver
17 * using the Lyre interface board. 17 * must be used to perform all the physical IO interactions. An example
18 * is provided as am200epd.c
18 * 19 *
19 * General notes:
20 * - User must set metronomefb_enable=1 to enable it.
21 * - See Documentation/fb/metronomefb.txt for how metronome works.
22 */ 20 */
23#include <linux/module.h> 21#include <linux/module.h>
24#include <linux/kernel.h> 22#include <linux/kernel.h>
@@ -38,9 +36,11 @@
38#include <linux/uaccess.h> 36#include <linux/uaccess.h>
39#include <linux/irq.h> 37#include <linux/irq.h>
40 38
41#include <asm/arch/pxa-regs.h> 39#include <video/metronomefb.h>
40
42#include <asm/unaligned.h> 41#include <asm/unaligned.h>
43 42
43
44#define DEBUG 1 44#define DEBUG 1
45#ifdef DEBUG 45#ifdef DEBUG
46#define DPRINTK(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a) 46#define DPRINTK(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a)
@@ -53,35 +53,6 @@
53#define DPY_W 832 53#define DPY_W 832
54#define DPY_H 622 54#define DPY_H 622
55 55
56struct metromem_desc {
57 u32 mFDADR0;
58 u32 mFSADR0;
59 u32 mFIDR0;
60 u32 mLDCMD0;
61};
62
63struct metromem_cmd {
64 u16 opcode;
65 u16 args[((64-2)/2)];
66 u16 csum;
67};
68
69struct metronomefb_par {
70 unsigned char *metromem;
71 struct metromem_desc *metromem_desc;
72 struct metromem_cmd *metromem_cmd;
73 unsigned char *metromem_wfm;
74 unsigned char *metromem_img;
75 u16 *metromem_img_csum;
76 u16 *csum_table;
77 int metromemsize;
78 dma_addr_t metromem_dma;
79 dma_addr_t metromem_desc_dma;
80 struct fb_info *info;
81 wait_queue_head_t waitq;
82 u8 frame_count;
83};
84
85/* frame differs from image. frame includes non-visible pixels */ 56/* frame differs from image. frame includes non-visible pixels */
86struct epd_frame { 57struct epd_frame {
87 int fw; /* frame width */ 58 int fw; /* frame width */
@@ -120,8 +91,7 @@ static struct fb_var_screeninfo metronomefb_var __devinitdata = {
120 .transp = { 0, 0, 0 }, 91 .transp = { 0, 0, 0 },
121}; 92};
122 93
123static unsigned int metronomefb_enable; 94/* the waveform structure that is coming from userspace firmware */
124
125struct waveform_hdr { 95struct waveform_hdr {
126 u8 stuff[32]; 96 u8 stuff[32];
127 97
@@ -301,165 +271,6 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t,
301 return 0; 271 return 0;
302} 272}
303 273
304/* register offsets for gpio control */
305#define LED_GPIO_PIN 51
306#define STDBY_GPIO_PIN 48
307#define RST_GPIO_PIN 49
308#define RDY_GPIO_PIN 32
309#define ERR_GPIO_PIN 17
310#define PCBPWR_GPIO_PIN 16
311
312#define AF_SEL_GPIO_N 0x3
313#define GAFR0_U_OFFSET(pin) ((pin - 16) * 2)
314#define GAFR1_L_OFFSET(pin) ((pin - 32) * 2)
315#define GAFR1_U_OFFSET(pin) ((pin - 48) * 2)
316#define GPDR1_OFFSET(pin) (pin - 32)
317#define GPCR1_OFFSET(pin) (pin - 32)
318#define GPSR1_OFFSET(pin) (pin - 32)
319#define GPCR0_OFFSET(pin) (pin)
320#define GPSR0_OFFSET(pin) (pin)
321
322static void metronome_set_gpio_output(int pin, int val)
323{
324 u8 index;
325
326 index = pin >> 4;
327
328 switch (index) {
329 case 1:
330 if (val)
331 GPSR0 |= (1 << GPSR0_OFFSET(pin));
332 else
333 GPCR0 |= (1 << GPCR0_OFFSET(pin));
334 break;
335 case 2:
336 break;
337 case 3:
338 if (val)
339 GPSR1 |= (1 << GPSR1_OFFSET(pin));
340 else
341 GPCR1 |= (1 << GPCR1_OFFSET(pin));
342 break;
343 default:
344 printk(KERN_ERR "unimplemented\n");
345 }
346}
347
348static void __devinit metronome_init_gpio_pin(int pin, int dir)
349{
350 u8 index;
351 /* dir 0 is output, 1 is input
352 - do 2 things here:
353 - set gpio alternate function to standard gpio
354 - set gpio direction to input or output */
355
356 index = pin >> 4;
357 switch (index) {
358 case 1:
359 GAFR0_U &= ~(AF_SEL_GPIO_N << GAFR0_U_OFFSET(pin));
360
361 if (dir)
362 GPDR0 &= ~(1 << pin);
363 else
364 GPDR0 |= (1 << pin);
365 break;
366 case 2:
367 GAFR1_L &= ~(AF_SEL_GPIO_N << GAFR1_L_OFFSET(pin));
368
369 if (dir)
370 GPDR1 &= ~(1 << GPDR1_OFFSET(pin));
371 else
372 GPDR1 |= (1 << GPDR1_OFFSET(pin));
373 break;
374 case 3:
375 GAFR1_U &= ~(AF_SEL_GPIO_N << GAFR1_U_OFFSET(pin));
376
377 if (dir)
378 GPDR1 &= ~(1 << GPDR1_OFFSET(pin));
379 else
380 GPDR1 |= (1 << GPDR1_OFFSET(pin));
381 break;
382 default:
383 printk(KERN_ERR "unimplemented\n");
384 }
385}
386
387static void __devinit metronome_init_gpio_regs(void)
388{
389 metronome_init_gpio_pin(LED_GPIO_PIN, 0);
390 metronome_set_gpio_output(LED_GPIO_PIN, 0);
391
392 metronome_init_gpio_pin(STDBY_GPIO_PIN, 0);
393 metronome_set_gpio_output(STDBY_GPIO_PIN, 0);
394
395 metronome_init_gpio_pin(RST_GPIO_PIN, 0);
396 metronome_set_gpio_output(RST_GPIO_PIN, 0);
397
398 metronome_init_gpio_pin(RDY_GPIO_PIN, 1);
399
400 metronome_init_gpio_pin(ERR_GPIO_PIN, 1);
401
402 metronome_init_gpio_pin(PCBPWR_GPIO_PIN, 0);
403 metronome_set_gpio_output(PCBPWR_GPIO_PIN, 0);
404}
405
406static void metronome_disable_lcd_controller(struct metronomefb_par *par)
407{
408 LCSR = 0xffffffff; /* Clear LCD Status Register */
409 LCCR0 |= LCCR0_DIS; /* Disable LCD Controller */
410
411 /* we reset and just wait for things to settle */
412 msleep(200);
413}
414
415static void metronome_enable_lcd_controller(struct metronomefb_par *par)
416{
417 LCSR = 0xffffffff;
418 FDADR0 = par->metromem_desc_dma;
419 LCCR0 |= LCCR0_ENB;
420}
421
422static void __devinit metronome_init_lcdc_regs(struct metronomefb_par *par)
423{
424 /* here we do:
425 - disable the lcd controller
426 - setup lcd control registers
427 - setup dma descriptor
428 - reenable lcd controller
429 */
430
431 /* disable the lcd controller */
432 metronome_disable_lcd_controller(par);
433
434 /* setup lcd control registers */
435 LCCR0 = LCCR0_LDM | LCCR0_SFM | LCCR0_IUM | LCCR0_EFM | LCCR0_PAS
436 | LCCR0_QDM | LCCR0_BM | LCCR0_OUM;
437
438 LCCR1 = (epd_frame_table[0].fw/2 - 1) /* pixels per line */
439 | (27 << 10) /* hsync pulse width - 1 */
440 | (33 << 16) /* eol pixel count */
441 | (33 << 24); /* bol pixel count */
442
443 LCCR2 = (epd_frame_table[0].fh - 1) /* lines per panel */
444 | (24 << 10) /* vsync pulse width - 1 */
445 | (2 << 16) /* eof pixel count */
446 | (0 << 24); /* bof pixel count */
447
448 LCCR3 = 2 /* pixel clock divisor */
449 | (24 << 8) /* AC Bias pin freq */
450 | LCCR3_16BPP /* BPP */
451 | LCCR3_PCP; /* PCP falling edge */
452
453 /* setup dma descriptor */
454 par->metromem_desc->mFDADR0 = par->metromem_desc_dma;
455 par->metromem_desc->mFSADR0 = par->metromem_dma;
456 par->metromem_desc->mFIDR0 = 0;
457 par->metromem_desc->mLDCMD0 = epd_frame_table[0].fw
458 * epd_frame_table[0].fh;
459 /* reenable lcd controller */
460 metronome_enable_lcd_controller(par);
461}
462
463static int metronome_display_cmd(struct metronomefb_par *par) 274static int metronome_display_cmd(struct metronomefb_par *par)
464{ 275{
465 int i; 276 int i;
@@ -493,8 +304,7 @@ static int metronome_display_cmd(struct metronomefb_par *par)
493 par->metromem_cmd->csum = cs; 304 par->metromem_cmd->csum = cs;
494 par->metromem_cmd->opcode = opcode; /* display cmd */ 305 par->metromem_cmd->opcode = opcode; /* display cmd */
495 306
496 i = wait_event_interruptible_timeout(par->waitq, (GPLR1 & 0x01), HZ); 307 return par->board->met_wait_event_intr(par);
497 return i;
498} 308}
499 309
500static int __devinit metronome_powerup_cmd(struct metronomefb_par *par) 310static int __devinit metronome_powerup_cmd(struct metronomefb_par *par)
@@ -518,13 +328,12 @@ static int __devinit metronome_powerup_cmd(struct metronomefb_par *par)
518 par->metromem_cmd->csum = cs; 328 par->metromem_cmd->csum = cs;
519 329
520 msleep(1); 330 msleep(1);
521 metronome_set_gpio_output(RST_GPIO_PIN, 1); 331 par->board->set_rst(par, 1);
522 332
523 msleep(1); 333 msleep(1);
524 metronome_set_gpio_output(STDBY_GPIO_PIN, 1); 334 par->board->set_stdby(par, 1);
525 335
526 i = wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ); 336 return par->board->met_wait_event(par);
527 return i;
528} 337}
529 338
530static int __devinit metronome_config_cmd(struct metronomefb_par *par) 339static int __devinit metronome_config_cmd(struct metronomefb_par *par)
@@ -569,8 +378,7 @@ static int __devinit metronome_config_cmd(struct metronomefb_par *par)
569 par->metromem_cmd->csum = cs; 378 par->metromem_cmd->csum = cs;
570 par->metromem_cmd->opcode = 0xCC10; /* config cmd */ 379 par->metromem_cmd->opcode = 0xCC10; /* config cmd */
571 380
572 i = wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ); 381 return par->board->met_wait_event(par);
573 return i;
574} 382}
575 383
576static int __devinit metronome_init_cmd(struct metronomefb_par *par) 384static int __devinit metronome_init_cmd(struct metronomefb_par *par)
@@ -596,16 +404,19 @@ static int __devinit metronome_init_cmd(struct metronomefb_par *par)
596 par->metromem_cmd->csum = cs; 404 par->metromem_cmd->csum = cs;
597 par->metromem_cmd->opcode = 0xCC20; /* init cmd */ 405 par->metromem_cmd->opcode = 0xCC20; /* init cmd */
598 406
599 i = wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ); 407 return par->board->met_wait_event(par);
600 return i;
601} 408}
602 409
603static int __devinit metronome_init_regs(struct metronomefb_par *par) 410static int __devinit metronome_init_regs(struct metronomefb_par *par)
604{ 411{
605 int res; 412 int res;
606 413
607 metronome_init_gpio_regs(); 414 par->board->init_gpio_regs(par);
608 metronome_init_lcdc_regs(par); 415
416 par->board->init_lcdc_regs(par);
417
418 /* now that lcd is setup, setup dma descriptor */
419 par->board->post_dma_setup(par);
609 420
610 res = metronome_powerup_cmd(par); 421 res = metronome_powerup_cmd(par);
611 if (res) 422 if (res)
@@ -616,8 +427,6 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par)
616 return res; 427 return res;
617 428
618 res = metronome_init_cmd(par); 429 res = metronome_init_cmd(par);
619 if (res)
620 return res;
621 430
622 return res; 431 return res;
623} 432}
@@ -632,7 +441,7 @@ static void metronomefb_dpy_update(struct metronomefb_par *par)
632 441
633 cksum = calc_img_cksum((u16 *) par->metromem_img, 442 cksum = calc_img_cksum((u16 *) par->metromem_img,
634 (epd_frame_table[0].fw * DPY_H)/2); 443 (epd_frame_table[0].fw * DPY_H)/2);
635 *((u16 *) (par->metromem_img) + 444 *((u16 *)(par->metromem_img) +
636 (epd_frame_table[0].fw * DPY_H)/2) = cksum; 445 (epd_frame_table[0].fw * DPY_H)/2) = cksum;
637 metronome_display_cmd(par); 446 metronome_display_cmd(par);
638} 447}
@@ -641,8 +450,8 @@ static u16 metronomefb_dpy_update_page(struct metronomefb_par *par, int index)
641{ 450{
642 int i; 451 int i;
643 u16 csum = 0; 452 u16 csum = 0;
644 u16 *buf = (u16 __force *) (par->info->screen_base + index); 453 u16 *buf = (u16 __force *)(par->info->screen_base + index);
645 u16 *img = (u16 *) (par->metromem_img + index); 454 u16 *img = (u16 *)(par->metromem_img + index);
646 455
647 /* swizzle from vm to metromem and recalc cksum at the same time*/ 456 /* swizzle from vm to metromem and recalc cksum at the same time*/
648 for (i = 0; i < PAGE_SIZE/2; i++) { 457 for (i = 0; i < PAGE_SIZE/2; i++) {
@@ -678,7 +487,7 @@ static void metronomefb_fillrect(struct fb_info *info,
678{ 487{
679 struct metronomefb_par *par = info->par; 488 struct metronomefb_par *par = info->par;
680 489
681 cfb_fillrect(info, rect); 490 sys_fillrect(info, rect);
682 metronomefb_dpy_update(par); 491 metronomefb_dpy_update(par);
683} 492}
684 493
@@ -687,7 +496,7 @@ static void metronomefb_copyarea(struct fb_info *info,
687{ 496{
688 struct metronomefb_par *par = info->par; 497 struct metronomefb_par *par = info->par;
689 498
690 cfb_copyarea(info, area); 499 sys_copyarea(info, area);
691 metronomefb_dpy_update(par); 500 metronomefb_dpy_update(par);
692} 501}
693 502
@@ -696,7 +505,7 @@ static void metronomefb_imageblit(struct fb_info *info,
696{ 505{
697 struct metronomefb_par *par = info->par; 506 struct metronomefb_par *par = info->par;
698 507
699 cfb_imageblit(info, image); 508 sys_imageblit(info, image);
700 metronomefb_dpy_update(par); 509 metronomefb_dpy_update(par);
701} 510}
702 511
@@ -733,7 +542,7 @@ static ssize_t metronomefb_write(struct fb_info *info, const char __user *buf,
733 count = total_size - p; 542 count = total_size - p;
734 } 543 }
735 544
736 dst = (void __force *) (info->screen_base + p); 545 dst = (void __force *)(info->screen_base + p);
737 546
738 if (copy_from_user(dst, buf, count)) 547 if (copy_from_user(dst, buf, count))
739 err = -EFAULT; 548 err = -EFAULT;
@@ -759,18 +568,10 @@ static struct fb_deferred_io metronomefb_defio = {
759 .deferred_io = metronomefb_dpy_deferred_io, 568 .deferred_io = metronomefb_dpy_deferred_io,
760}; 569};
761 570
762static irqreturn_t metronome_handle_irq(int irq, void *dev_id)
763{
764 struct fb_info *info = dev_id;
765 struct metronomefb_par *par = info->par;
766
767 wake_up_interruptible(&par->waitq);
768 return IRQ_HANDLED;
769}
770
771static int __devinit metronomefb_probe(struct platform_device *dev) 571static int __devinit metronomefb_probe(struct platform_device *dev)
772{ 572{
773 struct fb_info *info; 573 struct fb_info *info;
574 struct metronome_board *board;
774 int retval = -ENOMEM; 575 int retval = -ENOMEM;
775 int videomemorysize; 576 int videomemorysize;
776 unsigned char *videomemory; 577 unsigned char *videomemory;
@@ -779,17 +580,26 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
779 int cmd_size, wfm_size, img_size, padding_size, totalsize; 580 int cmd_size, wfm_size, img_size, padding_size, totalsize;
780 int i; 581 int i;
781 582
583 /* pick up board specific routines */
584 board = dev->dev.platform_data;
585 if (!board)
586 return -EINVAL;
587
588 /* try to count device specific driver, if can't, platform recalls */
589 if (!try_module_get(board->owner))
590 return -ENODEV;
591
782 /* we have two blocks of memory. 592 /* we have two blocks of memory.
783 info->screen_base which is vm, and is the fb used by apps. 593 info->screen_base which is vm, and is the fb used by apps.
784 par->metromem which is physically contiguous memory and 594 par->metromem which is physically contiguous memory and
785 contains the display controller commands, waveform, 595 contains the display controller commands, waveform,
786 processed image data and padding. this is the data pulled 596 processed image data and padding. this is the data pulled
787 by the pxa255's LCD controller and pushed to Metronome */ 597 by the device's LCD controller and pushed to Metronome */
788 598
789 videomemorysize = (DPY_W*DPY_H); 599 videomemorysize = (DPY_W*DPY_H);
790 videomemory = vmalloc(videomemorysize); 600 videomemory = vmalloc(videomemorysize);
791 if (!videomemory) 601 if (!videomemory)
792 return retval; 602 return -ENOMEM;
793 603
794 memset(videomemory, 0, videomemorysize); 604 memset(videomemory, 0, videomemorysize);
795 605
@@ -797,7 +607,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
797 if (!info) 607 if (!info)
798 goto err_vfree; 608 goto err_vfree;
799 609
800 info->screen_base = (char __iomem *) videomemory; 610 info->screen_base = (char __force __iomem *)videomemory;
801 info->fbops = &metronomefb_ops; 611 info->fbops = &metronomefb_ops;
802 612
803 info->var = metronomefb_var; 613 info->var = metronomefb_var;
@@ -805,6 +615,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
805 info->fix.smem_len = videomemorysize; 615 info->fix.smem_len = videomemorysize;
806 par = info->par; 616 par = info->par;
807 par->info = info; 617 par->info = info;
618 par->board = board;
808 init_waitqueue_head(&par->waitq); 619 init_waitqueue_head(&par->waitq);
809 620
810 /* this table caches per page csum values. */ 621 /* this table caches per page csum values. */
@@ -849,11 +660,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
849 par->metromem_desc_dma = par->metromem_dma + cmd_size + wfm_size 660 par->metromem_desc_dma = par->metromem_dma + cmd_size + wfm_size
850 + img_size + padding_size; 661 + img_size + padding_size;
851 662
852 /* load the waveform in. assume mode 3, temp 31 for now */ 663 /* load the waveform in. assume mode 3, temp 31 for now
853 /* a) request the waveform file from userspace 664 a) request the waveform file from userspace
854 b) process waveform and decode into metromem */ 665 b) process waveform and decode into metromem */
855 666 retval = request_firmware(&fw_entry, "metronome.wbf", &dev->dev);
856 retval = request_firmware(&fw_entry, "waveform.wbf", &dev->dev);
857 if (retval < 0) { 667 if (retval < 0) {
858 printk(KERN_ERR "metronomefb: couldn't get waveform\n"); 668 printk(KERN_ERR "metronomefb: couldn't get waveform\n");
859 goto err_dma_free; 669 goto err_dma_free;
@@ -861,19 +671,14 @@ static int __devinit metronomefb_probe(struct platform_device *dev)
861 671
862 retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, 672 retval = load_waveform((u8 *) fw_entry->data, fw_entry->size,
863 par->metromem_wfm, 3, 31, &par->frame_count); 673 par->metromem_wfm, 3, 31, &par->frame_count);
674 release_firmware(fw_entry);
864 if (retval < 0) { 675 if (retval < 0) {
865 printk(KERN_ERR "metronomefb: couldn't process waveform\n"); 676 printk(KERN_ERR "metronomefb: couldn't process waveform\n");
866 goto err_ld_wfm; 677 goto err_dma_free;
867 } 678 }
868 release_firmware(fw_entry);
869 679
870 retval = request_irq(IRQ_GPIO(RDY_GPIO_PIN), metronome_handle_irq, 680 if (board->setup_irq(info))
871 IRQF_DISABLED, "Metronome", info); 681 goto err_dma_free;
872 if (retval) {
873 dev_err(&dev->dev, "request_irq failed: %d\n", retval);
874 goto err_ld_wfm;
875 }
876 set_irq_type(IRQ_GPIO(RDY_GPIO_PIN), IRQT_FALLING);
877 682
878 retval = metronome_init_regs(par); 683 retval = metronome_init_regs(par);
879 if (retval < 0) 684 if (retval < 0)
@@ -913,9 +718,7 @@ err_cmap:
913err_fb_rel: 718err_fb_rel:
914 framebuffer_release(info); 719 framebuffer_release(info);
915err_free_irq: 720err_free_irq:
916 free_irq(IRQ_GPIO(RDY_GPIO_PIN), info); 721 board->free_irq(info);
917err_ld_wfm:
918 release_firmware(fw_entry);
919err_dma_free: 722err_dma_free:
920 dma_free_writecombine(&dev->dev, par->metromemsize, par->metromem, 723 dma_free_writecombine(&dev->dev, par->metromemsize, par->metromem,
921 par->metromem_dma); 724 par->metromem_dma);
@@ -923,6 +726,7 @@ err_csum_table:
923 vfree(par->csum_table); 726 vfree(par->csum_table);
924err_vfree: 727err_vfree:
925 vfree(videomemory); 728 vfree(videomemory);
729 module_put(board->owner);
926 return retval; 730 return retval;
927} 731}
928 732
@@ -939,7 +743,8 @@ static int __devexit metronomefb_remove(struct platform_device *dev)
939 vfree(par->csum_table); 743 vfree(par->csum_table);
940 unregister_framebuffer(info); 744 unregister_framebuffer(info);
941 vfree((void __force *)info->screen_base); 745 vfree((void __force *)info->screen_base);
942 free_irq(IRQ_GPIO(RDY_GPIO_PIN), info); 746 par->board->free_irq(info);
747 module_put(par->board->owner);
943 framebuffer_release(info); 748 framebuffer_release(info);
944 } 749 }
945 return 0; 750 return 0;
@@ -949,48 +754,21 @@ static struct platform_driver metronomefb_driver = {
949 .probe = metronomefb_probe, 754 .probe = metronomefb_probe,
950 .remove = metronomefb_remove, 755 .remove = metronomefb_remove,
951 .driver = { 756 .driver = {
757 .owner = THIS_MODULE,
952 .name = "metronomefb", 758 .name = "metronomefb",
953 }, 759 },
954}; 760};
955 761
956static struct platform_device *metronomefb_device;
957
958static int __init metronomefb_init(void) 762static int __init metronomefb_init(void)
959{ 763{
960 int ret; 764 return platform_driver_register(&metronomefb_driver);
961
962 if (!metronomefb_enable) {
963 printk(KERN_ERR
964 "Use metronomefb_enable to enable the device\n");
965 return -ENXIO;
966 }
967
968 ret = platform_driver_register(&metronomefb_driver);
969 if (!ret) {
970 metronomefb_device = platform_device_alloc("metronomefb", 0);
971 if (metronomefb_device)
972 ret = platform_device_add(metronomefb_device);
973 else
974 ret = -ENOMEM;
975
976 if (ret) {
977 platform_device_put(metronomefb_device);
978 platform_driver_unregister(&metronomefb_driver);
979 }
980 }
981 return ret;
982
983} 765}
984 766
985static void __exit metronomefb_exit(void) 767static void __exit metronomefb_exit(void)
986{ 768{
987 platform_device_unregister(metronomefb_device);
988 platform_driver_unregister(&metronomefb_driver); 769 platform_driver_unregister(&metronomefb_driver);
989} 770}
990 771
991module_param(metronomefb_enable, uint, 0);
992MODULE_PARM_DESC(metronomefb_enable, "Enable communication with Metronome");
993
994module_init(metronomefb_init); 772module_init(metronomefb_init);
995module_exit(metronomefb_exit); 773module_exit(metronomefb_exit);
996 774
diff --git a/drivers/video/modedb.c b/drivers/video/modedb.c
index 08d072552233..473562191586 100644
--- a/drivers/video/modedb.c
+++ b/drivers/video/modedb.c
@@ -22,7 +22,7 @@
22 ((v).xres == (x) && (v).yres == (y)) 22 ((v).xres == (x) && (v).yres == (y))
23 23
24#ifdef DEBUG 24#ifdef DEBUG
25#define DPRINTK(fmt, args...) printk("modedb %s: " fmt, __FUNCTION__ , ## args) 25#define DPRINTK(fmt, args...) printk("modedb %s: " fmt, __func__ , ## args)
26#else 26#else
27#define DPRINTK(fmt, args...) 27#define DPRINTK(fmt, args...)
28#endif 28#endif
@@ -522,7 +522,7 @@ int fb_find_mode(struct fb_var_screeninfo *var,
522 int res_specified = 0, bpp_specified = 0, refresh_specified = 0; 522 int res_specified = 0, bpp_specified = 0, refresh_specified = 0;
523 unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0; 523 unsigned int xres = 0, yres = 0, bpp = default_bpp, refresh = 0;
524 int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0; 524 int yres_specified = 0, cvt = 0, rb = 0, interlace = 0, margins = 0;
525 u32 best, diff; 525 u32 best, diff, tdiff;
526 526
527 for (i = namelen-1; i >= 0; i--) { 527 for (i = namelen-1; i >= 0; i--) {
528 switch (name[i]) { 528 switch (name[i]) {
@@ -651,19 +651,27 @@ done:
651 return (refresh_specified) ? 2 : 1; 651 return (refresh_specified) ? 2 : 1;
652 } 652 }
653 653
654 diff = xres + yres; 654 diff = 2 * (xres + yres);
655 best = -1; 655 best = -1;
656 DPRINTK("Trying best-fit modes\n"); 656 DPRINTK("Trying best-fit modes\n");
657 for (i = 0; i < dbsize; i++) { 657 for (i = 0; i < dbsize; i++) {
658 if (xres <= db[i].xres && yres <= db[i].yres) {
659 DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres); 658 DPRINTK("Trying %ix%i\n", db[i].xres, db[i].yres);
660 if (!fb_try_mode(var, info, &db[i], bpp)) { 659 if (!fb_try_mode(var, info, &db[i], bpp)) {
661 if (diff > (db[i].xres - xres) + (db[i].yres - yres)) { 660 tdiff = abs(db[i].xres - xres) +
662 diff = (db[i].xres - xres) + (db[i].yres - yres); 661 abs(db[i].yres - yres);
663 best = i; 662
664 } 663 /*
664 * Penalize modes with resolutions smaller
665 * than requested.
666 */
667 if (xres > db[i].xres || yres > db[i].yres)
668 tdiff += xres + yres;
669
670 if (diff > tdiff) {
671 diff = tdiff;
672 best = i;
673 }
665 } 674 }
666 }
667 } 675 }
668 if (best != -1) { 676 if (best != -1) {
669 fb_try_mode(var, info, &db[best], bpp); 677 fb_try_mode(var, info, &db[best], bpp);
diff --git a/drivers/video/n411.c b/drivers/video/n411.c
new file mode 100644
index 000000000000..935830fea7b6
--- /dev/null
+++ b/drivers/video/n411.c
@@ -0,0 +1,202 @@
1/*
2 * linux/drivers/video/n411.c -- Platform device for N411 EPD kit
3 *
4 * Copyright (C) 2008, Jaya Kumar
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive for
8 * more details.
9 *
10 * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
11 *
12 * This driver is written to be used with the Hecuba display controller
13 * board, and tested with the EInk 800x600 display in 1 bit mode.
14 * The interface between Hecuba and the host is TTL based GPIO. The
15 * GPIO requirements are 8 writable data lines and 6 lines for control.
16 * Only 4 of the controls are actually used here but 6 for future use.
17 * The driver requires the IO addresses for data and control GPIO at
18 * load time. It is also possible to use this display with a standard
19 * PC parallel port.
20 *
21 * General notes:
22 * - User must set dio_addr=0xIOADDR cio_addr=0xIOADDR c2io_addr=0xIOADDR
23 *
24 */
25
26#include <linux/module.h>
27#include <linux/kernel.h>
28#include <linux/errno.h>
29#include <linux/string.h>
30#include <linux/delay.h>
31#include <linux/interrupt.h>
32#include <linux/fb.h>
33#include <linux/init.h>
34#include <linux/platform_device.h>
35#include <linux/list.h>
36#include <linux/uaccess.h>
37#include <linux/irq.h>
38
39#include <video/hecubafb.h>
40
41static unsigned long dio_addr;
42static unsigned long cio_addr;
43static unsigned long c2io_addr;
44static unsigned long splashval;
45static unsigned int nosplash;
46static unsigned char ctl;
47
48static void n411_set_ctl(struct hecubafb_par *par, unsigned char bit, unsigned
49 char state)
50{
51 switch (bit) {
52 case HCB_CD_BIT:
53 if (state)
54 ctl &= ~(HCB_CD_BIT);
55 else
56 ctl |= HCB_CD_BIT;
57 break;
58 case HCB_DS_BIT:
59 if (state)
60 ctl &= ~(HCB_DS_BIT);
61 else
62 ctl |= HCB_DS_BIT;
63 break;
64 }
65 outb(ctl, cio_addr);
66}
67
68static unsigned char n411_get_ctl(struct hecubafb_par *par)
69{
70 return inb(c2io_addr);
71}
72
73static void n411_set_data(struct hecubafb_par *par, unsigned char value)
74{
75 outb(value, dio_addr);
76}
77
78static void n411_wait_for_ack(struct hecubafb_par *par, int clear)
79{
80 int timeout;
81 unsigned char tmp;
82
83 timeout = 500;
84 do {
85 tmp = n411_get_ctl(par);
86 if ((tmp & HCB_ACK_BIT) && (!clear))
87 return;
88 else if (!(tmp & HCB_ACK_BIT) && (clear))
89 return;
90 udelay(1);
91 } while (timeout--);
92 printk(KERN_ERR "timed out waiting for ack\n");
93}
94
95static int n411_init_control(struct hecubafb_par *par)
96{
97 unsigned char tmp;
98 /* for init, we want the following setup to be set:
99 WUP = lo
100 ACK = hi
101 DS = hi
102 RW = hi
103 CD = lo
104 */
105
106 /* write WUP to lo, DS to hi, RW to hi, CD to lo */
107 ctl = HCB_WUP_BIT | HCB_RW_BIT | HCB_CD_BIT ;
108 n411_set_ctl(par, HCB_DS_BIT, 1);
109
110 /* check ACK is not lo */
111 tmp = n411_get_ctl(par);
112 if (tmp & HCB_ACK_BIT) {
113 printk(KERN_ERR "Fail because ACK is already low\n");
114 return -ENXIO;
115 }
116
117 return 0;
118}
119
120
121static int n411_init_board(struct hecubafb_par *par)
122{
123 int retval;
124
125 retval = n411_init_control(par);
126 if (retval)
127 return retval;
128
129 par->send_command(par, APOLLO_INIT_DISPLAY);
130 par->send_data(par, 0x81);
131
132 /* have to wait while display resets */
133 udelay(1000);
134
135 /* if we were told to splash the screen, we just clear it */
136 if (!nosplash) {
137 par->send_command(par, APOLLO_ERASE_DISPLAY);
138 par->send_data(par, splashval);
139 }
140
141 return 0;
142}
143
144static struct hecuba_board n411_board = {
145 .owner = THIS_MODULE,
146 .init = n411_init_board,
147 .set_ctl = n411_set_ctl,
148 .set_data = n411_set_data,
149 .wait_for_ack = n411_wait_for_ack,
150};
151
152static struct platform_device *n411_device;
153static int __init n411_init(void)
154{
155 int ret;
156 if (!dio_addr || !cio_addr || !c2io_addr) {
157 printk(KERN_WARNING "no IO addresses supplied\n");
158 return -EINVAL;
159 }
160
161 /* request our platform independent driver */
162 request_module("hecubafb");
163
164 n411_device = platform_device_alloc("hecubafb", -1);
165 if (!n411_device)
166 return -ENOMEM;
167
168 platform_device_add_data(n411_device, &n411_board, sizeof(n411_board));
169
170 /* this _add binds hecubafb to n411. hecubafb refcounts n411 */
171 ret = platform_device_add(n411_device);
172
173 if (ret)
174 platform_device_put(n411_device);
175
176 return ret;
177
178}
179
180static void __exit n411_exit(void)
181{
182 platform_device_unregister(n411_device);
183}
184
185module_init(n411_init);
186module_exit(n411_exit);
187
188module_param(nosplash, uint, 0);
189MODULE_PARM_DESC(nosplash, "Disable doing the splash screen");
190module_param(dio_addr, ulong, 0);
191MODULE_PARM_DESC(dio_addr, "IO address for data, eg: 0x480");
192module_param(cio_addr, ulong, 0);
193MODULE_PARM_DESC(cio_addr, "IO address for control, eg: 0x400");
194module_param(c2io_addr, ulong, 0);
195MODULE_PARM_DESC(c2io_addr, "IO address for secondary control, eg: 0x408");
196module_param(splashval, ulong, 0);
197MODULE_PARM_DESC(splashval, "Splash pattern: 0x00 is black, 0x01 is white");
198
199MODULE_DESCRIPTION("board driver for n411 hecuba/apollo epd kit");
200MODULE_AUTHOR("Jaya Kumar");
201MODULE_LICENSE("GPL");
202
diff --git a/drivers/video/nvidia/nv_hw.c b/drivers/video/nvidia/nv_hw.c
index d1a10549f543..ed20a9871b33 100644
--- a/drivers/video/nvidia/nv_hw.c
+++ b/drivers/video/nvidia/nv_hw.c
@@ -129,7 +129,7 @@ typedef struct {
129 int nvclk_khz; 129 int nvclk_khz;
130 char mem_page_miss; 130 char mem_page_miss;
131 char mem_latency; 131 char mem_latency;
132 int memory_type; 132 u32 memory_type;
133 int memory_width; 133 int memory_width;
134 char enable_video; 134 char enable_video;
135 char gr_during_vid; 135 char gr_during_vid;
@@ -719,7 +719,7 @@ static void nForceUpdateArbitrationSettings(unsigned VClk,
719 memctrl >>= 16; 719 memctrl >>= 16;
720 720
721 if ((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) { 721 if ((memctrl == 0x1A9) || (memctrl == 0x1AB) || (memctrl == 0x1ED)) {
722 int dimm[3]; 722 u32 dimm[3];
723 723
724 dev = pci_get_bus_and_slot(0, 2); 724 dev = pci_get_bus_and_slot(0, 2);
725 pci_read_config_dword(dev, 0x40, &dimm[0]); 725 pci_read_config_dword(dev, 0x40, &dimm[0]);
diff --git a/drivers/video/nvidia/nv_setup.c b/drivers/video/nvidia/nv_setup.c
index 82579d3a9970..d9627b57eb4d 100644
--- a/drivers/video/nvidia/nv_setup.c
+++ b/drivers/video/nvidia/nv_setup.c
@@ -265,12 +265,12 @@ static void nv10GetConfig(struct nvidia_par *par)
265 265
266 dev = pci_get_bus_and_slot(0, 1); 266 dev = pci_get_bus_and_slot(0, 1);
267 if ((par->Chipset & 0xffff) == 0x01a0) { 267 if ((par->Chipset & 0xffff) == 0x01a0) {
268 int amt = 0; 268 u32 amt;
269 269
270 pci_read_config_dword(dev, 0x7c, &amt); 270 pci_read_config_dword(dev, 0x7c, &amt);
271 par->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024; 271 par->RamAmountKBytes = (((amt >> 6) & 31) + 1) * 1024;
272 } else if ((par->Chipset & 0xffff) == 0x01f0) { 272 } else if ((par->Chipset & 0xffff) == 0x01f0) {
273 int amt = 0; 273 u32 amt;
274 274
275 pci_read_config_dword(dev, 0x84, &amt); 275 pci_read_config_dword(dev, 0x84, &amt);
276 par->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024; 276 par->RamAmountKBytes = (((amt >> 4) & 127) + 1) * 1024;
diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
index 596652d2831f..9dbb5a5a267b 100644
--- a/drivers/video/nvidia/nvidia.c
+++ b/drivers/video/nvidia/nvidia.c
@@ -43,14 +43,14 @@
43#define NVTRACE if (0) printk 43#define NVTRACE if (0) printk
44#endif 44#endif
45 45
46#define NVTRACE_ENTER(...) NVTRACE("%s START\n", __FUNCTION__) 46#define NVTRACE_ENTER(...) NVTRACE("%s START\n", __func__)
47#define NVTRACE_LEAVE(...) NVTRACE("%s END\n", __FUNCTION__) 47#define NVTRACE_LEAVE(...) NVTRACE("%s END\n", __func__)
48 48
49#ifdef CONFIG_FB_NVIDIA_DEBUG 49#ifdef CONFIG_FB_NVIDIA_DEBUG
50#define assert(expr) \ 50#define assert(expr) \
51 if (!(expr)) { \ 51 if (!(expr)) { \
52 printk( "Assertion failed! %s,%s,%s,line=%d\n",\ 52 printk( "Assertion failed! %s,%s,%s,line=%d\n",\
53 #expr,__FILE__,__FUNCTION__,__LINE__); \ 53 #expr,__FILE__,__func__,__LINE__); \
54 BUG(); \ 54 BUG(); \
55 } 55 }
56#else 56#else
@@ -1559,7 +1559,6 @@ static int __devinit nvidiafb_init(void)
1559 1559
1560module_init(nvidiafb_init); 1560module_init(nvidiafb_init);
1561 1561
1562#ifdef MODULE
1563static void __exit nvidiafb_exit(void) 1562static void __exit nvidiafb_exit(void)
1564{ 1563{
1565 pci_unregister_driver(&nvidiafb_driver); 1564 pci_unregister_driver(&nvidiafb_driver);
@@ -1615,5 +1614,3 @@ MODULE_PARM_DESC(nomtrr, "Disables MTRR support (0 or 1=disabled) "
1615MODULE_AUTHOR("Antonino Daplas"); 1614MODULE_AUTHOR("Antonino Daplas");
1616MODULE_DESCRIPTION("Framebuffer driver for nVidia graphics chipset"); 1615MODULE_DESCRIPTION("Framebuffer driver for nVidia graphics chipset");
1617MODULE_LICENSE("GPL"); 1616MODULE_LICENSE("GPL");
1618#endif /* MODULE */
1619
diff --git a/drivers/video/offb.c b/drivers/video/offb.c
index 452433d46973..d7b3dcc0dc43 100644
--- a/drivers/video/offb.c
+++ b/drivers/video/offb.c
@@ -248,7 +248,7 @@ static void __iomem *offb_map_reg(struct device_node *np, int index,
248static void __init offb_init_fb(const char *name, const char *full_name, 248static void __init offb_init_fb(const char *name, const char *full_name,
249 int width, int height, int depth, 249 int width, int height, int depth,
250 int pitch, unsigned long address, 250 int pitch, unsigned long address,
251 struct device_node *dp) 251 int foreign_endian, struct device_node *dp)
252{ 252{
253 unsigned long res_size = pitch * height * (depth + 7) / 8; 253 unsigned long res_size = pitch * height * (depth + 7) / 8;
254 struct offb_par *par = &default_par; 254 struct offb_par *par = &default_par;
@@ -397,7 +397,7 @@ static void __init offb_init_fb(const char *name, const char *full_name,
397 info->screen_base = ioremap(address, fix->smem_len); 397 info->screen_base = ioremap(address, fix->smem_len);
398 info->par = par; 398 info->par = par;
399 info->pseudo_palette = (void *) (info + 1); 399 info->pseudo_palette = (void *) (info + 1);
400 info->flags = FBINFO_DEFAULT; 400 info->flags = FBINFO_DEFAULT | foreign_endian;
401 401
402 fb_alloc_cmap(&info->cmap, 256, 0); 402 fb_alloc_cmap(&info->cmap, 256, 0);
403 403
@@ -424,6 +424,15 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
424 u64 rstart, address = OF_BAD_ADDR; 424 u64 rstart, address = OF_BAD_ADDR;
425 const u32 *pp, *addrp, *up; 425 const u32 *pp, *addrp, *up;
426 u64 asize; 426 u64 asize;
427 int foreign_endian = 0;
428
429#ifdef __BIG_ENDIAN
430 if (of_get_property(dp, "little-endian", NULL))
431 foreign_endian = FBINFO_FOREIGN_ENDIAN;
432#else
433 if (of_get_property(dp, "big-endian", NULL))
434 foreign_endian = FBINFO_FOREIGN_ENDIAN;
435#endif
427 436
428 pp = of_get_property(dp, "linux,bootx-depth", &len); 437 pp = of_get_property(dp, "linux,bootx-depth", &len);
429 if (pp == NULL) 438 if (pp == NULL)
@@ -509,7 +518,7 @@ static void __init offb_init_nodriver(struct device_node *dp, int no_real_node)
509 offb_init_fb(no_real_node ? "bootx" : dp->name, 518 offb_init_fb(no_real_node ? "bootx" : dp->name,
510 no_real_node ? "display" : dp->full_name, 519 no_real_node ? "display" : dp->full_name,
511 width, height, depth, pitch, address, 520 width, height, depth, pitch, address,
512 no_real_node ? NULL : dp); 521 foreign_endian, no_real_node ? NULL : dp);
513 } 522 }
514} 523}
515 524
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c
index 58496061142d..c95874fe9076 100644
--- a/drivers/video/p9100.c
+++ b/drivers/video/p9100.c
@@ -310,7 +310,7 @@ static int __devinit p9100_probe(struct of_device *op, const struct of_device_id
310 310
311 dev_set_drvdata(&op->dev, info); 311 dev_set_drvdata(&op->dev, info);
312 312
313 printk("%s: p9100 at %lx:%lx\n", 313 printk(KERN_INFO "%s: p9100 at %lx:%lx\n",
314 dp->full_name, 314 dp->full_name,
315 par->which_io, par->physbase); 315 par->which_io, par->physbase);
316 316
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c
index 30181b593829..3f1ca2adda3d 100644
--- a/drivers/video/pm2fb.c
+++ b/drivers/video/pm2fb.c
@@ -56,7 +56,7 @@
56#undef PM2FB_MASTER_DEBUG 56#undef PM2FB_MASTER_DEBUG
57#ifdef PM2FB_MASTER_DEBUG 57#ifdef PM2FB_MASTER_DEBUG
58#define DPRINTK(a, b...) \ 58#define DPRINTK(a, b...) \
59 printk(KERN_DEBUG "pm2fb: %s: " a, __FUNCTION__ , ## b) 59 printk(KERN_DEBUG "pm2fb: %s: " a, __func__ , ## b)
60#else 60#else
61#define DPRINTK(a, b...) 61#define DPRINTK(a, b...)
62#endif 62#endif
@@ -67,7 +67,7 @@
67 * Driver data 67 * Driver data
68 */ 68 */
69static int hwcursor = 1; 69static int hwcursor = 1;
70static char *mode __devinitdata; 70static char *mode_option __devinitdata;
71 71
72/* 72/*
73 * The XFree GLINT driver will (I think to implement hardware cursor 73 * The XFree GLINT driver will (I think to implement hardware cursor
@@ -1680,17 +1680,19 @@ static int __devinit pm2fb_probe(struct pci_dev *pdev,
1680 info->pixmap.scan_align = 1; 1680 info->pixmap.scan_align = 1;
1681 } 1681 }
1682 1682
1683 if (!mode) 1683 if (!mode_option)
1684 mode = "640x480@60"; 1684 mode_option = "640x480@60";
1685 1685
1686 err = fb_find_mode(&info->var, info, mode, NULL, 0, NULL, 8); 1686 err = fb_find_mode(&info->var, info, mode_option, NULL, 0, NULL, 8);
1687 if (!err || err == 4) 1687 if (!err || err == 4)
1688 info->var = pm2fb_var; 1688 info->var = pm2fb_var;
1689 1689
1690 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) 1690 retval = fb_alloc_cmap(&info->cmap, 256, 0);
1691 if (retval < 0)
1691 goto err_exit_both; 1692 goto err_exit_both;
1692 1693
1693 if (register_framebuffer(info) < 0) 1694 retval = register_framebuffer(info);
1695 if (retval < 0)
1694 goto err_exit_all; 1696 goto err_exit_all;
1695 1697
1696 printk(KERN_INFO "fb%d: %s frame buffer device, memory = %dK.\n", 1698 printk(KERN_INFO "fb%d: %s frame buffer device, memory = %dK.\n",
@@ -1797,7 +1799,7 @@ static int __init pm2fb_setup(char *options)
1797 else if (!strncmp(this_opt, "noaccel", 7)) 1799 else if (!strncmp(this_opt, "noaccel", 7))
1798 noaccel = 1; 1800 noaccel = 1;
1799 else 1801 else
1800 mode = this_opt; 1802 mode_option = this_opt;
1801 } 1803 }
1802 return 0; 1804 return 0;
1803} 1805}
@@ -1833,8 +1835,10 @@ static void __exit pm2fb_exit(void)
1833#ifdef MODULE 1835#ifdef MODULE
1834module_exit(pm2fb_exit); 1836module_exit(pm2fb_exit);
1835 1837
1836module_param(mode, charp, 0); 1838module_param(mode_option, charp, 0);
1837MODULE_PARM_DESC(mode, "Preferred video mode e.g. '648x480-8@60'"); 1839MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");
1840module_param_named(mode, mode_option, charp, 0);
1841MODULE_PARM_DESC(mode, "Initial video mode e.g. '648x480-8@60' (deprecated)");
1838module_param(lowhsync, bool, 0); 1842module_param(lowhsync, bool, 0);
1839MODULE_PARM_DESC(lowhsync, "Force horizontal sync low regardless of mode"); 1843MODULE_PARM_DESC(lowhsync, "Force horizontal sync low regardless of mode");
1840module_param(lowvsync, bool, 0); 1844module_param(lowvsync, bool, 0);
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index 5dba8cdd0517..68089d1456c2 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -45,7 +45,7 @@
45#undef PM3FB_MASTER_DEBUG 45#undef PM3FB_MASTER_DEBUG
46#ifdef PM3FB_MASTER_DEBUG 46#ifdef PM3FB_MASTER_DEBUG
47#define DPRINTK(a, b...) \ 47#define DPRINTK(a, b...) \
48 printk(KERN_DEBUG "pm3fb: %s: " a, __FUNCTION__ , ## b) 48 printk(KERN_DEBUG "pm3fb: %s: " a, __func__ , ## b)
49#else 49#else
50#define DPRINTK(a, b...) 50#define DPRINTK(a, b...)
51#endif 51#endif
@@ -1571,6 +1571,8 @@ module_exit(pm3fb_exit);
1571#endif 1571#endif
1572module_init(pm3fb_init); 1572module_init(pm3fb_init);
1573 1573
1574module_param(mode_option, charp, 0);
1575MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");
1574module_param(noaccel, bool, 0); 1576module_param(noaccel, bool, 0);
1575MODULE_PARM_DESC(noaccel, "Disable acceleration"); 1577MODULE_PARM_DESC(noaccel, "Disable acceleration");
1576module_param(hwcursor, int, 0644); 1578module_param(hwcursor, int, 0644);
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index 5c47968e7f21..d94c57ffbdb1 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -56,10 +56,6 @@
56#include "rivafb.h" 56#include "rivafb.h"
57#include "nvreg.h" 57#include "nvreg.h"
58 58
59#ifndef CONFIG_PCI /* sanity check */
60#error This driver requires PCI support.
61#endif
62
63/* version number of this driver */ 59/* version number of this driver */
64#define RIVAFB_VERSION "0.9.5b" 60#define RIVAFB_VERSION "0.9.5b"
65 61
@@ -74,14 +70,14 @@
74#define NVTRACE if(0) printk 70#define NVTRACE if(0) printk
75#endif 71#endif
76 72
77#define NVTRACE_ENTER(...) NVTRACE("%s START\n", __FUNCTION__) 73#define NVTRACE_ENTER(...) NVTRACE("%s START\n", __func__)
78#define NVTRACE_LEAVE(...) NVTRACE("%s END\n", __FUNCTION__) 74#define NVTRACE_LEAVE(...) NVTRACE("%s END\n", __func__)
79 75
80#ifdef CONFIG_FB_RIVA_DEBUG 76#ifdef CONFIG_FB_RIVA_DEBUG
81#define assert(expr) \ 77#define assert(expr) \
82 if(!(expr)) { \ 78 if(!(expr)) { \
83 printk( "Assertion failed! %s,%s,%s,line=%d\n",\ 79 printk( "Assertion failed! %s,%s,%s,line=%d\n",\
84 #expr,__FILE__,__FUNCTION__,__LINE__); \ 80 #expr,__FILE__,__func__,__LINE__); \
85 BUG(); \ 81 BUG(); \
86 } 82 }
87#else 83#else
@@ -2213,14 +2209,12 @@ static int __devinit rivafb_init(void)
2213 2209
2214module_init(rivafb_init); 2210module_init(rivafb_init);
2215 2211
2216#ifdef MODULE
2217static void __exit rivafb_exit(void) 2212static void __exit rivafb_exit(void)
2218{ 2213{
2219 pci_unregister_driver(&rivafb_driver); 2214 pci_unregister_driver(&rivafb_driver);
2220} 2215}
2221 2216
2222module_exit(rivafb_exit); 2217module_exit(rivafb_exit);
2223#endif /* MODULE */
2224 2218
2225module_param(noaccel, bool, 0); 2219module_param(noaccel, bool, 0);
2226MODULE_PARM_DESC(noaccel, "bool: disable acceleration"); 2220MODULE_PARM_DESC(noaccel, "bool: disable acceleration");
diff --git a/drivers/video/riva/nv_driver.c b/drivers/video/riva/nv_driver.c
index a11026812d1b..f3694cf17e58 100644
--- a/drivers/video/riva/nv_driver.c
+++ b/drivers/video/riva/nv_driver.c
@@ -41,11 +41,6 @@
41#include "rivafb.h" 41#include "rivafb.h"
42#include "nvreg.h" 42#include "nvreg.h"
43 43
44
45#ifndef CONFIG_PCI /* sanity check */
46#error This driver requires PCI support.
47#endif
48
49#define PFX "rivafb: " 44#define PFX "rivafb: "
50 45
51static inline unsigned char MISCin(struct riva_par *par) 46static inline unsigned char MISCin(struct riva_par *par)
@@ -163,7 +158,7 @@ unsigned long riva_get_memlen(struct riva_par *par)
163 unsigned long memlen = 0; 158 unsigned long memlen = 0;
164 unsigned int chipset = par->Chipset; 159 unsigned int chipset = par->Chipset;
165 struct pci_dev* dev; 160 struct pci_dev* dev;
166 int amt; 161 u32 amt;
167 162
168 switch (chip->Architecture) { 163 switch (chip->Architecture) {
169 case NV_ARCH_03: 164 case NV_ARCH_03:
diff --git a/drivers/video/riva/riva_hw.c b/drivers/video/riva/riva_hw.c
index 13307703a9f0..78fdbf5178d7 100644
--- a/drivers/video/riva/riva_hw.c
+++ b/drivers/video/riva/riva_hw.c
@@ -231,7 +231,7 @@ typedef struct {
231 int nvclk_khz; 231 int nvclk_khz;
232 char mem_page_miss; 232 char mem_page_miss;
233 char mem_latency; 233 char mem_latency;
234 int memory_type; 234 u32 memory_type;
235 int memory_width; 235 int memory_width;
236 char enable_video; 236 char enable_video;
237 char gr_during_vid; 237 char gr_during_vid;
@@ -2107,7 +2107,7 @@ static void nv10GetConfig
2107) 2107)
2108{ 2108{
2109 struct pci_dev* dev; 2109 struct pci_dev* dev;
2110 int amt; 2110 u32 amt;
2111 2111
2112#ifdef __BIG_ENDIAN 2112#ifdef __BIG_ENDIAN
2113 /* turn on big endian register access */ 2113 /* turn on big endian register access */
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c
index 71fa6edb5c47..13b38cbbe4cf 100644
--- a/drivers/video/s3c2410fb.c
+++ b/drivers/video/s3c2410fb.c
@@ -430,9 +430,9 @@ static void s3c2410fb_activate_var(struct fb_info *info)
430 struct fb_var_screeninfo *var = &info->var; 430 struct fb_var_screeninfo *var = &info->var;
431 int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock) / 2; 431 int clkdiv = s3c2410fb_calc_pixclk(fbi, var->pixclock) / 2;
432 432
433 dprintk("%s: var->xres = %d\n", __FUNCTION__, var->xres); 433 dprintk("%s: var->xres = %d\n", __func__, var->xres);
434 dprintk("%s: var->yres = %d\n", __FUNCTION__, var->yres); 434 dprintk("%s: var->yres = %d\n", __func__, var->yres);
435 dprintk("%s: var->bpp = %d\n", __FUNCTION__, var->bits_per_pixel); 435 dprintk("%s: var->bpp = %d\n", __func__, var->bits_per_pixel);
436 436
437 if (type == S3C2410_LCDCON1_TFT) { 437 if (type == S3C2410_LCDCON1_TFT) {
438 s3c2410fb_calculate_tft_lcd_regs(info, &fbi->regs); 438 s3c2410fb_calculate_tft_lcd_regs(info, &fbi->regs);
diff --git a/drivers/video/s3fb.c b/drivers/video/s3fb.c
index 7d53bc23b9c7..2972f112dbed 100644
--- a/drivers/video/s3fb.c
+++ b/drivers/video/s3fb.c
@@ -132,10 +132,10 @@ static const struct svga_timing_regs s3_timing_regs = {
132/* Module parameters */ 132/* Module parameters */
133 133
134 134
135static char *mode = "640x480-8@60"; 135static char *mode_option __devinitdata = "640x480-8@60";
136 136
137#ifdef CONFIG_MTRR 137#ifdef CONFIG_MTRR
138static int mtrr = 1; 138static int mtrr __devinitdata = 1;
139#endif 139#endif
140 140
141static int fasttext = 1; 141static int fasttext = 1;
@@ -145,8 +145,10 @@ MODULE_AUTHOR("(c) 2006-2007 Ondrej Zajicek <santiago@crfreenet.org>");
145MODULE_LICENSE("GPL"); 145MODULE_LICENSE("GPL");
146MODULE_DESCRIPTION("fbdev driver for S3 Trio/Virge"); 146MODULE_DESCRIPTION("fbdev driver for S3 Trio/Virge");
147 147
148module_param(mode, charp, 0444); 148module_param(mode_option, charp, 0444);
149MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc)"); 149MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
150module_param_named(mode, mode_option, charp, 0444);
151MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc) (deprecated)");
150 152
151#ifdef CONFIG_MTRR 153#ifdef CONFIG_MTRR
152module_param(mtrr, int, 0444); 154module_param(mtrr, int, 0444);
@@ -886,7 +888,7 @@ static int __devinit s3_pci_probe(struct pci_dev *dev, const struct pci_device_i
886 } 888 }
887 889
888 /* Allocate and fill driver data structure */ 890 /* Allocate and fill driver data structure */
889 info = framebuffer_alloc(sizeof(struct s3fb_info), NULL); 891 info = framebuffer_alloc(sizeof(struct s3fb_info), &(dev->dev));
890 if (!info) { 892 if (!info) {
891 dev_err(&(dev->dev), "cannot allocate memory\n"); 893 dev_err(&(dev->dev), "cannot allocate memory\n");
892 return -ENOMEM; 894 return -ENOMEM;
@@ -901,13 +903,13 @@ static int __devinit s3_pci_probe(struct pci_dev *dev, const struct pci_device_i
901 /* Prepare PCI device */ 903 /* Prepare PCI device */
902 rc = pci_enable_device(dev); 904 rc = pci_enable_device(dev);
903 if (rc < 0) { 905 if (rc < 0) {
904 dev_err(&(dev->dev), "cannot enable PCI device\n"); 906 dev_err(info->dev, "cannot enable PCI device\n");
905 goto err_enable_device; 907 goto err_enable_device;
906 } 908 }
907 909
908 rc = pci_request_regions(dev, "s3fb"); 910 rc = pci_request_regions(dev, "s3fb");
909 if (rc < 0) { 911 if (rc < 0) {
910 dev_err(&(dev->dev), "cannot reserve framebuffer region\n"); 912 dev_err(info->dev, "cannot reserve framebuffer region\n");
911 goto err_request_regions; 913 goto err_request_regions;
912 } 914 }
913 915
@@ -919,7 +921,7 @@ static int __devinit s3_pci_probe(struct pci_dev *dev, const struct pci_device_i
919 info->screen_base = pci_iomap(dev, 0, 0); 921 info->screen_base = pci_iomap(dev, 0, 0);
920 if (! info->screen_base) { 922 if (! info->screen_base) {
921 rc = -ENOMEM; 923 rc = -ENOMEM;
922 dev_err(&(dev->dev), "iomap for framebuffer failed\n"); 924 dev_err(info->dev, "iomap for framebuffer failed\n");
923 goto err_iomap; 925 goto err_iomap;
924 } 926 }
925 927
@@ -960,22 +962,22 @@ static int __devinit s3_pci_probe(struct pci_dev *dev, const struct pci_device_i
960 info->pseudo_palette = (void*) (par->pseudo_palette); 962 info->pseudo_palette = (void*) (par->pseudo_palette);
961 963
962 /* Prepare startup mode */ 964 /* Prepare startup mode */
963 rc = fb_find_mode(&(info->var), info, mode, NULL, 0, NULL, 8); 965 rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
964 if (! ((rc == 1) || (rc == 2))) { 966 if (! ((rc == 1) || (rc == 2))) {
965 rc = -EINVAL; 967 rc = -EINVAL;
966 dev_err(&(dev->dev), "mode %s not found\n", mode); 968 dev_err(info->dev, "mode %s not found\n", mode_option);
967 goto err_find_mode; 969 goto err_find_mode;
968 } 970 }
969 971
970 rc = fb_alloc_cmap(&info->cmap, 256, 0); 972 rc = fb_alloc_cmap(&info->cmap, 256, 0);
971 if (rc < 0) { 973 if (rc < 0) {
972 dev_err(&(dev->dev), "cannot allocate colormap\n"); 974 dev_err(info->dev, "cannot allocate colormap\n");
973 goto err_alloc_cmap; 975 goto err_alloc_cmap;
974 } 976 }
975 977
976 rc = register_framebuffer(info); 978 rc = register_framebuffer(info);
977 if (rc < 0) { 979 if (rc < 0) {
978 dev_err(&(dev->dev), "cannot register framebuffer\n"); 980 dev_err(info->dev, "cannot register framebuffer\n");
979 goto err_reg_fb; 981 goto err_reg_fb;
980 } 982 }
981 983
@@ -1051,7 +1053,7 @@ static int s3_pci_suspend(struct pci_dev* dev, pm_message_t state)
1051 struct fb_info *info = pci_get_drvdata(dev); 1053 struct fb_info *info = pci_get_drvdata(dev);
1052 struct s3fb_info *par = info->par; 1054 struct s3fb_info *par = info->par;
1053 1055
1054 dev_info(&(dev->dev), "suspend\n"); 1056 dev_info(info->dev, "suspend\n");
1055 1057
1056 acquire_console_sem(); 1058 acquire_console_sem();
1057 mutex_lock(&(par->open_lock)); 1059 mutex_lock(&(par->open_lock));
@@ -1083,7 +1085,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1083 struct s3fb_info *par = info->par; 1085 struct s3fb_info *par = info->par;
1084 int err; 1086 int err;
1085 1087
1086 dev_info(&(dev->dev), "resume\n"); 1088 dev_info(info->dev, "resume\n");
1087 1089
1088 acquire_console_sem(); 1090 acquire_console_sem();
1089 mutex_lock(&(par->open_lock)); 1091 mutex_lock(&(par->open_lock));
@@ -1100,7 +1102,7 @@ static int s3_pci_resume(struct pci_dev* dev)
1100 if (err) { 1102 if (err) {
1101 mutex_unlock(&(par->open_lock)); 1103 mutex_unlock(&(par->open_lock));
1102 release_console_sem(); 1104 release_console_sem();
1103 dev_err(&(dev->dev), "error %d enabling device for resume\n", err); 1105 dev_err(info->dev, "error %d enabling device for resume\n", err);
1104 return err; 1106 return err;
1105 } 1107 }
1106 pci_set_master(dev); 1108 pci_set_master(dev);
@@ -1168,7 +1170,7 @@ static int __init s3fb_setup(char *options)
1168 else if (!strncmp(opt, "fasttext:", 9)) 1170 else if (!strncmp(opt, "fasttext:", 9))
1169 fasttext = simple_strtoul(opt + 9, NULL, 0); 1171 fasttext = simple_strtoul(opt + 9, NULL, 0);
1170 else 1172 else
1171 mode = opt; 1173 mode_option = opt;
1172 } 1174 }
1173 1175
1174 return 0; 1176 return 0;
diff --git a/drivers/video/sa1100fb.h b/drivers/video/sa1100fb.h
index 48066ef3af05..f465b27ed860 100644
--- a/drivers/video/sa1100fb.h
+++ b/drivers/video/sa1100fb.h
@@ -132,7 +132,7 @@ struct sa1100fb_info {
132 * Debug macros 132 * Debug macros
133 */ 133 */
134#if DEBUG 134#if DEBUG
135# define DPRINTK(fmt, args...) printk("%s: " fmt, __FUNCTION__ , ## args) 135# define DPRINTK(fmt, args...) printk("%s: " fmt, __func__ , ## args)
136#else 136#else
137# define DPRINTK(fmt, args...) 137# define DPRINTK(fmt, args...)
138#endif 138#endif
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c
index 35c1ce62b216..783d4adffb93 100644
--- a/drivers/video/savage/savagefb-i2c.c
+++ b/drivers/video/savage/savagefb-i2c.c
@@ -140,7 +140,7 @@ static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
140 chan->adapter.id = I2C_HW_B_SAVAGE; 140 chan->adapter.id = I2C_HW_B_SAVAGE;
141 chan->adapter.algo_data = &chan->algo; 141 chan->adapter.algo_data = &chan->algo;
142 chan->adapter.dev.parent = &chan->par->pcidev->dev; 142 chan->adapter.dev.parent = &chan->par->pcidev->dev;
143 chan->algo.udelay = 40; 143 chan->algo.udelay = 10;
144 chan->algo.timeout = 20; 144 chan->algo.timeout = 20;
145 chan->algo.data = chan; 145 chan->algo.data = chan;
146 146
diff --git a/drivers/video/sis/sis.h b/drivers/video/sis/sis.h
index 9b05da6268f7..a14e82211037 100644
--- a/drivers/video/sis/sis.h
+++ b/drivers/video/sis/sis.h
@@ -55,7 +55,7 @@
55#undef SISFBDEBUG 55#undef SISFBDEBUG
56 56
57#ifdef SISFBDEBUG 57#ifdef SISFBDEBUG
58#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __FUNCTION__ , ## args) 58#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt, __func__ , ## args)
59#define TWDEBUG(x) printk(KERN_INFO x "\n"); 59#define TWDEBUG(x) printk(KERN_INFO x "\n");
60#else 60#else
61#define DPRINTK(fmt, args...) 61#define DPRINTK(fmt, args...)
diff --git a/drivers/video/sstfb.c b/drivers/video/sstfb.c
index 97784f9c184d..5b11a00f49bc 100644
--- a/drivers/video/sstfb.c
+++ b/drivers/video/sstfb.c
@@ -1006,7 +1006,7 @@ static int sst_set_pll_att_ti(struct fb_info *info,
1006 break; 1006 break;
1007 default: 1007 default:
1008 dprintk("%s: wrong clock code '%d'\n", 1008 dprintk("%s: wrong clock code '%d'\n",
1009 __FUNCTION__, clock); 1009 __func__, clock);
1010 return 0; 1010 return 0;
1011 } 1011 }
1012 udelay(300); 1012 udelay(300);
@@ -1048,7 +1048,7 @@ static int sst_set_pll_ics(struct fb_info *info,
1048 break; 1048 break;
1049 default: 1049 default:
1050 dprintk("%s: wrong clock code '%d'\n", 1050 dprintk("%s: wrong clock code '%d'\n",
1051 __FUNCTION__, clock); 1051 __func__, clock);
1052 return 0; 1052 return 0;
1053 } 1053 }
1054 udelay(300); 1054 udelay(300);
@@ -1079,7 +1079,7 @@ static void sst_set_vidmod_att_ti(struct fb_info *info, const int bpp)
1079 sst_dac_write(DACREG_RMR, (cr0 & 0x0f) | DACREG_CR0_16BPP); 1079 sst_dac_write(DACREG_RMR, (cr0 & 0x0f) | DACREG_CR0_16BPP);
1080 break; 1080 break;
1081 default: 1081 default:
1082 dprintk("%s: bad depth '%u'\n", __FUNCTION__, bpp); 1082 dprintk("%s: bad depth '%u'\n", __func__, bpp);
1083 break; 1083 break;
1084 } 1084 }
1085} 1085}
@@ -1093,7 +1093,7 @@ static void sst_set_vidmod_ics(struct fb_info *info, const int bpp)
1093 sst_dac_write(DACREG_ICS_CMD, DACREG_ICS_CMD_16BPP); 1093 sst_dac_write(DACREG_ICS_CMD, DACREG_ICS_CMD_16BPP);
1094 break; 1094 break;
1095 default: 1095 default:
1096 dprintk("%s: bad depth '%u'\n", __FUNCTION__, bpp); 1096 dprintk("%s: bad depth '%u'\n", __func__, bpp);
1097 break; 1097 break;
1098 } 1098 }
1099} 1099}
@@ -1133,7 +1133,7 @@ static int __devinit sst_detect_dactype(struct fb_info *info, struct sstfb_par *
1133 } 1133 }
1134 if (!ret) 1134 if (!ret)
1135 return 0; 1135 return 0;
1136 f_dprintk("%s found %s\n", __FUNCTION__, dacs[i].name); 1136 f_dprintk("%s found %s\n", __func__, dacs[i].name);
1137 par->dac_sw = dacs[i]; 1137 par->dac_sw = dacs[i];
1138 return 1; 1138 return 1;
1139} 1139}
diff --git a/drivers/video/stifb.c b/drivers/video/stifb.c
index f98be301140c..598d35eff935 100644
--- a/drivers/video/stifb.c
+++ b/drivers/video/stifb.c
@@ -164,11 +164,11 @@ static int __initdata stifb_bpp_pref[MAX_STI_ROMS];
164# define DEBUG_ON() debug_on=1 164# define DEBUG_ON() debug_on=1
165# define WRITE_BYTE(value,fb,reg) do { if (debug_on) \ 165# define WRITE_BYTE(value,fb,reg) do { if (debug_on) \
166 printk(KERN_DEBUG "%30s: WRITE_BYTE(0x%06x) = 0x%02x (old=0x%02x)\n", \ 166 printk(KERN_DEBUG "%30s: WRITE_BYTE(0x%06x) = 0x%02x (old=0x%02x)\n", \
167 __FUNCTION__, reg, value, READ_BYTE(fb,reg)); \ 167 __func__, reg, value, READ_BYTE(fb,reg)); \
168 gsc_writeb((value),(fb)->info.fix.mmio_start + (reg)); } while (0) 168 gsc_writeb((value),(fb)->info.fix.mmio_start + (reg)); } while (0)
169# define WRITE_WORD(value,fb,reg) do { if (debug_on) \ 169# define WRITE_WORD(value,fb,reg) do { if (debug_on) \
170 printk(KERN_DEBUG "%30s: WRITE_WORD(0x%06x) = 0x%08x (old=0x%08x)\n", \ 170 printk(KERN_DEBUG "%30s: WRITE_WORD(0x%06x) = 0x%08x (old=0x%08x)\n", \
171 __FUNCTION__, reg, value, READ_WORD(fb,reg)); \ 171 __func__, reg, value, READ_WORD(fb,reg)); \
172 gsc_writel((value),(fb)->info.fix.mmio_start + (reg)); } while (0) 172 gsc_writel((value),(fb)->info.fix.mmio_start + (reg)); } while (0)
173#endif /* DEBUG_STIFB_REGS */ 173#endif /* DEBUG_STIFB_REGS */
174 174
diff --git a/drivers/video/syscopyarea.c b/drivers/video/syscopyarea.c
index 37af10ab8f52..a352d5f46bbf 100644
--- a/drivers/video/syscopyarea.c
+++ b/drivers/video/syscopyarea.c
@@ -26,15 +26,15 @@
26 */ 26 */
27 27
28static void 28static void
29bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src, 29bitcpy(struct fb_info *p, unsigned long *dst, int dst_idx,
30 int src_idx, int bits, unsigned n) 30 const unsigned long *src, int src_idx, int bits, unsigned n)
31{ 31{
32 unsigned long first, last; 32 unsigned long first, last;
33 int const shift = dst_idx-src_idx; 33 int const shift = dst_idx-src_idx;
34 int left, right; 34 int left, right;
35 35
36 first = FB_SHIFT_HIGH(~0UL, dst_idx); 36 first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
37 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits)); 37 last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
38 38
39 if (!shift) { 39 if (!shift) {
40 /* Same alignment for source and dest */ 40 /* Same alignment for source and dest */
@@ -167,8 +167,8 @@ bitcpy(unsigned long *dst, int dst_idx, const unsigned long *src,
167 */ 167 */
168 168
169static void 169static void
170bitcpy_rev(unsigned long *dst, int dst_idx, const unsigned long *src, 170bitcpy_rev(struct fb_info *p, unsigned long *dst, int dst_idx,
171 int src_idx, int bits, unsigned n) 171 const unsigned long *src, int src_idx, int bits, unsigned n)
172{ 172{
173 unsigned long first, last; 173 unsigned long first, last;
174 int shift; 174 int shift;
@@ -186,8 +186,8 @@ bitcpy_rev(unsigned long *dst, int dst_idx, const unsigned long *src,
186 186
187 shift = dst_idx-src_idx; 187 shift = dst_idx-src_idx;
188 188
189 first = FB_SHIFT_LOW(~0UL, bits - 1 - dst_idx); 189 first = FB_SHIFT_LOW(p, ~0UL, bits - 1 - dst_idx);
190 last = ~(FB_SHIFT_LOW(~0UL, bits - 1 - ((dst_idx-n) % bits))); 190 last = ~(FB_SHIFT_LOW(p, ~0UL, bits - 1 - ((dst_idx-n) % bits)));
191 191
192 if (!shift) { 192 if (!shift) {
193 /* Same alignment for source and dest */ 193 /* Same alignment for source and dest */
@@ -353,7 +353,7 @@ void sys_copyarea(struct fb_info *p, const struct fb_copyarea *area)
353 dst_idx &= (bytes - 1); 353 dst_idx &= (bytes - 1);
354 src += src_idx >> (ffs(bits) - 1); 354 src += src_idx >> (ffs(bits) - 1);
355 src_idx &= (bytes - 1); 355 src_idx &= (bytes - 1);
356 bitcpy_rev(dst, dst_idx, src, src_idx, bits, 356 bitcpy_rev(p, dst, dst_idx, src, src_idx, bits,
357 width*p->var.bits_per_pixel); 357 width*p->var.bits_per_pixel);
358 } 358 }
359 } else { 359 } else {
@@ -362,7 +362,7 @@ void sys_copyarea(struct fb_info *p, const struct fb_copyarea *area)
362 dst_idx &= (bytes - 1); 362 dst_idx &= (bytes - 1);
363 src += src_idx >> (ffs(bits) - 1); 363 src += src_idx >> (ffs(bits) - 1);
364 src_idx &= (bytes - 1); 364 src_idx &= (bytes - 1);
365 bitcpy(dst, dst_idx, src, src_idx, bits, 365 bitcpy(p, dst, dst_idx, src, src_idx, bits,
366 width*p->var.bits_per_pixel); 366 width*p->var.bits_per_pixel);
367 dst_idx += bits_per_line; 367 dst_idx += bits_per_line;
368 src_idx += bits_per_line; 368 src_idx += bits_per_line;
diff --git a/drivers/video/sysfillrect.c b/drivers/video/sysfillrect.c
index a261e9e6a675..f94d6b6e29ee 100644
--- a/drivers/video/sysfillrect.c
+++ b/drivers/video/sysfillrect.c
@@ -22,16 +22,16 @@
22 */ 22 */
23 23
24static void 24static void
25bitfill_aligned(unsigned long *dst, int dst_idx, unsigned long pat, 25bitfill_aligned(struct fb_info *p, unsigned long *dst, int dst_idx,
26 unsigned n, int bits) 26 unsigned long pat, unsigned n, int bits)
27{ 27{
28 unsigned long first, last; 28 unsigned long first, last;
29 29
30 if (!n) 30 if (!n)
31 return; 31 return;
32 32
33 first = FB_SHIFT_HIGH(~0UL, dst_idx); 33 first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
34 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits)); 34 last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
35 35
36 if (dst_idx+n <= bits) { 36 if (dst_idx+n <= bits) {
37 /* Single word */ 37 /* Single word */
@@ -78,16 +78,16 @@ bitfill_aligned(unsigned long *dst, int dst_idx, unsigned long pat,
78 */ 78 */
79 79
80static void 80static void
81bitfill_unaligned(unsigned long *dst, int dst_idx, unsigned long pat, 81bitfill_unaligned(struct fb_info *p, unsigned long *dst, int dst_idx,
82 int left, int right, unsigned n, int bits) 82 unsigned long pat, int left, int right, unsigned n, int bits)
83{ 83{
84 unsigned long first, last; 84 unsigned long first, last;
85 85
86 if (!n) 86 if (!n)
87 return; 87 return;
88 88
89 first = FB_SHIFT_HIGH(~0UL, dst_idx); 89 first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
90 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits)); 90 last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
91 91
92 if (dst_idx+n <= bits) { 92 if (dst_idx+n <= bits) {
93 /* Single word */ 93 /* Single word */
@@ -132,8 +132,8 @@ bitfill_unaligned(unsigned long *dst, int dst_idx, unsigned long pat,
132 * Aligned pattern invert using 32/64-bit memory accesses 132 * Aligned pattern invert using 32/64-bit memory accesses
133 */ 133 */
134static void 134static void
135bitfill_aligned_rev(unsigned long *dst, int dst_idx, unsigned long pat, 135bitfill_aligned_rev(struct fb_info *p, unsigned long *dst, int dst_idx,
136 unsigned n, int bits) 136 unsigned long pat, unsigned n, int bits)
137{ 137{
138 unsigned long val = pat; 138 unsigned long val = pat;
139 unsigned long first, last; 139 unsigned long first, last;
@@ -141,8 +141,8 @@ bitfill_aligned_rev(unsigned long *dst, int dst_idx, unsigned long pat,
141 if (!n) 141 if (!n)
142 return; 142 return;
143 143
144 first = FB_SHIFT_HIGH(~0UL, dst_idx); 144 first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
145 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits)); 145 last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
146 146
147 if (dst_idx+n <= bits) { 147 if (dst_idx+n <= bits) {
148 /* Single word */ 148 /* Single word */
@@ -188,16 +188,17 @@ bitfill_aligned_rev(unsigned long *dst, int dst_idx, unsigned long pat,
188 */ 188 */
189 189
190static void 190static void
191bitfill_unaligned_rev(unsigned long *dst, int dst_idx, unsigned long pat, 191bitfill_unaligned_rev(struct fb_info *p, unsigned long *dst, int dst_idx,
192 int left, int right, unsigned n, int bits) 192 unsigned long pat, int left, int right, unsigned n,
193 int bits)
193{ 194{
194 unsigned long first, last; 195 unsigned long first, last;
195 196
196 if (!n) 197 if (!n)
197 return; 198 return;
198 199
199 first = FB_SHIFT_HIGH(~0UL, dst_idx); 200 first = FB_SHIFT_HIGH(p, ~0UL, dst_idx);
200 last = ~(FB_SHIFT_HIGH(~0UL, (dst_idx+n) % bits)); 201 last = ~(FB_SHIFT_HIGH(p, ~0UL, (dst_idx+n) % bits));
201 202
202 if (dst_idx+n <= bits) { 203 if (dst_idx+n <= bits) {
203 /* Single word */ 204 /* Single word */
@@ -267,9 +268,9 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
267 if (p->fbops->fb_sync) 268 if (p->fbops->fb_sync)
268 p->fbops->fb_sync(p); 269 p->fbops->fb_sync(p);
269 if (!left) { 270 if (!left) {
270 void (*fill_op32)(unsigned long *dst, int dst_idx, 271 void (*fill_op32)(struct fb_info *p, unsigned long *dst,
271 unsigned long pat, unsigned n, int bits) = 272 int dst_idx, unsigned long pat, unsigned n,
272 NULL; 273 int bits) = NULL;
273 274
274 switch (rect->rop) { 275 switch (rect->rop) {
275 case ROP_XOR: 276 case ROP_XOR:
@@ -287,16 +288,16 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
287 while (height--) { 288 while (height--) {
288 dst += dst_idx >> (ffs(bits) - 1); 289 dst += dst_idx >> (ffs(bits) - 1);
289 dst_idx &= (bits - 1); 290 dst_idx &= (bits - 1);
290 fill_op32(dst, dst_idx, pat, width*bpp, bits); 291 fill_op32(p, dst, dst_idx, pat, width*bpp, bits);
291 dst_idx += p->fix.line_length*8; 292 dst_idx += p->fix.line_length*8;
292 } 293 }
293 } else { 294 } else {
294 int right; 295 int right;
295 int r; 296 int r;
296 int rot = (left-dst_idx) % bpp; 297 int rot = (left-dst_idx) % bpp;
297 void (*fill_op)(unsigned long *dst, int dst_idx, 298 void (*fill_op)(struct fb_info *p, unsigned long *dst,
298 unsigned long pat, int left, int right, 299 int dst_idx, unsigned long pat, int left,
299 unsigned n, int bits) = NULL; 300 int right, unsigned n, int bits) = NULL;
300 301
301 /* rotate pattern to correct start position */ 302 /* rotate pattern to correct start position */
302 pat = pat << rot | pat >> (bpp-rot); 303 pat = pat << rot | pat >> (bpp-rot);
@@ -318,7 +319,7 @@ void sys_fillrect(struct fb_info *p, const struct fb_fillrect *rect)
318 while (height--) { 319 while (height--) {
319 dst += dst_idx >> (ffs(bits) - 1); 320 dst += dst_idx >> (ffs(bits) - 1);
320 dst_idx &= (bits - 1); 321 dst_idx &= (bits - 1);
321 fill_op(dst, dst_idx, pat, left, right, 322 fill_op(p, dst, dst_idx, pat, left, right,
322 width*bpp, bits); 323 width*bpp, bits);
323 r = (p->fix.line_length*8) % bpp; 324 r = (p->fix.line_length*8) % bpp;
324 pat = pat << (bpp-r) | pat >> r; 325 pat = pat << (bpp-r) | pat >> r;
diff --git a/drivers/video/sysimgblt.c b/drivers/video/sysimgblt.c
index bd7e7e9d155f..186c6f607be2 100644
--- a/drivers/video/sysimgblt.c
+++ b/drivers/video/sysimgblt.c
@@ -18,35 +18,31 @@
18#define DEBUG 18#define DEBUG
19 19
20#ifdef DEBUG 20#ifdef DEBUG
21#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__FUNCTION__,## args) 21#define DPRINTK(fmt, args...) printk(KERN_DEBUG "%s: " fmt,__func__,## args)
22#else 22#else
23#define DPRINTK(fmt, args...) 23#define DPRINTK(fmt, args...)
24#endif 24#endif
25 25
26static const u32 cfb_tab8[] = { 26static const u32 cfb_tab8_be[] = {
27#if defined(__BIG_ENDIAN)
28 0x00000000,0x000000ff,0x0000ff00,0x0000ffff, 27 0x00000000,0x000000ff,0x0000ff00,0x0000ffff,
29 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff, 28 0x00ff0000,0x00ff00ff,0x00ffff00,0x00ffffff,
30 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff, 29 0xff000000,0xff0000ff,0xff00ff00,0xff00ffff,
31 0xffff0000,0xffff00ff,0xffffff00,0xffffffff 30 0xffff0000,0xffff00ff,0xffffff00,0xffffffff
32#elif defined(__LITTLE_ENDIAN) 31};
32
33static const u32 cfb_tab8_le[] = {
33 0x00000000,0xff000000,0x00ff0000,0xffff0000, 34 0x00000000,0xff000000,0x00ff0000,0xffff0000,
34 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00, 35 0x0000ff00,0xff00ff00,0x00ffff00,0xffffff00,
35 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff, 36 0x000000ff,0xff0000ff,0x00ff00ff,0xffff00ff,
36 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff 37 0x0000ffff,0xff00ffff,0x00ffffff,0xffffffff
37#else
38#error FIXME: No endianness??
39#endif
40}; 38};
41 39
42static const u32 cfb_tab16[] = { 40static const u32 cfb_tab16_be[] = {
43#if defined(__BIG_ENDIAN)
44 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff 41 0x00000000, 0x0000ffff, 0xffff0000, 0xffffffff
45#elif defined(__LITTLE_ENDIAN) 42};
43
44static const u32 cfb_tab16_le[] = {
46 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff 45 0x00000000, 0xffff0000, 0x0000ffff, 0xffffffff
47#else
48#error FIXME: No endianness??
49#endif
50}; 46};
51 47
52static const u32 cfb_tab32[] = { 48static const u32 cfb_tab32[] = {
@@ -72,7 +68,7 @@ static void color_imageblit(const struct fb_image *image, struct fb_info *p,
72 val = 0; 68 val = 0;
73 69
74 if (start_index) { 70 if (start_index) {
75 u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0, 71 u32 start_mask = ~(FB_SHIFT_HIGH(p, ~(u32)0,
76 start_index)); 72 start_index));
77 val = *dst & start_mask; 73 val = *dst & start_mask;
78 shift = start_index; 74 shift = start_index;
@@ -83,20 +79,20 @@ static void color_imageblit(const struct fb_image *image, struct fb_info *p,
83 color = palette[*src]; 79 color = palette[*src];
84 else 80 else
85 color = *src; 81 color = *src;
86 color <<= FB_LEFT_POS(bpp); 82 color <<= FB_LEFT_POS(p, bpp);
87 val |= FB_SHIFT_HIGH(color, shift); 83 val |= FB_SHIFT_HIGH(p, color, shift);
88 if (shift >= null_bits) { 84 if (shift >= null_bits) {
89 *dst++ = val; 85 *dst++ = val;
90 86
91 val = (shift == null_bits) ? 0 : 87 val = (shift == null_bits) ? 0 :
92 FB_SHIFT_LOW(color, 32 - shift); 88 FB_SHIFT_LOW(p, color, 32 - shift);
93 } 89 }
94 shift += bpp; 90 shift += bpp;
95 shift &= (32 - 1); 91 shift &= (32 - 1);
96 src++; 92 src++;
97 } 93 }
98 if (shift) { 94 if (shift) {
99 u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift); 95 u32 end_mask = FB_SHIFT_HIGH(p, ~(u32)0, shift);
100 96
101 *dst &= end_mask; 97 *dst &= end_mask;
102 *dst |= val; 98 *dst |= val;
@@ -125,8 +121,8 @@ static void slow_imageblit(const struct fb_image *image, struct fb_info *p,
125 u32 i, j, l; 121 u32 i, j, l;
126 122
127 dst2 = dst1; 123 dst2 = dst1;
128 fgcolor <<= FB_LEFT_POS(bpp); 124 fgcolor <<= FB_LEFT_POS(p, bpp);
129 bgcolor <<= FB_LEFT_POS(bpp); 125 bgcolor <<= FB_LEFT_POS(p, bpp);
130 126
131 for (i = image->height; i--; ) { 127 for (i = image->height; i--; ) {
132 shift = val = 0; 128 shift = val = 0;
@@ -137,7 +133,8 @@ static void slow_imageblit(const struct fb_image *image, struct fb_info *p,
137 133
138 /* write leading bits */ 134 /* write leading bits */
139 if (start_index) { 135 if (start_index) {
140 u32 start_mask = ~(FB_SHIFT_HIGH(~(u32)0,start_index)); 136 u32 start_mask = ~(FB_SHIFT_HIGH(p, ~(u32)0,
137 start_index));
141 val = *dst & start_mask; 138 val = *dst & start_mask;
142 shift = start_index; 139 shift = start_index;
143 } 140 }
@@ -145,13 +142,13 @@ static void slow_imageblit(const struct fb_image *image, struct fb_info *p,
145 while (j--) { 142 while (j--) {
146 l--; 143 l--;
147 color = (*s & (1 << l)) ? fgcolor : bgcolor; 144 color = (*s & (1 << l)) ? fgcolor : bgcolor;
148 val |= FB_SHIFT_HIGH(color, shift); 145 val |= FB_SHIFT_HIGH(p, color, shift);
149 146
150 /* Did the bitshift spill bits to the next long? */ 147 /* Did the bitshift spill bits to the next long? */
151 if (shift >= null_bits) { 148 if (shift >= null_bits) {
152 *dst++ = val; 149 *dst++ = val;
153 val = (shift == null_bits) ? 0 : 150 val = (shift == null_bits) ? 0 :
154 FB_SHIFT_LOW(color,32 - shift); 151 FB_SHIFT_LOW(p, color, 32 - shift);
155 } 152 }
156 shift += bpp; 153 shift += bpp;
157 shift &= (32 - 1); 154 shift &= (32 - 1);
@@ -160,7 +157,7 @@ static void slow_imageblit(const struct fb_image *image, struct fb_info *p,
160 157
161 /* write trailing bits */ 158 /* write trailing bits */
162 if (shift) { 159 if (shift) {
163 u32 end_mask = FB_SHIFT_HIGH(~(u32)0, shift); 160 u32 end_mask = FB_SHIFT_HIGH(p, ~(u32)0, shift);
164 161
165 *dst &= end_mask; 162 *dst &= end_mask;
166 *dst |= val; 163 *dst |= val;
@@ -199,10 +196,10 @@ static void fast_imageblit(const struct fb_image *image, struct fb_info *p,
199 196
200 switch (bpp) { 197 switch (bpp) {
201 case 8: 198 case 8:
202 tab = cfb_tab8; 199 tab = fb_be_math(p) ? cfb_tab8_be : cfb_tab8_le;
203 break; 200 break;
204 case 16: 201 case 16:
205 tab = cfb_tab16; 202 tab = fb_be_math(p) ? cfb_tab16_be : cfb_tab16_le;
206 break; 203 break;
207 case 32: 204 case 32:
208 default: 205 default:
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c
index e5a9ddb3c8be..a71774305772 100644
--- a/drivers/video/tcx.c
+++ b/drivers/video/tcx.c
@@ -419,7 +419,7 @@ static int __devinit tcx_init_one(struct of_device *op)
419 par->mmap_map[6].size = SBUS_MMAP_EMPTY; 419 par->mmap_map[6].size = SBUS_MMAP_EMPTY;
420 } 420 }
421 421
422 par->physbase = 0; 422 par->physbase = op->resource[0].start;
423 par->which_io = op->resource[0].flags & IORESOURCE_BITS; 423 par->which_io = op->resource[0].flags & IORESOURCE_BITS;
424 424
425 for (i = 0; i < TCX_MMAP_ENTRIES; i++) { 425 for (i = 0; i < TCX_MMAP_ENTRIES; i++) {
@@ -470,10 +470,10 @@ static int __devinit tcx_init_one(struct of_device *op)
470 470
471 dev_set_drvdata(&op->dev, info); 471 dev_set_drvdata(&op->dev, info);
472 472
473 printk("%s: TCX at %lx:%lx, %s\n", 473 printk(KERN_INFO "%s: TCX at %lx:%lx, %s\n",
474 dp->full_name, 474 dp->full_name,
475 par->which_io, 475 par->which_io,
476 op->resource[0].start, 476 par->physbase,
477 par->lowdepth ? "8-bit only" : "24-bit depth"); 477 par->lowdepth ? "8-bit only" : "24-bit depth");
478 478
479 return 0; 479 return 0;
@@ -527,7 +527,7 @@ static struct of_platform_driver tcx_driver = {
527 .remove = __devexit_p(tcx_remove), 527 .remove = __devexit_p(tcx_remove),
528}; 528};
529 529
530int __init tcx_init(void) 530static int __init tcx_init(void)
531{ 531{
532 if (fb_get_options("tcxfb", NULL)) 532 if (fb_get_options("tcxfb", NULL))
533 return -ENODEV; 533 return -ENODEV;
@@ -535,7 +535,7 @@ int __init tcx_init(void)
535 return of_register_driver(&tcx_driver, &of_bus_type); 535 return of_register_driver(&tcx_driver, &of_bus_type);
536} 536}
537 537
538void __exit tcx_exit(void) 538static void __exit tcx_exit(void)
539{ 539{
540 of_unregister_driver(&tcx_driver); 540 of_unregister_driver(&tcx_driver);
541} 541}
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c
index 71e179ea5f95..ea9f19d25597 100644
--- a/drivers/video/tdfxfb.c
+++ b/drivers/video/tdfxfb.c
@@ -70,7 +70,7 @@
70 70
71#include <video/tdfx.h> 71#include <video/tdfx.h>
72 72
73#define DPRINTK(a, b...) pr_debug("fb: %s: " a, __FUNCTION__ , ## b) 73#define DPRINTK(a, b...) pr_debug("fb: %s: " a, __func__ , ## b)
74 74
75#ifdef CONFIG_MTRR 75#ifdef CONFIG_MTRR
76#include <asm/mtrr.h> 76#include <asm/mtrr.h>
diff --git a/drivers/video/tridentfb.c b/drivers/video/tridentfb.c
index 0a4e07d43d2d..bd54cd0de39a 100644
--- a/drivers/video/tridentfb.c
+++ b/drivers/video/tridentfb.c
@@ -58,7 +58,7 @@ static int displaytype;
58/* defaults which are normally overriden by user values */ 58/* defaults which are normally overriden by user values */
59 59
60/* video mode */ 60/* video mode */
61static char *mode = "640x480"; 61static char *mode_option __devinitdata = "640x480";
62static int bpp = 8; 62static int bpp = 8;
63 63
64static int noaccel; 64static int noaccel;
@@ -73,7 +73,10 @@ static int memsize;
73static int memdiff; 73static int memdiff;
74static int nativex; 74static int nativex;
75 75
76module_param(mode, charp, 0); 76module_param(mode_option, charp, 0);
77MODULE_PARM_DESC(mode_option, "Initial video mode e.g. '648x480-8@60'");
78module_param_named(mode, mode_option, charp, 0);
79MODULE_PARM_DESC(mode, "Initial video mode e.g. '648x480-8@60' (deprecated)");
77module_param(bpp, int, 0); 80module_param(bpp, int, 0);
78module_param(center, int, 0); 81module_param(center, int, 0);
79module_param(stretch, int, 0); 82module_param(stretch, int, 0);
@@ -1297,7 +1300,8 @@ static int __devinit trident_pci_probe(struct pci_dev * dev,
1297#endif 1300#endif
1298 fb_info.pseudo_palette = pseudo_pal; 1301 fb_info.pseudo_palette = pseudo_pal;
1299 1302
1300 if (!fb_find_mode(&default_var, &fb_info, mode, NULL, 0, NULL, bpp)) { 1303 if (!fb_find_mode(&default_var, &fb_info,
1304 mode_option, NULL, 0, NULL, bpp)) {
1301 err = -EINVAL; 1305 err = -EINVAL;
1302 goto out_unmap2; 1306 goto out_unmap2;
1303 } 1307 }
@@ -1385,7 +1389,7 @@ static struct pci_driver tridentfb_pci_driver = {
1385 * video=trident:800x600,bpp=16,noaccel 1389 * video=trident:800x600,bpp=16,noaccel
1386 */ 1390 */
1387#ifndef MODULE 1391#ifndef MODULE
1388static int tridentfb_setup(char *options) 1392static int __init tridentfb_setup(char *options)
1389{ 1393{
1390 char *opt; 1394 char *opt;
1391 if (!options || !*options) 1395 if (!options || !*options)
@@ -1412,7 +1416,7 @@ static int tridentfb_setup(char *options)
1412 else if (!strncmp(opt, "nativex=", 8)) 1416 else if (!strncmp(opt, "nativex=", 8))
1413 nativex = simple_strtoul(opt + 8, NULL, 0); 1417 nativex = simple_strtoul(opt + 8, NULL, 0);
1414 else 1418 else
1415 mode = opt; 1419 mode_option = opt;
1416 } 1420 }
1417 return 0; 1421 return 0;
1418} 1422}
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 93361656316c..cdbb56edb6cb 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -181,7 +181,8 @@ static int uvesafb_exec(struct uvesafb_ktask *task)
181 /* If all slots are taken -- bail out. */ 181 /* If all slots are taken -- bail out. */
182 if (uvfb_tasks[seq]) { 182 if (uvfb_tasks[seq]) {
183 mutex_unlock(&uvfb_lock); 183 mutex_unlock(&uvfb_lock);
184 return -EBUSY; 184 err = -EBUSY;
185 goto out;
185 } 186 }
186 187
187 /* Save a pointer to the kernel part of the task struct. */ 188 /* Save a pointer to the kernel part of the task struct. */
@@ -205,7 +206,6 @@ static int uvesafb_exec(struct uvesafb_ktask *task)
205 err = cn_netlink_send(m, 0, gfp_any()); 206 err = cn_netlink_send(m, 0, gfp_any());
206 } 207 }
207 } 208 }
208 kfree(m);
209 209
210 if (!err && !(task->t.flags & TF_EXIT)) 210 if (!err && !(task->t.flags & TF_EXIT))
211 err = !wait_for_completion_timeout(task->done, 211 err = !wait_for_completion_timeout(task->done,
@@ -218,7 +218,8 @@ static int uvesafb_exec(struct uvesafb_ktask *task)
218 seq++; 218 seq++;
219 if (seq >= UVESAFB_TASKS_MAX) 219 if (seq >= UVESAFB_TASKS_MAX)
220 seq = 0; 220 seq = 0;
221 221out:
222 kfree(m);
222 return err; 223 return err;
223} 224}
224 225
@@ -885,7 +886,7 @@ static int __devinit uvesafb_vbe_init_mode(struct fb_info *info)
885 } 886 }
886 887
887 /* fb_find_mode() failed */ 888 /* fb_find_mode() failed */
888 if (i == 0 || i >= 3) { 889 if (i == 0) {
889 info->var.xres = 640; 890 info->var.xres = 640;
890 info->var.yres = 480; 891 info->var.yres = 480;
891 mode = (struct fb_videomode *) 892 mode = (struct fb_videomode *)
diff --git a/drivers/video/vermilion/vermilion.c b/drivers/video/vermilion/vermilion.c
index 2aa71eb67c2b..c18f1884b550 100644
--- a/drivers/video/vermilion/vermilion.c
+++ b/drivers/video/vermilion/vermilion.c
@@ -112,8 +112,9 @@ static int vmlfb_alloc_vram_area(struct vram_area *va, unsigned max_order,
112 112
113 /* 113 /*
114 * It seems like __get_free_pages only ups the usage count 114 * It seems like __get_free_pages only ups the usage count
115 * of the first page. This doesn't work with nopage mapping, so 115 * of the first page. This doesn't work with fault mapping, so
116 * up the usage count once more. 116 * up the usage count once more (XXX: should use split_page or
117 * compound page).
117 */ 118 */
118 119
119 memset((void *)va->logical, 0x00, va->size); 120 memset((void *)va->logical, 0x00, va->size);
diff --git a/drivers/video/vt8623fb.c b/drivers/video/vt8623fb.c
index 4c3a63308df1..536ab11623f0 100644
--- a/drivers/video/vt8623fb.c
+++ b/drivers/video/vt8623fb.c
@@ -100,7 +100,7 @@ static struct svga_timing_regs vt8623_timing_regs = {
100 100
101/* Module parameters */ 101/* Module parameters */
102 102
103static char *mode = "640x480-8@60"; 103static char *mode_option = "640x480-8@60";
104 104
105#ifdef CONFIG_MTRR 105#ifdef CONFIG_MTRR
106static int mtrr = 1; 106static int mtrr = 1;
@@ -110,8 +110,10 @@ MODULE_AUTHOR("(c) 2006 Ondrej Zajicek <santiago@crfreenet.org>");
110MODULE_LICENSE("GPL"); 110MODULE_LICENSE("GPL");
111MODULE_DESCRIPTION("fbdev driver for integrated graphics core in VIA VT8623 [CLE266]"); 111MODULE_DESCRIPTION("fbdev driver for integrated graphics core in VIA VT8623 [CLE266]");
112 112
113module_param(mode, charp, 0644); 113module_param(mode_option, charp, 0644);
114MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc)"); 114MODULE_PARM_DESC(mode_option, "Default video mode ('640x480-8@60', etc)");
115module_param_named(mode, mode_option, charp, 0);
116MODULE_PARM_DESC(mode, "Default video mode e.g. '648x480-8@60' (deprecated)");
115 117
116#ifdef CONFIG_MTRR 118#ifdef CONFIG_MTRR
117module_param(mtrr, int, 0444); 119module_param(mtrr, int, 0444);
@@ -434,6 +436,10 @@ static int vt8623fb_set_par(struct fb_info *info)
434 svga_wcrt_multi(vt8623_offset_regs, offset_value); 436 svga_wcrt_multi(vt8623_offset_regs, offset_value);
435 svga_wseq_multi(vt8623_fetch_count_regs, fetch_value); 437 svga_wseq_multi(vt8623_fetch_count_regs, fetch_value);
436 438
439 /* Clear H/V Skew */
440 svga_wcrt_mask(0x03, 0x00, 0x60);
441 svga_wcrt_mask(0x05, 0x00, 0x60);
442
437 if (info->var.vmode & FB_VMODE_DOUBLE) 443 if (info->var.vmode & FB_VMODE_DOUBLE)
438 svga_wcrt_mask(0x09, 0x80, 0x80); 444 svga_wcrt_mask(0x09, 0x80, 0x80);
439 else 445 else
@@ -655,7 +661,7 @@ static int __devinit vt8623_pci_probe(struct pci_dev *dev, const struct pci_devi
655 } 661 }
656 662
657 /* Allocate and fill driver data structure */ 663 /* Allocate and fill driver data structure */
658 info = framebuffer_alloc(sizeof(struct vt8623fb_info), NULL); 664 info = framebuffer_alloc(sizeof(struct vt8623fb_info), &(dev->dev));
659 if (! info) { 665 if (! info) {
660 dev_err(&(dev->dev), "cannot allocate memory\n"); 666 dev_err(&(dev->dev), "cannot allocate memory\n");
661 return -ENOMEM; 667 return -ENOMEM;
@@ -671,13 +677,13 @@ static int __devinit vt8623_pci_probe(struct pci_dev *dev, const struct pci_devi
671 677
672 rc = pci_enable_device(dev); 678 rc = pci_enable_device(dev);
673 if (rc < 0) { 679 if (rc < 0) {
674 dev_err(&(dev->dev), "cannot enable PCI device\n"); 680 dev_err(info->dev, "cannot enable PCI device\n");
675 goto err_enable_device; 681 goto err_enable_device;
676 } 682 }
677 683
678 rc = pci_request_regions(dev, "vt8623fb"); 684 rc = pci_request_regions(dev, "vt8623fb");
679 if (rc < 0) { 685 if (rc < 0) {
680 dev_err(&(dev->dev), "cannot reserve framebuffer region\n"); 686 dev_err(info->dev, "cannot reserve framebuffer region\n");
681 goto err_request_regions; 687 goto err_request_regions;
682 } 688 }
683 689
@@ -690,14 +696,14 @@ static int __devinit vt8623_pci_probe(struct pci_dev *dev, const struct pci_devi
690 info->screen_base = pci_iomap(dev, 0, 0); 696 info->screen_base = pci_iomap(dev, 0, 0);
691 if (! info->screen_base) { 697 if (! info->screen_base) {
692 rc = -ENOMEM; 698 rc = -ENOMEM;
693 dev_err(&(dev->dev), "iomap for framebuffer failed\n"); 699 dev_err(info->dev, "iomap for framebuffer failed\n");
694 goto err_iomap_1; 700 goto err_iomap_1;
695 } 701 }
696 702
697 par->mmio_base = pci_iomap(dev, 1, 0); 703 par->mmio_base = pci_iomap(dev, 1, 0);
698 if (! par->mmio_base) { 704 if (! par->mmio_base) {
699 rc = -ENOMEM; 705 rc = -ENOMEM;
700 dev_err(&(dev->dev), "iomap for MMIO failed\n"); 706 dev_err(info->dev, "iomap for MMIO failed\n");
701 goto err_iomap_2; 707 goto err_iomap_2;
702 } 708 }
703 709
@@ -708,7 +714,7 @@ static int __devinit vt8623_pci_probe(struct pci_dev *dev, const struct pci_devi
708 if ((16 <= memsize1) && (memsize1 <= 64) && (memsize1 == memsize2)) 714 if ((16 <= memsize1) && (memsize1 <= 64) && (memsize1 == memsize2))
709 info->screen_size = memsize1 << 20; 715 info->screen_size = memsize1 << 20;
710 else { 716 else {
711 dev_err(&(dev->dev), "memory size detection failed (%x %x), suppose 16 MB\n", memsize1, memsize2); 717 dev_err(info->dev, "memory size detection failed (%x %x), suppose 16 MB\n", memsize1, memsize2);
712 info->screen_size = 16 << 20; 718 info->screen_size = 16 << 20;
713 } 719 }
714 720
@@ -722,22 +728,22 @@ static int __devinit vt8623_pci_probe(struct pci_dev *dev, const struct pci_devi
722 728
723 /* Prepare startup mode */ 729 /* Prepare startup mode */
724 730
725 rc = fb_find_mode(&(info->var), info, mode, NULL, 0, NULL, 8); 731 rc = fb_find_mode(&(info->var), info, mode_option, NULL, 0, NULL, 8);
726 if (! ((rc == 1) || (rc == 2))) { 732 if (! ((rc == 1) || (rc == 2))) {
727 rc = -EINVAL; 733 rc = -EINVAL;
728 dev_err(&(dev->dev), "mode %s not found\n", mode); 734 dev_err(info->dev, "mode %s not found\n", mode_option);
729 goto err_find_mode; 735 goto err_find_mode;
730 } 736 }
731 737
732 rc = fb_alloc_cmap(&info->cmap, 256, 0); 738 rc = fb_alloc_cmap(&info->cmap, 256, 0);
733 if (rc < 0) { 739 if (rc < 0) {
734 dev_err(&(dev->dev), "cannot allocate colormap\n"); 740 dev_err(info->dev, "cannot allocate colormap\n");
735 goto err_alloc_cmap; 741 goto err_alloc_cmap;
736 } 742 }
737 743
738 rc = register_framebuffer(info); 744 rc = register_framebuffer(info);
739 if (rc < 0) { 745 if (rc < 0) {
740 dev_err(&(dev->dev), "cannot register framebugger\n"); 746 dev_err(info->dev, "cannot register framebugger\n");
741 goto err_reg_fb; 747 goto err_reg_fb;
742 } 748 }
743 749
@@ -811,7 +817,7 @@ static int vt8623_pci_suspend(struct pci_dev* dev, pm_message_t state)
811 struct fb_info *info = pci_get_drvdata(dev); 817 struct fb_info *info = pci_get_drvdata(dev);
812 struct vt8623fb_info *par = info->par; 818 struct vt8623fb_info *par = info->par;
813 819
814 dev_info(&(dev->dev), "suspend\n"); 820 dev_info(info->dev, "suspend\n");
815 821
816 acquire_console_sem(); 822 acquire_console_sem();
817 mutex_lock(&(par->open_lock)); 823 mutex_lock(&(par->open_lock));
@@ -842,7 +848,7 @@ static int vt8623_pci_resume(struct pci_dev* dev)
842 struct fb_info *info = pci_get_drvdata(dev); 848 struct fb_info *info = pci_get_drvdata(dev);
843 struct vt8623fb_info *par = info->par; 849 struct vt8623fb_info *par = info->par;
844 850
845 dev_info(&(dev->dev), "resume\n"); 851 dev_info(info->dev, "resume\n");
846 852
847 acquire_console_sem(); 853 acquire_console_sem();
848 mutex_lock(&(par->open_lock)); 854 mutex_lock(&(par->open_lock));
@@ -913,7 +919,7 @@ static int __init vt8623fb_init(void)
913 return -ENODEV; 919 return -ENODEV;
914 920
915 if (option && *option) 921 if (option && *option)
916 mode = option; 922 mode_option = option;
917#endif 923#endif
918 924
919 pr_debug("vt8623fb: initializing\n"); 925 pr_debug("vt8623fb: initializing\n");
diff --git a/drivers/video/w100fb.c b/drivers/video/w100fb.c
index 003c49a490eb..30469bf906e5 100644
--- a/drivers/video/w100fb.c
+++ b/drivers/video/w100fb.c
@@ -765,8 +765,10 @@ int __init w100fb_probe(struct platform_device *pdev)
765 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id); 765 printk(KERN_INFO "fb%d: %s frame buffer device\n", info->node, info->fix.id);
766 return 0; 766 return 0;
767out: 767out:
768 fb_dealloc_cmap(&info->cmap); 768 if (info) {
769 kfree(info->pseudo_palette); 769 fb_dealloc_cmap(&info->cmap);
770 kfree(info->pseudo_palette);
771 }
770 if (remapped_fbuf != NULL) 772 if (remapped_fbuf != NULL)
771 iounmap(remapped_fbuf); 773 iounmap(remapped_fbuf);
772 if (remapped_regs != NULL) 774 if (remapped_regs != NULL)