diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2008-10-13 12:13:56 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2008-10-13 12:13:56 -0400 |
commit | e758936e02700ff88a0b08b722a3847b95283ef2 (patch) | |
tree | 50c919bef1b459a778b85159d5929de95b6c4a01 /drivers/video | |
parent | 239cfbde1f5843c4a24199f117d5f67f637d72d5 (diff) | |
parent | 4480f15b3306f43bbb0310d461142b4e897ca45b (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
include/asm-x86/statfs.h
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/Kconfig | 33 | ||||
-rw-r--r-- | drivers/video/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/am200epd.c | 295 | ||||
-rw-r--r-- | drivers/video/atmel_lcdfb.c | 98 | ||||
-rw-r--r-- | drivers/video/backlight/Kconfig | 15 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 2 | ||||
-rw-r--r-- | drivers/video/backlight/corgi_lcd.c | 641 | ||||
-rw-r--r-- | drivers/video/backlight/lcd.c | 18 | ||||
-rw-r--r-- | drivers/video/backlight/tdo24m.c | 396 | ||||
-rw-r--r-- | drivers/video/bw2.c | 2 | ||||
-rw-r--r-- | drivers/video/cg14.c | 2 | ||||
-rw-r--r-- | drivers/video/cg3.c | 2 | ||||
-rw-r--r-- | drivers/video/cg6.c | 38 | ||||
-rw-r--r-- | drivers/video/cirrusfb.c | 59 | ||||
-rw-r--r-- | drivers/video/console/Kconfig | 16 | ||||
-rw-r--r-- | drivers/video/console/fbcon.c | 6 | ||||
-rw-r--r-- | drivers/video/console/fbcon.h | 2 | ||||
-rw-r--r-- | drivers/video/fbmem.c | 1 | ||||
-rw-r--r-- | drivers/video/ffb.c | 2 | ||||
-rw-r--r-- | drivers/video/leo.c | 96 | ||||
-rw-r--r-- | drivers/video/metronomefb.c | 288 | ||||
-rw-r--r-- | drivers/video/p9100.c | 2 | ||||
-rw-r--r-- | drivers/video/tcx.c | 2 | ||||
-rw-r--r-- | drivers/video/tdfxfb.c | 9 | ||||
-rw-r--r-- | drivers/video/xen-fbfront.c | 4 |
25 files changed, 1425 insertions, 605 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 70d135e0cc47..f79c2040758b 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -172,11 +172,6 @@ config FB_DEFERRED_IO | |||
172 | bool | 172 | bool |
173 | depends on FB | 173 | depends on FB |
174 | 174 | ||
175 | config FB_METRONOME | ||
176 | tristate | ||
177 | depends on FB | ||
178 | depends on FB_DEFERRED_IO | ||
179 | |||
180 | config FB_HECUBA | 175 | config FB_HECUBA |
181 | tristate | 176 | tristate |
182 | depends on FB | 177 | depends on FB |
@@ -678,7 +673,6 @@ config FB_VESA | |||
678 | select FB_CFB_FILLRECT | 673 | select FB_CFB_FILLRECT |
679 | select FB_CFB_COPYAREA | 674 | select FB_CFB_COPYAREA |
680 | select FB_CFB_IMAGEBLIT | 675 | select FB_CFB_IMAGEBLIT |
681 | select VIDEO_SELECT | ||
682 | help | 676 | help |
683 | This is the frame buffer device driver for generic VESA 2.0 | 677 | This is the frame buffer device driver for generic VESA 2.0 |
684 | compliant graphic cards. The older VESA 1.2 cards are not supported. | 678 | compliant graphic cards. The older VESA 1.2 cards are not supported. |
@@ -1583,7 +1577,6 @@ config FB_CYBLA | |||
1583 | tristate "Cyberblade/i1 support" | 1577 | tristate "Cyberblade/i1 support" |
1584 | depends on FB && PCI && X86_32 && !64BIT | 1578 | depends on FB && PCI && X86_32 && !64BIT |
1585 | select FB_CFB_IMAGEBLIT | 1579 | select FB_CFB_IMAGEBLIT |
1586 | select VIDEO_SELECT | ||
1587 | ---help--- | 1580 | ---help--- |
1588 | This driver is supposed to support the Trident Cyberblade/i1 | 1581 | This driver is supposed to support the Trident Cyberblade/i1 |
1589 | graphics core integrated in the VIA VT8601A North Bridge, | 1582 | graphics core integrated in the VIA VT8601A North Bridge, |
@@ -1974,19 +1967,6 @@ config FB_XILINX | |||
1974 | framebuffer. ML300 carries a 640*480 LCD display on the board, | 1967 | framebuffer. ML300 carries a 640*480 LCD display on the board, |
1975 | ML403 uses a standard DB15 VGA connector. | 1968 | ML403 uses a standard DB15 VGA connector. |
1976 | 1969 | ||
1977 | config FB_AM200EPD | ||
1978 | tristate "AM-200 E-Ink EPD devkit support" | ||
1979 | depends on FB && ARCH_PXA && MMU | ||
1980 | select FB_SYS_FILLRECT | ||
1981 | select FB_SYS_COPYAREA | ||
1982 | select FB_SYS_IMAGEBLIT | ||
1983 | select FB_SYS_FOPS | ||
1984 | select FB_DEFERRED_IO | ||
1985 | select FB_METRONOME | ||
1986 | help | ||
1987 | This enables support for the Metronome display controller used on | ||
1988 | the E-Ink AM-200 EPD devkit. | ||
1989 | |||
1990 | config FB_COBALT | 1970 | config FB_COBALT |
1991 | tristate "Cobalt server LCD frame buffer support" | 1971 | tristate "Cobalt server LCD frame buffer support" |
1992 | depends on FB && MIPS_COBALT | 1972 | depends on FB && MIPS_COBALT |
@@ -2041,6 +2021,19 @@ config XEN_FBDEV_FRONTEND | |||
2041 | frame buffer driver. It communicates with a back-end | 2021 | frame buffer driver. It communicates with a back-end |
2042 | in another domain. | 2022 | in another domain. |
2043 | 2023 | ||
2024 | config FB_METRONOME | ||
2025 | tristate "E-Ink Metronome/8track controller support" | ||
2026 | depends on FB | ||
2027 | select FB_SYS_FILLRECT | ||
2028 | select FB_SYS_COPYAREA | ||
2029 | select FB_SYS_IMAGEBLIT | ||
2030 | select FB_SYS_FOPS | ||
2031 | select FB_DEFERRED_IO | ||
2032 | help | ||
2033 | This driver implements support for the E-Ink Metronome | ||
2034 | controller. The pre-release name for this device was 8track | ||
2035 | and could also have been called by some vendors as PVI-nnnn. | ||
2036 | |||
2044 | source "drivers/video/omap/Kconfig" | 2037 | source "drivers/video/omap/Kconfig" |
2045 | 2038 | ||
2046 | source "drivers/video/backlight/Kconfig" | 2039 | source "drivers/video/backlight/Kconfig" |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index a6b55297a7fb..ad0330bf9be3 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -29,7 +29,6 @@ obj-$(CONFIG_FB_DEFERRED_IO) += fb_defio.o | |||
29 | 29 | ||
30 | # Hardware specific drivers go first | 30 | # Hardware specific drivers go first |
31 | obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o | 31 | obj-$(CONFIG_FB_AMIGA) += amifb.o c2p.o |
32 | obj-$(CONFIG_FB_AM200EPD) += am200epd.o | ||
33 | obj-$(CONFIG_FB_ARC) += arcfb.o | 32 | obj-$(CONFIG_FB_ARC) += arcfb.o |
34 | obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o | 33 | obj-$(CONFIG_FB_CLPS711X) += clps711xfb.o |
35 | obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o | 34 | obj-$(CONFIG_FB_CYBER2000) += cyber2000fb.o |
diff --git a/drivers/video/am200epd.c b/drivers/video/am200epd.c deleted file mode 100644 index 0c35b8b0160e..000000000000 --- a/drivers/video/am200epd.c +++ /dev/null | |||
@@ -1,295 +0,0 @@ | |||
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 <mach/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 | |||
56 | static 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 | |||
82 | static 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 | |||
121 | static 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 | |||
140 | static 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 | |||
149 | static 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 | |||
156 | static 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 | |||
189 | static 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 | |||
199 | static void am200_free_irq(struct fb_info *info) | ||
200 | { | ||
201 | free_irq(IRQ_GPIO(RDY_GPIO_PIN), info); | ||
202 | } | ||
203 | |||
204 | static 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 | |||
213 | static 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), IRQ_TYPE_EDGE_FALLING); | ||
225 | } | ||
226 | |||
227 | static void am200_set_rst(struct metronomefb_par *par, int state) | ||
228 | { | ||
229 | am200_set_gpio_output(RST_GPIO_PIN, state); | ||
230 | } | ||
231 | |||
232 | static void am200_set_stdby(struct metronomefb_par *par, int state) | ||
233 | { | ||
234 | am200_set_gpio_output(STDBY_GPIO_PIN, state); | ||
235 | } | ||
236 | |||
237 | static int am200_wait_event(struct metronomefb_par *par) | ||
238 | { | ||
239 | return wait_event_timeout(par->waitq, (GPLR1 & 0x01), HZ); | ||
240 | } | ||
241 | |||
242 | static int am200_wait_event_intr(struct metronomefb_par *par) | ||
243 | { | ||
244 | return wait_event_interruptible_timeout(par->waitq, (GPLR1 & 0x01), HZ); | ||
245 | } | ||
246 | |||
247 | static 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 | |||
260 | static struct platform_device *am200_device; | ||
261 | |||
262 | static 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 | |||
285 | static void __exit am200_exit(void) | ||
286 | { | ||
287 | platform_device_unregister(am200_device); | ||
288 | } | ||
289 | |||
290 | module_init(am200_init); | ||
291 | module_exit(am200_exit); | ||
292 | |||
293 | MODULE_DESCRIPTION("board driver for am200 metronome epd kit"); | ||
294 | MODULE_AUTHOR("Jaya Kumar"); | ||
295 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c index 9c5925927ece..d38fd5217422 100644 --- a/drivers/video/atmel_lcdfb.c +++ b/drivers/video/atmel_lcdfb.c | |||
@@ -208,6 +208,36 @@ static unsigned long compute_hozval(unsigned long xres, unsigned long lcdcon2) | |||
208 | return value; | 208 | return value; |
209 | } | 209 | } |
210 | 210 | ||
211 | static void atmel_lcdfb_stop_nowait(struct atmel_lcdfb_info *sinfo) | ||
212 | { | ||
213 | /* Turn off the LCD controller and the DMA controller */ | ||
214 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, | ||
215 | sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); | ||
216 | |||
217 | /* Wait for the LCDC core to become idle */ | ||
218 | while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY) | ||
219 | msleep(10); | ||
220 | |||
221 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); | ||
222 | } | ||
223 | |||
224 | static void atmel_lcdfb_stop(struct atmel_lcdfb_info *sinfo) | ||
225 | { | ||
226 | atmel_lcdfb_stop_nowait(sinfo); | ||
227 | |||
228 | /* Wait for DMA engine to become idle... */ | ||
229 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) | ||
230 | msleep(10); | ||
231 | } | ||
232 | |||
233 | static void atmel_lcdfb_start(struct atmel_lcdfb_info *sinfo) | ||
234 | { | ||
235 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon); | ||
236 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, | ||
237 | (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET) | ||
238 | | ATMEL_LCDC_PWR); | ||
239 | } | ||
240 | |||
211 | static void atmel_lcdfb_update_dma(struct fb_info *info, | 241 | static void atmel_lcdfb_update_dma(struct fb_info *info, |
212 | struct fb_var_screeninfo *var) | 242 | struct fb_var_screeninfo *var) |
213 | { | 243 | { |
@@ -378,6 +408,10 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var, | |||
378 | var->red.offset = 11; | 408 | var->red.offset = 11; |
379 | var->blue.offset = 0; | 409 | var->blue.offset = 0; |
380 | var->green.length = 6; | 410 | var->green.length = 6; |
411 | } else if (sinfo->lcd_wiring_mode == ATMEL_LCDC_WIRING_RGB555) { | ||
412 | var->red.offset = 10; | ||
413 | var->blue.offset = 0; | ||
414 | var->green.length = 5; | ||
381 | } else { | 415 | } else { |
382 | /* BGR:555 mode */ | 416 | /* BGR:555 mode */ |
383 | var->red.offset = 0; | 417 | var->red.offset = 0; |
@@ -420,26 +454,8 @@ static void atmel_lcdfb_reset(struct atmel_lcdfb_info *sinfo) | |||
420 | { | 454 | { |
421 | might_sleep(); | 455 | might_sleep(); |
422 | 456 | ||
423 | /* LCD power off */ | 457 | atmel_lcdfb_stop(sinfo); |
424 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); | 458 | atmel_lcdfb_start(sinfo); |
425 | |||
426 | /* wait for the LCDC core to become idle */ | ||
427 | while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY) | ||
428 | msleep(10); | ||
429 | |||
430 | /* DMA disable */ | ||
431 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); | ||
432 | |||
433 | /* wait for DMA engine to become idle */ | ||
434 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) | ||
435 | msleep(10); | ||
436 | |||
437 | /* LCD power on */ | ||
438 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, | ||
439 | (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET) | ATMEL_LCDC_PWR); | ||
440 | |||
441 | /* DMA enable */ | ||
442 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon); | ||
443 | } | 459 | } |
444 | 460 | ||
445 | /** | 461 | /** |
@@ -471,14 +487,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info) | |||
471 | info->var.xres, info->var.yres, | 487 | info->var.xres, info->var.yres, |
472 | info->var.xres_virtual, info->var.yres_virtual); | 488 | info->var.xres_virtual, info->var.yres_virtual); |
473 | 489 | ||
474 | /* Turn off the LCD controller and the DMA controller */ | 490 | atmel_lcdfb_stop_nowait(sinfo); |
475 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET); | ||
476 | |||
477 | /* Wait for the LCDC core to become idle */ | ||
478 | while (lcdc_readl(sinfo, ATMEL_LCDC_PWRCON) & ATMEL_LCDC_BUSY) | ||
479 | msleep(10); | ||
480 | |||
481 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); | ||
482 | 491 | ||
483 | if (info->var.bits_per_pixel == 1) | 492 | if (info->var.bits_per_pixel == 1) |
484 | info->fix.visual = FB_VISUAL_MONO01; | 493 | info->fix.visual = FB_VISUAL_MONO01; |
@@ -583,13 +592,7 @@ static int atmel_lcdfb_set_par(struct fb_info *info) | |||
583 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) | 592 | while (lcdc_readl(sinfo, ATMEL_LCDC_DMACON) & ATMEL_LCDC_DMABUSY) |
584 | msleep(10); | 593 | msleep(10); |
585 | 594 | ||
586 | dev_dbg(info->device, " * re-enable DMA engine\n"); | 595 | atmel_lcdfb_start(sinfo); |
587 | /* ...and enable it with updated configuration */ | ||
588 | lcdc_writel(sinfo, ATMEL_LCDC_DMACON, sinfo->default_dmacon); | ||
589 | |||
590 | dev_dbg(info->device, " * re-enable LCDC core\n"); | ||
591 | lcdc_writel(sinfo, ATMEL_LCDC_PWRCON, | ||
592 | (sinfo->guard_time << ATMEL_LCDC_GUARDT_OFFSET) | ATMEL_LCDC_PWR); | ||
593 | 596 | ||
594 | dev_dbg(info->device, " * DONE\n"); | 597 | dev_dbg(info->device, " * DONE\n"); |
595 | 598 | ||
@@ -939,7 +942,7 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
939 | ret = register_framebuffer(info); | 942 | ret = register_framebuffer(info); |
940 | if (ret < 0) { | 943 | if (ret < 0) { |
941 | dev_err(dev, "failed to register framebuffer device: %d\n", ret); | 944 | dev_err(dev, "failed to register framebuffer device: %d\n", ret); |
942 | goto free_cmap; | 945 | goto reset_drvdata; |
943 | } | 946 | } |
944 | 947 | ||
945 | /* add selected videomode to modelist */ | 948 | /* add selected videomode to modelist */ |
@@ -955,7 +958,8 @@ static int __init atmel_lcdfb_probe(struct platform_device *pdev) | |||
955 | 958 | ||
956 | return 0; | 959 | return 0; |
957 | 960 | ||
958 | 961 | reset_drvdata: | |
962 | dev_set_drvdata(dev, NULL); | ||
959 | free_cmap: | 963 | free_cmap: |
960 | fb_dealloc_cmap(&info->cmap); | 964 | fb_dealloc_cmap(&info->cmap); |
961 | unregister_irqs: | 965 | unregister_irqs: |
@@ -992,10 +996,11 @@ static int __exit atmel_lcdfb_remove(struct platform_device *pdev) | |||
992 | { | 996 | { |
993 | struct device *dev = &pdev->dev; | 997 | struct device *dev = &pdev->dev; |
994 | struct fb_info *info = dev_get_drvdata(dev); | 998 | struct fb_info *info = dev_get_drvdata(dev); |
995 | struct atmel_lcdfb_info *sinfo = info->par; | 999 | struct atmel_lcdfb_info *sinfo; |
996 | 1000 | ||
997 | if (!sinfo) | 1001 | if (!info || !info->par) |
998 | return 0; | 1002 | return 0; |
1003 | sinfo = info->par; | ||
999 | 1004 | ||
1000 | cancel_work_sync(&sinfo->task); | 1005 | cancel_work_sync(&sinfo->task); |
1001 | exit_backlight(sinfo); | 1006 | exit_backlight(sinfo); |
@@ -1030,11 +1035,20 @@ static int atmel_lcdfb_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1030 | struct fb_info *info = platform_get_drvdata(pdev); | 1035 | struct fb_info *info = platform_get_drvdata(pdev); |
1031 | struct atmel_lcdfb_info *sinfo = info->par; | 1036 | struct atmel_lcdfb_info *sinfo = info->par; |
1032 | 1037 | ||
1038 | /* | ||
1039 | * We don't want to handle interrupts while the clock is | ||
1040 | * stopped. It may take forever. | ||
1041 | */ | ||
1042 | lcdc_writel(sinfo, ATMEL_LCDC_IDR, ~0UL); | ||
1043 | |||
1033 | sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL); | 1044 | sinfo->saved_lcdcon = lcdc_readl(sinfo, ATMEL_LCDC_CONTRAST_VAL); |
1034 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0); | 1045 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, 0); |
1035 | if (sinfo->atmel_lcdfb_power_control) | 1046 | if (sinfo->atmel_lcdfb_power_control) |
1036 | sinfo->atmel_lcdfb_power_control(0); | 1047 | sinfo->atmel_lcdfb_power_control(0); |
1048 | |||
1049 | atmel_lcdfb_stop(sinfo); | ||
1037 | atmel_lcdfb_stop_clock(sinfo); | 1050 | atmel_lcdfb_stop_clock(sinfo); |
1051 | |||
1038 | return 0; | 1052 | return 0; |
1039 | } | 1053 | } |
1040 | 1054 | ||
@@ -1044,9 +1058,15 @@ static int atmel_lcdfb_resume(struct platform_device *pdev) | |||
1044 | struct atmel_lcdfb_info *sinfo = info->par; | 1058 | struct atmel_lcdfb_info *sinfo = info->par; |
1045 | 1059 | ||
1046 | atmel_lcdfb_start_clock(sinfo); | 1060 | atmel_lcdfb_start_clock(sinfo); |
1061 | atmel_lcdfb_start(sinfo); | ||
1047 | if (sinfo->atmel_lcdfb_power_control) | 1062 | if (sinfo->atmel_lcdfb_power_control) |
1048 | sinfo->atmel_lcdfb_power_control(1); | 1063 | sinfo->atmel_lcdfb_power_control(1); |
1049 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, sinfo->saved_lcdcon); | 1064 | lcdc_writel(sinfo, ATMEL_LCDC_CONTRAST_CTR, sinfo->saved_lcdcon); |
1065 | |||
1066 | /* Enable FIFO & DMA errors */ | ||
1067 | lcdc_writel(sinfo, ATMEL_LCDC_IER, ATMEL_LCDC_UFLWI | ||
1068 | | ATMEL_LCDC_OWRI | ATMEL_LCDC_MERI); | ||
1069 | |||
1050 | return 0; | 1070 | return 0; |
1051 | } | 1071 | } |
1052 | 1072 | ||
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index 452b770d8cc9..c72a13562954 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -24,6 +24,13 @@ config LCD_CLASS_DEVICE | |||
24 | To have support for your specific LCD panel you will have to | 24 | To have support for your specific LCD panel you will have to |
25 | select the proper drivers which depend on this option. | 25 | select the proper drivers which depend on this option. |
26 | 26 | ||
27 | config LCD_CORGI | ||
28 | tristate "LCD Panel support for SHARP corgi/spitz model" | ||
29 | depends on LCD_CLASS_DEVICE && SPI_MASTER && PXA_SHARPSL | ||
30 | help | ||
31 | Say y here to support the LCD panels usually found on SHARP | ||
32 | corgi (C7x0) and spitz (Cxx00) models. | ||
33 | |||
27 | config LCD_LTV350QV | 34 | config LCD_LTV350QV |
28 | tristate "Samsung LTV350QV LCD Panel" | 35 | tristate "Samsung LTV350QV LCD Panel" |
29 | depends on LCD_CLASS_DEVICE && SPI_MASTER | 36 | depends on LCD_CLASS_DEVICE && SPI_MASTER |
@@ -44,6 +51,14 @@ config LCD_ILI9320 | |||
44 | If you have a panel based on the ILI9320 controller chip | 51 | If you have a panel based on the ILI9320 controller chip |
45 | then say y to include a power driver for it. | 52 | then say y to include a power driver for it. |
46 | 53 | ||
54 | config LCD_TDO24M | ||
55 | tristate "Toppoly TDO24M LCD Panels support" | ||
56 | depends on LCD_CLASS_DEVICE && SPI_MASTER | ||
57 | default n | ||
58 | help | ||
59 | If you have a Toppoly TDO24M series LCD panel, say y here to | ||
60 | include the support for it. | ||
61 | |||
47 | config LCD_VGG2432A4 | 62 | config LCD_VGG2432A4 |
48 | tristate "VGG2432A4 LCM device support" | 63 | tristate "VGG2432A4 LCM device support" |
49 | depends on BACKLIGHT_LCD_SUPPORT && LCD_CLASS_DEVICE && SPI_MASTER | 64 | depends on BACKLIGHT_LCD_SUPPORT && LCD_CLASS_DEVICE && SPI_MASTER |
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index b405aace803f..3ec551eb472c 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -1,10 +1,12 @@ | |||
1 | # Backlight & LCD drivers | 1 | # Backlight & LCD drivers |
2 | 2 | ||
3 | obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o | 3 | obj-$(CONFIG_LCD_CLASS_DEVICE) += lcd.o |
4 | obj-$(CONFIG_LCD_CORGI) += corgi_lcd.o | ||
4 | obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o | 5 | obj-$(CONFIG_LCD_LTV350QV) += ltv350qv.o |
5 | obj-$(CONFIG_LCD_ILI9320) += ili9320.o | 6 | obj-$(CONFIG_LCD_ILI9320) += ili9320.o |
6 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o | 7 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o |
7 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o | 8 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o |
9 | obj-$(CONFIG_LCD_TDO24M) += tdo24m.o | ||
8 | 10 | ||
9 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o | 11 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o |
10 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o | 12 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o |
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c new file mode 100644 index 000000000000..2afd47eefe74 --- /dev/null +++ b/drivers/video/backlight/corgi_lcd.c | |||
@@ -0,0 +1,641 @@ | |||
1 | /* | ||
2 | * LCD/Backlight Driver for Sharp Zaurus Handhelds (various models) | ||
3 | * | ||
4 | * Copyright (c) 2004-2006 Richard Purdie | ||
5 | * | ||
6 | * Based on Sharp's 2.4 Backlight Driver | ||
7 | * | ||
8 | * Copyright (c) 2008 Marvell International Ltd. | ||
9 | * Converted to SPI device based LCD/Backlight device driver | ||
10 | * by Eric Miao <eric.miao@marvell.com> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License version 2 as | ||
14 | * published by the Free Software Foundation. | ||
15 | * | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/kernel.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/gpio.h> | ||
23 | #include <linux/fb.h> | ||
24 | #include <linux/lcd.h> | ||
25 | #include <linux/spi/spi.h> | ||
26 | #include <linux/spi/corgi_lcd.h> | ||
27 | #include <asm/mach/sharpsl_param.h> | ||
28 | |||
29 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
30 | |||
31 | /* Register Addresses */ | ||
32 | #define RESCTL_ADRS 0x00 | ||
33 | #define PHACTRL_ADRS 0x01 | ||
34 | #define DUTYCTRL_ADRS 0x02 | ||
35 | #define POWERREG0_ADRS 0x03 | ||
36 | #define POWERREG1_ADRS 0x04 | ||
37 | #define GPOR3_ADRS 0x05 | ||
38 | #define PICTRL_ADRS 0x06 | ||
39 | #define POLCTRL_ADRS 0x07 | ||
40 | |||
41 | /* Register Bit Definitions */ | ||
42 | #define RESCTL_QVGA 0x01 | ||
43 | #define RESCTL_VGA 0x00 | ||
44 | |||
45 | #define POWER1_VW_ON 0x01 /* VW Supply FET ON */ | ||
46 | #define POWER1_GVSS_ON 0x02 /* GVSS(-8V) Power Supply ON */ | ||
47 | #define POWER1_VDD_ON 0x04 /* VDD(8V),SVSS(-4V) Power Supply ON */ | ||
48 | |||
49 | #define POWER1_VW_OFF 0x00 /* VW Supply FET OFF */ | ||
50 | #define POWER1_GVSS_OFF 0x00 /* GVSS(-8V) Power Supply OFF */ | ||
51 | #define POWER1_VDD_OFF 0x00 /* VDD(8V),SVSS(-4V) Power Supply OFF */ | ||
52 | |||
53 | #define POWER0_COM_DCLK 0x01 /* COM Voltage DC Bias DAC Serial Data Clock */ | ||
54 | #define POWER0_COM_DOUT 0x02 /* COM Voltage DC Bias DAC Serial Data Out */ | ||
55 | #define POWER0_DAC_ON 0x04 /* DAC Power Supply ON */ | ||
56 | #define POWER0_COM_ON 0x08 /* COM Power Supply ON */ | ||
57 | #define POWER0_VCC5_ON 0x10 /* VCC5 Power Supply ON */ | ||
58 | |||
59 | #define POWER0_DAC_OFF 0x00 /* DAC Power Supply OFF */ | ||
60 | #define POWER0_COM_OFF 0x00 /* COM Power Supply OFF */ | ||
61 | #define POWER0_VCC5_OFF 0x00 /* VCC5 Power Supply OFF */ | ||
62 | |||
63 | #define PICTRL_INIT_STATE 0x01 | ||
64 | #define PICTRL_INIOFF 0x02 | ||
65 | #define PICTRL_POWER_DOWN 0x04 | ||
66 | #define PICTRL_COM_SIGNAL_OFF 0x08 | ||
67 | #define PICTRL_DAC_SIGNAL_OFF 0x10 | ||
68 | |||
69 | #define POLCTRL_SYNC_POL_FALL 0x01 | ||
70 | #define POLCTRL_EN_POL_FALL 0x02 | ||
71 | #define POLCTRL_DATA_POL_FALL 0x04 | ||
72 | #define POLCTRL_SYNC_ACT_H 0x08 | ||
73 | #define POLCTRL_EN_ACT_L 0x10 | ||
74 | |||
75 | #define POLCTRL_SYNC_POL_RISE 0x00 | ||
76 | #define POLCTRL_EN_POL_RISE 0x00 | ||
77 | #define POLCTRL_DATA_POL_RISE 0x00 | ||
78 | #define POLCTRL_SYNC_ACT_L 0x00 | ||
79 | #define POLCTRL_EN_ACT_H 0x00 | ||
80 | |||
81 | #define PHACTRL_PHASE_MANUAL 0x01 | ||
82 | #define DEFAULT_PHAD_QVGA (9) | ||
83 | #define DEFAULT_COMADJ (125) | ||
84 | |||
85 | struct corgi_lcd { | ||
86 | struct spi_device *spi_dev; | ||
87 | struct lcd_device *lcd_dev; | ||
88 | struct backlight_device *bl_dev; | ||
89 | |||
90 | int limit_mask; | ||
91 | int intensity; | ||
92 | int power; | ||
93 | int mode; | ||
94 | char buf[2]; | ||
95 | |||
96 | int gpio_backlight_on; | ||
97 | int gpio_backlight_cont; | ||
98 | int gpio_backlight_cont_inverted; | ||
99 | |||
100 | void (*kick_battery)(void); | ||
101 | }; | ||
102 | |||
103 | static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int reg, uint8_t val); | ||
104 | |||
105 | static struct corgi_lcd *the_corgi_lcd; | ||
106 | static unsigned long corgibl_flags; | ||
107 | #define CORGIBL_SUSPENDED 0x01 | ||
108 | #define CORGIBL_BATTLOW 0x02 | ||
109 | |||
110 | /* | ||
111 | * This is only a psuedo I2C interface. We can't use the standard kernel | ||
112 | * routines as the interface is write only. We just assume the data is acked... | ||
113 | */ | ||
114 | static void lcdtg_ssp_i2c_send(struct corgi_lcd *lcd, uint8_t data) | ||
115 | { | ||
116 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, data); | ||
117 | udelay(10); | ||
118 | } | ||
119 | |||
120 | static void lcdtg_i2c_send_bit(struct corgi_lcd *lcd, uint8_t data) | ||
121 | { | ||
122 | lcdtg_ssp_i2c_send(lcd, data); | ||
123 | lcdtg_ssp_i2c_send(lcd, data | POWER0_COM_DCLK); | ||
124 | lcdtg_ssp_i2c_send(lcd, data); | ||
125 | } | ||
126 | |||
127 | static void lcdtg_i2c_send_start(struct corgi_lcd *lcd, uint8_t base) | ||
128 | { | ||
129 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT); | ||
130 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK); | ||
131 | lcdtg_ssp_i2c_send(lcd, base); | ||
132 | } | ||
133 | |||
134 | static void lcdtg_i2c_send_stop(struct corgi_lcd *lcd, uint8_t base) | ||
135 | { | ||
136 | lcdtg_ssp_i2c_send(lcd, base); | ||
137 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK); | ||
138 | lcdtg_ssp_i2c_send(lcd, base | POWER0_COM_DCLK | POWER0_COM_DOUT); | ||
139 | } | ||
140 | |||
141 | static void lcdtg_i2c_send_byte(struct corgi_lcd *lcd, | ||
142 | uint8_t base, uint8_t data) | ||
143 | { | ||
144 | int i; | ||
145 | for (i = 0; i < 8; i++) { | ||
146 | if (data & 0x80) | ||
147 | lcdtg_i2c_send_bit(lcd, base | POWER0_COM_DOUT); | ||
148 | else | ||
149 | lcdtg_i2c_send_bit(lcd, base); | ||
150 | data <<= 1; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | static void lcdtg_i2c_wait_ack(struct corgi_lcd *lcd, uint8_t base) | ||
155 | { | ||
156 | lcdtg_i2c_send_bit(lcd, base); | ||
157 | } | ||
158 | |||
159 | static void lcdtg_set_common_voltage(struct corgi_lcd *lcd, | ||
160 | uint8_t base_data, uint8_t data) | ||
161 | { | ||
162 | /* Set Common Voltage to M62332FP via I2C */ | ||
163 | lcdtg_i2c_send_start(lcd, base_data); | ||
164 | lcdtg_i2c_send_byte(lcd, base_data, 0x9c); | ||
165 | lcdtg_i2c_wait_ack(lcd, base_data); | ||
166 | lcdtg_i2c_send_byte(lcd, base_data, 0x00); | ||
167 | lcdtg_i2c_wait_ack(lcd, base_data); | ||
168 | lcdtg_i2c_send_byte(lcd, base_data, data); | ||
169 | lcdtg_i2c_wait_ack(lcd, base_data); | ||
170 | lcdtg_i2c_send_stop(lcd, base_data); | ||
171 | } | ||
172 | |||
173 | static int corgi_ssp_lcdtg_send(struct corgi_lcd *lcd, int adrs, uint8_t data) | ||
174 | { | ||
175 | struct spi_message msg; | ||
176 | struct spi_transfer xfer = { | ||
177 | .len = 1, | ||
178 | .cs_change = 1, | ||
179 | .tx_buf = lcd->buf, | ||
180 | }; | ||
181 | |||
182 | lcd->buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f); | ||
183 | spi_message_init(&msg); | ||
184 | spi_message_add_tail(&xfer, &msg); | ||
185 | |||
186 | return spi_sync(lcd->spi_dev, &msg); | ||
187 | } | ||
188 | |||
189 | /* Set Phase Adjust */ | ||
190 | static void lcdtg_set_phadadj(struct corgi_lcd *lcd, int mode) | ||
191 | { | ||
192 | int adj; | ||
193 | |||
194 | switch(mode) { | ||
195 | case CORGI_LCD_MODE_VGA: | ||
196 | /* Setting for VGA */ | ||
197 | adj = sharpsl_param.phadadj; | ||
198 | adj = (adj < 0) ? PHACTRL_PHASE_MANUAL : | ||
199 | PHACTRL_PHASE_MANUAL | ((adj & 0xf) << 1); | ||
200 | break; | ||
201 | case CORGI_LCD_MODE_QVGA: | ||
202 | default: | ||
203 | /* Setting for QVGA */ | ||
204 | adj = (DEFAULT_PHAD_QVGA << 1) | PHACTRL_PHASE_MANUAL; | ||
205 | break; | ||
206 | } | ||
207 | |||
208 | corgi_ssp_lcdtg_send(lcd, PHACTRL_ADRS, adj); | ||
209 | } | ||
210 | |||
211 | static void corgi_lcd_power_on(struct corgi_lcd *lcd) | ||
212 | { | ||
213 | int comadj; | ||
214 | |||
215 | /* Initialize Internal Logic & Port */ | ||
216 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, | ||
217 | PICTRL_POWER_DOWN | PICTRL_INIOFF | | ||
218 | PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF | | ||
219 | PICTRL_DAC_SIGNAL_OFF); | ||
220 | |||
221 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
222 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_OFF | | ||
223 | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
224 | |||
225 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
226 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF); | ||
227 | |||
228 | /* VDD(+8V), SVSS(-4V) ON */ | ||
229 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
230 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON); | ||
231 | mdelay(3); | ||
232 | |||
233 | /* DAC ON */ | ||
234 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
235 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON | | ||
236 | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
237 | |||
238 | /* INIB = H, INI = L */ | ||
239 | /* PICTL[0] = H , PICTL[1] = PICTL[2] = PICTL[4] = L */ | ||
240 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, | ||
241 | PICTRL_INIT_STATE | PICTRL_COM_SIGNAL_OFF); | ||
242 | |||
243 | /* Set Common Voltage */ | ||
244 | comadj = sharpsl_param.comadj; | ||
245 | if (comadj < 0) | ||
246 | comadj = DEFAULT_COMADJ; | ||
247 | |||
248 | lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF | | ||
249 | POWER0_VCC5_OFF, comadj); | ||
250 | |||
251 | /* VCC5 ON, DAC ON */ | ||
252 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
253 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON | | ||
254 | POWER0_COM_OFF | POWER0_VCC5_ON); | ||
255 | |||
256 | /* GVSS(-8V) ON, VDD ON */ | ||
257 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
258 | POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON); | ||
259 | mdelay(2); | ||
260 | |||
261 | /* COM SIGNAL ON (PICTL[3] = L) */ | ||
262 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_INIT_STATE); | ||
263 | |||
264 | /* COM ON, DAC ON, VCC5_ON */ | ||
265 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
266 | POWER0_COM_DCLK | POWER0_COM_DOUT | POWER0_DAC_ON | | ||
267 | POWER0_COM_ON | POWER0_VCC5_ON); | ||
268 | |||
269 | /* VW ON, GVSS ON, VDD ON */ | ||
270 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
271 | POWER1_VW_ON | POWER1_GVSS_ON | POWER1_VDD_ON); | ||
272 | |||
273 | /* Signals output enable */ | ||
274 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, 0); | ||
275 | |||
276 | /* Set Phase Adjust */ | ||
277 | lcdtg_set_phadadj(lcd, lcd->mode); | ||
278 | |||
279 | /* Initialize for Input Signals from ATI */ | ||
280 | corgi_ssp_lcdtg_send(lcd, POLCTRL_ADRS, | ||
281 | POLCTRL_SYNC_POL_RISE | POLCTRL_EN_POL_RISE | | ||
282 | POLCTRL_DATA_POL_RISE | POLCTRL_SYNC_ACT_L | | ||
283 | POLCTRL_EN_ACT_H); | ||
284 | udelay(1000); | ||
285 | |||
286 | switch (lcd->mode) { | ||
287 | case CORGI_LCD_MODE_VGA: | ||
288 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA); | ||
289 | break; | ||
290 | case CORGI_LCD_MODE_QVGA: | ||
291 | default: | ||
292 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA); | ||
293 | break; | ||
294 | } | ||
295 | } | ||
296 | |||
297 | static void corgi_lcd_power_off(struct corgi_lcd *lcd) | ||
298 | { | ||
299 | /* 60Hz x 2 frame = 16.7msec x 2 = 33.4 msec */ | ||
300 | msleep(34); | ||
301 | |||
302 | /* (1)VW OFF */ | ||
303 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
304 | POWER1_VW_OFF | POWER1_GVSS_ON | POWER1_VDD_ON); | ||
305 | |||
306 | /* (2)COM OFF */ | ||
307 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, PICTRL_COM_SIGNAL_OFF); | ||
308 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
309 | POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_ON); | ||
310 | |||
311 | /* (3)Set Common Voltage Bias 0V */ | ||
312 | lcdtg_set_common_voltage(lcd, POWER0_DAC_ON | POWER0_COM_OFF | | ||
313 | POWER0_VCC5_ON, 0); | ||
314 | |||
315 | /* (4)GVSS OFF */ | ||
316 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
317 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_ON); | ||
318 | |||
319 | /* (5)VCC5 OFF */ | ||
320 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
321 | POWER0_DAC_ON | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
322 | |||
323 | /* (6)Set PDWN, INIOFF, DACOFF */ | ||
324 | corgi_ssp_lcdtg_send(lcd, PICTRL_ADRS, | ||
325 | PICTRL_INIOFF | PICTRL_DAC_SIGNAL_OFF | | ||
326 | PICTRL_POWER_DOWN | PICTRL_COM_SIGNAL_OFF); | ||
327 | |||
328 | /* (7)DAC OFF */ | ||
329 | corgi_ssp_lcdtg_send(lcd, POWERREG0_ADRS, | ||
330 | POWER0_DAC_OFF | POWER0_COM_OFF | POWER0_VCC5_OFF); | ||
331 | |||
332 | /* (8)VDD OFF */ | ||
333 | corgi_ssp_lcdtg_send(lcd, POWERREG1_ADRS, | ||
334 | POWER1_VW_OFF | POWER1_GVSS_OFF | POWER1_VDD_OFF); | ||
335 | } | ||
336 | |||
337 | static int corgi_lcd_set_mode(struct lcd_device *ld, struct fb_videomode *m) | ||
338 | { | ||
339 | struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev); | ||
340 | int mode = CORGI_LCD_MODE_QVGA; | ||
341 | |||
342 | if (m->xres == 640 || m->xres == 480) | ||
343 | mode = CORGI_LCD_MODE_VGA; | ||
344 | |||
345 | if (lcd->mode == mode) | ||
346 | return 0; | ||
347 | |||
348 | lcdtg_set_phadadj(lcd, mode); | ||
349 | |||
350 | switch (mode) { | ||
351 | case CORGI_LCD_MODE_VGA: | ||
352 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_VGA); | ||
353 | break; | ||
354 | case CORGI_LCD_MODE_QVGA: | ||
355 | default: | ||
356 | corgi_ssp_lcdtg_send(lcd, RESCTL_ADRS, RESCTL_QVGA); | ||
357 | break; | ||
358 | } | ||
359 | |||
360 | lcd->mode = mode; | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | static int corgi_lcd_set_power(struct lcd_device *ld, int power) | ||
365 | { | ||
366 | struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev); | ||
367 | |||
368 | if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) | ||
369 | corgi_lcd_power_on(lcd); | ||
370 | |||
371 | if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) | ||
372 | corgi_lcd_power_off(lcd); | ||
373 | |||
374 | lcd->power = power; | ||
375 | return 0; | ||
376 | } | ||
377 | |||
378 | static int corgi_lcd_get_power(struct lcd_device *ld) | ||
379 | { | ||
380 | struct corgi_lcd *lcd = dev_get_drvdata(&ld->dev); | ||
381 | |||
382 | return lcd->power; | ||
383 | } | ||
384 | |||
385 | static struct lcd_ops corgi_lcd_ops = { | ||
386 | .get_power = corgi_lcd_get_power, | ||
387 | .set_power = corgi_lcd_set_power, | ||
388 | .set_mode = corgi_lcd_set_mode, | ||
389 | }; | ||
390 | |||
391 | static int corgi_bl_get_intensity(struct backlight_device *bd) | ||
392 | { | ||
393 | struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev); | ||
394 | |||
395 | return lcd->intensity; | ||
396 | } | ||
397 | |||
398 | static int corgi_bl_set_intensity(struct corgi_lcd *lcd, int intensity) | ||
399 | { | ||
400 | int cont; | ||
401 | |||
402 | if (intensity > 0x10) | ||
403 | intensity += 0x10; | ||
404 | |||
405 | corgi_ssp_lcdtg_send(lcd, DUTYCTRL_ADRS, intensity); | ||
406 | |||
407 | /* Bit 5 via GPIO_BACKLIGHT_CONT */ | ||
408 | cont = !!(intensity & 0x20) ^ lcd->gpio_backlight_cont_inverted; | ||
409 | |||
410 | if (gpio_is_valid(lcd->gpio_backlight_cont)) | ||
411 | gpio_set_value(lcd->gpio_backlight_cont, cont); | ||
412 | |||
413 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
414 | gpio_set_value(lcd->gpio_backlight_on, intensity); | ||
415 | |||
416 | if (lcd->kick_battery) | ||
417 | lcd->kick_battery(); | ||
418 | |||
419 | lcd->intensity = intensity; | ||
420 | return 0; | ||
421 | } | ||
422 | |||
423 | static int corgi_bl_update_status(struct backlight_device *bd) | ||
424 | { | ||
425 | struct corgi_lcd *lcd = dev_get_drvdata(&bd->dev); | ||
426 | int intensity = bd->props.brightness; | ||
427 | |||
428 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
429 | intensity = 0; | ||
430 | |||
431 | if (bd->props.fb_blank != FB_BLANK_UNBLANK) | ||
432 | intensity = 0; | ||
433 | |||
434 | if (corgibl_flags & CORGIBL_SUSPENDED) | ||
435 | intensity = 0; | ||
436 | if (corgibl_flags & CORGIBL_BATTLOW) | ||
437 | intensity &= lcd->limit_mask; | ||
438 | |||
439 | return corgi_bl_set_intensity(lcd, intensity); | ||
440 | } | ||
441 | |||
442 | void corgibl_limit_intensity(int limit) | ||
443 | { | ||
444 | if (limit) | ||
445 | corgibl_flags |= CORGIBL_BATTLOW; | ||
446 | else | ||
447 | corgibl_flags &= ~CORGIBL_BATTLOW; | ||
448 | |||
449 | backlight_update_status(the_corgi_lcd->bl_dev); | ||
450 | } | ||
451 | EXPORT_SYMBOL(corgibl_limit_intensity); | ||
452 | |||
453 | static struct backlight_ops corgi_bl_ops = { | ||
454 | .get_brightness = corgi_bl_get_intensity, | ||
455 | .update_status = corgi_bl_update_status, | ||
456 | }; | ||
457 | |||
458 | #ifdef CONFIG_PM | ||
459 | static int corgi_lcd_suspend(struct spi_device *spi, pm_message_t state) | ||
460 | { | ||
461 | struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev); | ||
462 | |||
463 | corgibl_flags |= CORGIBL_SUSPENDED; | ||
464 | corgi_bl_set_intensity(lcd, 0); | ||
465 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); | ||
466 | return 0; | ||
467 | } | ||
468 | |||
469 | static int corgi_lcd_resume(struct spi_device *spi) | ||
470 | { | ||
471 | struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev); | ||
472 | |||
473 | corgibl_flags &= ~CORGIBL_SUSPENDED; | ||
474 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); | ||
475 | backlight_update_status(lcd->bl_dev); | ||
476 | return 0; | ||
477 | } | ||
478 | #else | ||
479 | #define corgi_lcd_suspend NULL | ||
480 | #define corgi_lcd_resume NULL | ||
481 | #endif | ||
482 | |||
483 | static int setup_gpio_backlight(struct corgi_lcd *lcd, | ||
484 | struct corgi_lcd_platform_data *pdata) | ||
485 | { | ||
486 | struct spi_device *spi = lcd->spi_dev; | ||
487 | int err; | ||
488 | |||
489 | lcd->gpio_backlight_on = -1; | ||
490 | lcd->gpio_backlight_cont = -1; | ||
491 | |||
492 | if (gpio_is_valid(pdata->gpio_backlight_on)) { | ||
493 | err = gpio_request(pdata->gpio_backlight_on, "BL_ON"); | ||
494 | if (err) { | ||
495 | dev_err(&spi->dev, "failed to request GPIO%d for " | ||
496 | "backlight_on\n", pdata->gpio_backlight_on); | ||
497 | return err; | ||
498 | } | ||
499 | |||
500 | lcd->gpio_backlight_on = pdata->gpio_backlight_on; | ||
501 | gpio_direction_output(lcd->gpio_backlight_on, 0); | ||
502 | } | ||
503 | |||
504 | if (gpio_is_valid(pdata->gpio_backlight_cont)) { | ||
505 | err = gpio_request(pdata->gpio_backlight_cont, "BL_CONT"); | ||
506 | if (err) { | ||
507 | dev_err(&spi->dev, "failed to request GPIO%d for " | ||
508 | "backlight_cont\n", pdata->gpio_backlight_cont); | ||
509 | goto err_free_backlight_on; | ||
510 | } | ||
511 | |||
512 | lcd->gpio_backlight_cont = pdata->gpio_backlight_cont; | ||
513 | |||
514 | /* spitz and akita use both GPIOs for backlight, and | ||
515 | * have inverted polarity of GPIO_BACKLIGHT_CONT | ||
516 | */ | ||
517 | if (gpio_is_valid(lcd->gpio_backlight_on)) { | ||
518 | lcd->gpio_backlight_cont_inverted = 1; | ||
519 | gpio_direction_output(lcd->gpio_backlight_cont, 1); | ||
520 | } else { | ||
521 | lcd->gpio_backlight_cont_inverted = 0; | ||
522 | gpio_direction_output(lcd->gpio_backlight_cont, 0); | ||
523 | } | ||
524 | } | ||
525 | return 0; | ||
526 | |||
527 | err_free_backlight_on: | ||
528 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
529 | gpio_free(lcd->gpio_backlight_on); | ||
530 | return err; | ||
531 | } | ||
532 | |||
533 | static int __devinit corgi_lcd_probe(struct spi_device *spi) | ||
534 | { | ||
535 | struct corgi_lcd_platform_data *pdata = spi->dev.platform_data; | ||
536 | struct corgi_lcd *lcd; | ||
537 | int ret = 0; | ||
538 | |||
539 | if (pdata == NULL) { | ||
540 | dev_err(&spi->dev, "platform data not available\n"); | ||
541 | return -EINVAL; | ||
542 | } | ||
543 | |||
544 | lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL); | ||
545 | if (!lcd) { | ||
546 | dev_err(&spi->dev, "failed to allocate memory\n"); | ||
547 | return -ENOMEM; | ||
548 | } | ||
549 | |||
550 | lcd->spi_dev = spi; | ||
551 | |||
552 | lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, | ||
553 | lcd, &corgi_lcd_ops); | ||
554 | if (IS_ERR(lcd->lcd_dev)) { | ||
555 | ret = PTR_ERR(lcd->lcd_dev); | ||
556 | goto err_free_lcd; | ||
557 | } | ||
558 | lcd->power = FB_BLANK_POWERDOWN; | ||
559 | lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; | ||
560 | |||
561 | lcd->bl_dev = backlight_device_register("corgi_bl", &spi->dev, | ||
562 | lcd, &corgi_bl_ops); | ||
563 | if (IS_ERR(lcd->bl_dev)) { | ||
564 | ret = PTR_ERR(lcd->bl_dev); | ||
565 | goto err_unregister_lcd; | ||
566 | } | ||
567 | lcd->bl_dev->props.max_brightness = pdata->max_intensity; | ||
568 | lcd->bl_dev->props.brightness = pdata->default_intensity; | ||
569 | lcd->bl_dev->props.power = FB_BLANK_UNBLANK; | ||
570 | |||
571 | ret = setup_gpio_backlight(lcd, pdata); | ||
572 | if (ret) | ||
573 | goto err_unregister_bl; | ||
574 | |||
575 | lcd->kick_battery = pdata->kick_battery; | ||
576 | |||
577 | dev_set_drvdata(&spi->dev, lcd); | ||
578 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_UNBLANK); | ||
579 | backlight_update_status(lcd->bl_dev); | ||
580 | |||
581 | lcd->limit_mask = pdata->limit_mask; | ||
582 | the_corgi_lcd = lcd; | ||
583 | return 0; | ||
584 | |||
585 | err_unregister_bl: | ||
586 | backlight_device_unregister(lcd->bl_dev); | ||
587 | err_unregister_lcd: | ||
588 | lcd_device_unregister(lcd->lcd_dev); | ||
589 | err_free_lcd: | ||
590 | kfree(lcd); | ||
591 | return ret; | ||
592 | } | ||
593 | |||
594 | static int __devexit corgi_lcd_remove(struct spi_device *spi) | ||
595 | { | ||
596 | struct corgi_lcd *lcd = dev_get_drvdata(&spi->dev); | ||
597 | |||
598 | lcd->bl_dev->props.power = FB_BLANK_UNBLANK; | ||
599 | lcd->bl_dev->props.brightness = 0; | ||
600 | backlight_update_status(lcd->bl_dev); | ||
601 | backlight_device_unregister(lcd->bl_dev); | ||
602 | |||
603 | if (gpio_is_valid(lcd->gpio_backlight_on)) | ||
604 | gpio_free(lcd->gpio_backlight_on); | ||
605 | |||
606 | if (gpio_is_valid(lcd->gpio_backlight_cont)) | ||
607 | gpio_free(lcd->gpio_backlight_cont); | ||
608 | |||
609 | corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); | ||
610 | lcd_device_unregister(lcd->lcd_dev); | ||
611 | kfree(lcd); | ||
612 | |||
613 | return 0; | ||
614 | } | ||
615 | |||
616 | static struct spi_driver corgi_lcd_driver = { | ||
617 | .driver = { | ||
618 | .name = "corgi-lcd", | ||
619 | .owner = THIS_MODULE, | ||
620 | }, | ||
621 | .probe = corgi_lcd_probe, | ||
622 | .remove = __devexit_p(corgi_lcd_remove), | ||
623 | .suspend = corgi_lcd_suspend, | ||
624 | .resume = corgi_lcd_resume, | ||
625 | }; | ||
626 | |||
627 | static int __init corgi_lcd_init(void) | ||
628 | { | ||
629 | return spi_register_driver(&corgi_lcd_driver); | ||
630 | } | ||
631 | module_init(corgi_lcd_init); | ||
632 | |||
633 | static void __exit corgi_lcd_exit(void) | ||
634 | { | ||
635 | spi_unregister_driver(&corgi_lcd_driver); | ||
636 | } | ||
637 | module_exit(corgi_lcd_exit); | ||
638 | |||
639 | MODULE_DESCRIPTION("LCD and backlight driver for SHARP C7x0/Cxx00"); | ||
640 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); | ||
641 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c index b15b2b84a6f7..8e1731d3b228 100644 --- a/drivers/video/backlight/lcd.c +++ b/drivers/video/backlight/lcd.c | |||
@@ -27,14 +27,26 @@ static int fb_notifier_callback(struct notifier_block *self, | |||
27 | struct fb_event *evdata = data; | 27 | struct fb_event *evdata = data; |
28 | 28 | ||
29 | /* If we aren't interested in this event, skip it immediately ... */ | 29 | /* If we aren't interested in this event, skip it immediately ... */ |
30 | if (event != FB_EVENT_BLANK) | 30 | switch (event) { |
31 | case FB_EVENT_BLANK: | ||
32 | case FB_EVENT_MODE_CHANGE: | ||
33 | case FB_EVENT_MODE_CHANGE_ALL: | ||
34 | break; | ||
35 | default: | ||
31 | return 0; | 36 | return 0; |
37 | } | ||
32 | 38 | ||
33 | ld = container_of(self, struct lcd_device, fb_notif); | 39 | ld = container_of(self, struct lcd_device, fb_notif); |
40 | if (!ld->ops) | ||
41 | return 0; | ||
42 | |||
34 | mutex_lock(&ld->ops_lock); | 43 | mutex_lock(&ld->ops_lock); |
35 | if (ld->ops) | 44 | if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) { |
36 | if (!ld->ops->check_fb || ld->ops->check_fb(ld, evdata->info)) | 45 | if (event == FB_EVENT_BLANK) |
37 | ld->ops->set_power(ld, *(int *)evdata->data); | 46 | ld->ops->set_power(ld, *(int *)evdata->data); |
47 | else | ||
48 | ld->ops->set_mode(ld, evdata->data); | ||
49 | } | ||
38 | mutex_unlock(&ld->ops_lock); | 50 | mutex_unlock(&ld->ops_lock); |
39 | return 0; | 51 | return 0; |
40 | } | 52 | } |
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c new file mode 100644 index 000000000000..8427669162ea --- /dev/null +++ b/drivers/video/backlight/tdo24m.c | |||
@@ -0,0 +1,396 @@ | |||
1 | /* | ||
2 | * tdo24m - SPI-based drivers for Toppoly TDO24M series LCD panels | ||
3 | * | ||
4 | * Copyright (C) 2008 Marvell International Ltd. | ||
5 | * Eric Miao <eric.miao@marvell.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * publishhed by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/spi/spi.h> | ||
17 | #include <linux/fb.h> | ||
18 | #include <linux/lcd.h> | ||
19 | |||
20 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
21 | |||
22 | #define TDO24M_SPI_BUFF_SIZE (4) | ||
23 | #define MODE_QVGA 0 | ||
24 | #define MODE_VGA 1 | ||
25 | |||
26 | struct tdo24m { | ||
27 | struct spi_device *spi_dev; | ||
28 | struct lcd_device *lcd_dev; | ||
29 | |||
30 | struct spi_message msg; | ||
31 | struct spi_transfer xfer; | ||
32 | uint8_t *buf; | ||
33 | |||
34 | int power; | ||
35 | int mode; | ||
36 | }; | ||
37 | |||
38 | /* use bit 30, 31 as the indicator of command parameter number */ | ||
39 | #define CMD0(x) ((0 << 30) | (x)) | ||
40 | #define CMD1(x, x1) ((1 << 30) | ((x) << 9) | 0x100 | (x1)) | ||
41 | #define CMD2(x, x1, x2) ((2 << 30) | ((x) << 18) | 0x20000 |\ | ||
42 | ((x1) << 9) | 0x100 | (x2)) | ||
43 | #define CMD_NULL (-1) | ||
44 | |||
45 | static uint32_t lcd_panel_reset[] = { | ||
46 | CMD0(0x1), /* reset */ | ||
47 | CMD0(0x0), /* nop */ | ||
48 | CMD0(0x0), /* nop */ | ||
49 | CMD0(0x0), /* nop */ | ||
50 | CMD_NULL, | ||
51 | }; | ||
52 | |||
53 | static uint32_t lcd_panel_on[] = { | ||
54 | CMD0(0x29), /* Display ON */ | ||
55 | CMD2(0xB8, 0xFF, 0xF9), /* Output Control */ | ||
56 | CMD0(0x11), /* Sleep out */ | ||
57 | CMD1(0xB0, 0x16), /* Wake */ | ||
58 | CMD_NULL, | ||
59 | }; | ||
60 | |||
61 | static uint32_t lcd_panel_off[] = { | ||
62 | CMD0(0x28), /* Display OFF */ | ||
63 | CMD2(0xB8, 0x80, 0x02), /* Output Control */ | ||
64 | CMD0(0x10), /* Sleep in */ | ||
65 | CMD1(0xB0, 0x00), /* Deep stand by in */ | ||
66 | CMD_NULL, | ||
67 | }; | ||
68 | |||
69 | static uint32_t lcd_vga_pass_through[] = { | ||
70 | CMD1(0xB0, 0x16), | ||
71 | CMD1(0xBC, 0x80), | ||
72 | CMD1(0xE1, 0x00), | ||
73 | CMD1(0x36, 0x50), | ||
74 | CMD1(0x3B, 0x00), | ||
75 | CMD_NULL, | ||
76 | }; | ||
77 | |||
78 | static uint32_t lcd_qvga_pass_through[] = { | ||
79 | CMD1(0xB0, 0x16), | ||
80 | CMD1(0xBC, 0x81), | ||
81 | CMD1(0xE1, 0x00), | ||
82 | CMD1(0x36, 0x50), | ||
83 | CMD1(0x3B, 0x22), | ||
84 | CMD_NULL, | ||
85 | }; | ||
86 | |||
87 | static uint32_t lcd_vga_transfer[] = { | ||
88 | CMD1(0xcf, 0x02), /* Blanking period control (1) */ | ||
89 | CMD2(0xd0, 0x08, 0x04), /* Blanking period control (2) */ | ||
90 | CMD1(0xd1, 0x01), /* CKV timing control on/off */ | ||
91 | CMD2(0xd2, 0x14, 0x00), /* CKV 1,2 timing control */ | ||
92 | CMD2(0xd3, 0x1a, 0x0f), /* OEV timing control */ | ||
93 | CMD2(0xd4, 0x1f, 0xaf), /* ASW timing control (1) */ | ||
94 | CMD1(0xd5, 0x14), /* ASW timing control (2) */ | ||
95 | CMD0(0x21), /* Invert for normally black display */ | ||
96 | CMD0(0x29), /* Display on */ | ||
97 | CMD_NULL, | ||
98 | }; | ||
99 | |||
100 | static uint32_t lcd_qvga_transfer[] = { | ||
101 | CMD1(0xd6, 0x02), /* Blanking period control (1) */ | ||
102 | CMD2(0xd7, 0x08, 0x04), /* Blanking period control (2) */ | ||
103 | CMD1(0xd8, 0x01), /* CKV timing control on/off */ | ||
104 | CMD2(0xd9, 0x00, 0x08), /* CKV 1,2 timing control */ | ||
105 | CMD2(0xde, 0x05, 0x0a), /* OEV timing control */ | ||
106 | CMD2(0xdf, 0x0a, 0x19), /* ASW timing control (1) */ | ||
107 | CMD1(0xe0, 0x0a), /* ASW timing control (2) */ | ||
108 | CMD0(0x21), /* Invert for normally black display */ | ||
109 | CMD0(0x29), /* Display on */ | ||
110 | CMD_NULL, | ||
111 | }; | ||
112 | |||
113 | static uint32_t lcd_panel_config[] = { | ||
114 | CMD2(0xb8, 0xff, 0xf9), /* Output control */ | ||
115 | CMD0(0x11), /* sleep out */ | ||
116 | CMD1(0xba, 0x01), /* Display mode (1) */ | ||
117 | CMD1(0xbb, 0x00), /* Display mode (2) */ | ||
118 | CMD1(0x3a, 0x60), /* Display mode 18-bit RGB */ | ||
119 | CMD1(0xbf, 0x10), /* Drive system change control */ | ||
120 | CMD1(0xb1, 0x56), /* Booster operation setup */ | ||
121 | CMD1(0xb2, 0x33), /* Booster mode setup */ | ||
122 | CMD1(0xb3, 0x11), /* Booster frequency setup */ | ||
123 | CMD1(0xb4, 0x02), /* Op amp/system clock */ | ||
124 | CMD1(0xb5, 0x35), /* VCS voltage */ | ||
125 | CMD1(0xb6, 0x40), /* VCOM voltage */ | ||
126 | CMD1(0xb7, 0x03), /* External display signal */ | ||
127 | CMD1(0xbd, 0x00), /* ASW slew rate */ | ||
128 | CMD1(0xbe, 0x00), /* Dummy data for QuadData operation */ | ||
129 | CMD1(0xc0, 0x11), /* Sleep out FR count (A) */ | ||
130 | CMD1(0xc1, 0x11), /* Sleep out FR count (B) */ | ||
131 | CMD1(0xc2, 0x11), /* Sleep out FR count (C) */ | ||
132 | CMD2(0xc3, 0x20, 0x40), /* Sleep out FR count (D) */ | ||
133 | CMD2(0xc4, 0x60, 0xc0), /* Sleep out FR count (E) */ | ||
134 | CMD2(0xc5, 0x10, 0x20), /* Sleep out FR count (F) */ | ||
135 | CMD1(0xc6, 0xc0), /* Sleep out FR count (G) */ | ||
136 | CMD2(0xc7, 0x33, 0x43), /* Gamma 1 fine tuning (1) */ | ||
137 | CMD1(0xc8, 0x44), /* Gamma 1 fine tuning (2) */ | ||
138 | CMD1(0xc9, 0x33), /* Gamma 1 inclination adjustment */ | ||
139 | CMD1(0xca, 0x00), /* Gamma 1 blue offset adjustment */ | ||
140 | CMD2(0xec, 0x01, 0xf0), /* Horizontal clock cycles */ | ||
141 | CMD_NULL, | ||
142 | }; | ||
143 | |||
144 | static int tdo24m_writes(struct tdo24m *lcd, uint32_t *array) | ||
145 | { | ||
146 | struct spi_transfer *x = &lcd->xfer; | ||
147 | uint32_t data, *p = array; | ||
148 | int nparams, err = 0; | ||
149 | |||
150 | for (; *p != CMD_NULL; p++) { | ||
151 | |||
152 | nparams = (*p >> 30) & 0x3; | ||
153 | |||
154 | data = *p << (7 - nparams); | ||
155 | switch (nparams) { | ||
156 | case 0: | ||
157 | lcd->buf[0] = (data >> 8) & 0xff; | ||
158 | lcd->buf[1] = data & 0xff; | ||
159 | break; | ||
160 | case 1: | ||
161 | lcd->buf[0] = (data >> 16) & 0xff; | ||
162 | lcd->buf[1] = (data >> 8) & 0xff; | ||
163 | lcd->buf[2] = data & 0xff; | ||
164 | break; | ||
165 | case 2: | ||
166 | lcd->buf[0] = (data >> 24) & 0xff; | ||
167 | lcd->buf[1] = (data >> 16) & 0xff; | ||
168 | lcd->buf[2] = (data >> 8) & 0xff; | ||
169 | lcd->buf[3] = data & 0xff; | ||
170 | break; | ||
171 | default: | ||
172 | continue; | ||
173 | } | ||
174 | x->len = nparams + 2; | ||
175 | err = spi_sync(lcd->spi_dev, &lcd->msg); | ||
176 | if (err) | ||
177 | break; | ||
178 | } | ||
179 | |||
180 | return err; | ||
181 | } | ||
182 | |||
183 | static int tdo24m_adj_mode(struct tdo24m *lcd, int mode) | ||
184 | { | ||
185 | switch (mode) { | ||
186 | case MODE_VGA: | ||
187 | tdo24m_writes(lcd, lcd_vga_pass_through); | ||
188 | tdo24m_writes(lcd, lcd_panel_config); | ||
189 | tdo24m_writes(lcd, lcd_vga_transfer); | ||
190 | break; | ||
191 | case MODE_QVGA: | ||
192 | tdo24m_writes(lcd, lcd_qvga_pass_through); | ||
193 | tdo24m_writes(lcd, lcd_panel_config); | ||
194 | tdo24m_writes(lcd, lcd_qvga_transfer); | ||
195 | break; | ||
196 | default: | ||
197 | return -EINVAL; | ||
198 | } | ||
199 | |||
200 | lcd->mode = mode; | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | static int tdo24m_power_on(struct tdo24m *lcd) | ||
205 | { | ||
206 | int err; | ||
207 | |||
208 | err = tdo24m_writes(lcd, lcd_panel_on); | ||
209 | if (err) | ||
210 | goto out; | ||
211 | |||
212 | err = tdo24m_writes(lcd, lcd_panel_reset); | ||
213 | if (err) | ||
214 | goto out; | ||
215 | |||
216 | err = tdo24m_adj_mode(lcd, lcd->mode); | ||
217 | out: | ||
218 | return err; | ||
219 | } | ||
220 | |||
221 | static int tdo24m_power_off(struct tdo24m *lcd) | ||
222 | { | ||
223 | return tdo24m_writes(lcd, lcd_panel_off); | ||
224 | } | ||
225 | |||
226 | static int tdo24m_power(struct tdo24m *lcd, int power) | ||
227 | { | ||
228 | int ret = 0; | ||
229 | |||
230 | if (POWER_IS_ON(power) && !POWER_IS_ON(lcd->power)) | ||
231 | ret = tdo24m_power_on(lcd); | ||
232 | else if (!POWER_IS_ON(power) && POWER_IS_ON(lcd->power)) | ||
233 | ret = tdo24m_power_off(lcd); | ||
234 | |||
235 | if (!ret) | ||
236 | lcd->power = power; | ||
237 | |||
238 | return ret; | ||
239 | } | ||
240 | |||
241 | |||
242 | static int tdo24m_set_power(struct lcd_device *ld, int power) | ||
243 | { | ||
244 | struct tdo24m *lcd = lcd_get_data(ld); | ||
245 | return tdo24m_power(lcd, power); | ||
246 | } | ||
247 | |||
248 | static int tdo24m_get_power(struct lcd_device *ld) | ||
249 | { | ||
250 | struct tdo24m *lcd = lcd_get_data(ld); | ||
251 | return lcd->power; | ||
252 | } | ||
253 | |||
254 | static int tdo24m_set_mode(struct lcd_device *ld, struct fb_videomode *m) | ||
255 | { | ||
256 | struct tdo24m *lcd = lcd_get_data(ld); | ||
257 | int mode = MODE_QVGA; | ||
258 | |||
259 | if (m->xres == 640 || m->xres == 480) | ||
260 | mode = MODE_VGA; | ||
261 | |||
262 | if (lcd->mode == mode) | ||
263 | return 0; | ||
264 | |||
265 | return tdo24m_adj_mode(lcd, mode); | ||
266 | } | ||
267 | |||
268 | static struct lcd_ops tdo24m_ops = { | ||
269 | .get_power = tdo24m_get_power, | ||
270 | .set_power = tdo24m_set_power, | ||
271 | .set_mode = tdo24m_set_mode, | ||
272 | }; | ||
273 | |||
274 | static int __devinit tdo24m_probe(struct spi_device *spi) | ||
275 | { | ||
276 | struct tdo24m *lcd; | ||
277 | struct spi_message *m; | ||
278 | struct spi_transfer *x; | ||
279 | int err; | ||
280 | |||
281 | spi->bits_per_word = 8; | ||
282 | spi->mode = SPI_MODE_3; | ||
283 | err = spi_setup(spi); | ||
284 | if (err) | ||
285 | return err; | ||
286 | |||
287 | lcd = kzalloc(sizeof(struct tdo24m), GFP_KERNEL); | ||
288 | if (!lcd) | ||
289 | return -ENOMEM; | ||
290 | |||
291 | lcd->spi_dev = spi; | ||
292 | lcd->power = FB_BLANK_POWERDOWN; | ||
293 | lcd->mode = MODE_VGA; /* default to VGA */ | ||
294 | |||
295 | lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, sizeof(GFP_KERNEL)); | ||
296 | if (lcd->buf == NULL) { | ||
297 | kfree(lcd); | ||
298 | return -ENOMEM; | ||
299 | } | ||
300 | |||
301 | m = &lcd->msg; | ||
302 | x = &lcd->xfer; | ||
303 | |||
304 | spi_message_init(m); | ||
305 | |||
306 | x->tx_buf = &lcd->buf[0]; | ||
307 | spi_message_add_tail(x, m); | ||
308 | |||
309 | lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, | ||
310 | lcd, &tdo24m_ops); | ||
311 | if (IS_ERR(lcd->lcd_dev)) { | ||
312 | err = PTR_ERR(lcd->lcd_dev); | ||
313 | goto out_free; | ||
314 | } | ||
315 | |||
316 | dev_set_drvdata(&spi->dev, lcd); | ||
317 | err = tdo24m_power(lcd, FB_BLANK_UNBLANK); | ||
318 | if (err) | ||
319 | goto out_unregister; | ||
320 | |||
321 | return 0; | ||
322 | |||
323 | out_unregister: | ||
324 | lcd_device_unregister(lcd->lcd_dev); | ||
325 | out_free: | ||
326 | kfree(lcd->buf); | ||
327 | kfree(lcd); | ||
328 | return err; | ||
329 | } | ||
330 | |||
331 | static int __devexit tdo24m_remove(struct spi_device *spi) | ||
332 | { | ||
333 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
334 | |||
335 | tdo24m_power(lcd, FB_BLANK_POWERDOWN); | ||
336 | lcd_device_unregister(lcd->lcd_dev); | ||
337 | kfree(lcd->buf); | ||
338 | kfree(lcd); | ||
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | #ifdef CONFIG_PM | ||
344 | static int tdo24m_suspend(struct spi_device *spi, pm_message_t state) | ||
345 | { | ||
346 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
347 | |||
348 | return tdo24m_power(lcd, FB_BLANK_POWERDOWN); | ||
349 | } | ||
350 | |||
351 | static int tdo24m_resume(struct spi_device *spi) | ||
352 | { | ||
353 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
354 | |||
355 | return tdo24m_power(lcd, FB_BLANK_UNBLANK); | ||
356 | } | ||
357 | #else | ||
358 | #define tdo24m_suspend NULL | ||
359 | #define tdo24m_resume NULL | ||
360 | #endif | ||
361 | |||
362 | /* Power down all displays on reboot, poweroff or halt */ | ||
363 | static void tdo24m_shutdown(struct spi_device *spi) | ||
364 | { | ||
365 | struct tdo24m *lcd = dev_get_drvdata(&spi->dev); | ||
366 | |||
367 | tdo24m_power(lcd, FB_BLANK_POWERDOWN); | ||
368 | } | ||
369 | |||
370 | static struct spi_driver tdo24m_driver = { | ||
371 | .driver = { | ||
372 | .name = "tdo24m", | ||
373 | .owner = THIS_MODULE, | ||
374 | }, | ||
375 | .probe = tdo24m_probe, | ||
376 | .remove = __devexit_p(tdo24m_remove), | ||
377 | .shutdown = tdo24m_shutdown, | ||
378 | .suspend = tdo24m_suspend, | ||
379 | .resume = tdo24m_resume, | ||
380 | }; | ||
381 | |||
382 | static int __init tdo24m_init(void) | ||
383 | { | ||
384 | return spi_register_driver(&tdo24m_driver); | ||
385 | } | ||
386 | module_init(tdo24m_init); | ||
387 | |||
388 | static void __exit tdo24m_exit(void) | ||
389 | { | ||
390 | spi_unregister_driver(&tdo24m_driver); | ||
391 | } | ||
392 | module_exit(tdo24m_exit); | ||
393 | |||
394 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>"); | ||
395 | MODULE_DESCRIPTION("Driver for Toppoly TDO24M LCD Panel"); | ||
396 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c index e721644bad74..1e35ba6f18e0 100644 --- a/drivers/video/bw2.c +++ b/drivers/video/bw2.c | |||
@@ -372,7 +372,7 @@ static int __devexit bw2_remove(struct of_device *op) | |||
372 | return 0; | 372 | return 0; |
373 | } | 373 | } |
374 | 374 | ||
375 | static struct of_device_id bw2_match[] = { | 375 | static const struct of_device_id bw2_match[] = { |
376 | { | 376 | { |
377 | .name = "bwtwo", | 377 | .name = "bwtwo", |
378 | }, | 378 | }, |
diff --git a/drivers/video/cg14.c b/drivers/video/cg14.c index b17e74671779..a2d1882791a5 100644 --- a/drivers/video/cg14.c +++ b/drivers/video/cg14.c | |||
@@ -589,7 +589,7 @@ static int __devexit cg14_remove(struct of_device *op) | |||
589 | return 0; | 589 | return 0; |
590 | } | 590 | } |
591 | 591 | ||
592 | static struct of_device_id cg14_match[] = { | 592 | static const struct of_device_id cg14_match[] = { |
593 | { | 593 | { |
594 | .name = "cgfourteen", | 594 | .name = "cgfourteen", |
595 | }, | 595 | }, |
diff --git a/drivers/video/cg3.c b/drivers/video/cg3.c index 3aa7b6cb0268..99f87fb61d05 100644 --- a/drivers/video/cg3.c +++ b/drivers/video/cg3.c | |||
@@ -456,7 +456,7 @@ static int __devexit cg3_remove(struct of_device *op) | |||
456 | return 0; | 456 | return 0; |
457 | } | 457 | } |
458 | 458 | ||
459 | static struct of_device_id cg3_match[] = { | 459 | static const struct of_device_id cg3_match[] = { |
460 | { | 460 | { |
461 | .name = "cgthree", | 461 | .name = "cgthree", |
462 | }, | 462 | }, |
diff --git a/drivers/video/cg6.c b/drivers/video/cg6.c index 2f64bb3bd254..940ec04f0f1b 100644 --- a/drivers/video/cg6.c +++ b/drivers/video/cg6.c | |||
@@ -34,10 +34,11 @@ static int cg6_blank(int, struct fb_info *); | |||
34 | 34 | ||
35 | static void cg6_imageblit(struct fb_info *, const struct fb_image *); | 35 | static void cg6_imageblit(struct fb_info *, const struct fb_image *); |
36 | static void cg6_fillrect(struct fb_info *, const struct fb_fillrect *); | 36 | static void cg6_fillrect(struct fb_info *, const struct fb_fillrect *); |
37 | static void cg6_copyarea(struct fb_info *info, const struct fb_copyarea *area); | ||
37 | static int cg6_sync(struct fb_info *); | 38 | static int cg6_sync(struct fb_info *); |
38 | static int cg6_mmap(struct fb_info *, struct vm_area_struct *); | 39 | static int cg6_mmap(struct fb_info *, struct vm_area_struct *); |
39 | static int cg6_ioctl(struct fb_info *, unsigned int, unsigned long); | 40 | static int cg6_ioctl(struct fb_info *, unsigned int, unsigned long); |
40 | static void cg6_copyarea(struct fb_info *info, const struct fb_copyarea *area); | 41 | static int cg6_pan_display(struct fb_var_screeninfo *, struct fb_info *); |
41 | 42 | ||
42 | /* | 43 | /* |
43 | * Frame buffer operations | 44 | * Frame buffer operations |
@@ -47,6 +48,7 @@ static struct fb_ops cg6_ops = { | |||
47 | .owner = THIS_MODULE, | 48 | .owner = THIS_MODULE, |
48 | .fb_setcolreg = cg6_setcolreg, | 49 | .fb_setcolreg = cg6_setcolreg, |
49 | .fb_blank = cg6_blank, | 50 | .fb_blank = cg6_blank, |
51 | .fb_pan_display = cg6_pan_display, | ||
50 | .fb_fillrect = cg6_fillrect, | 52 | .fb_fillrect = cg6_fillrect, |
51 | .fb_copyarea = cg6_copyarea, | 53 | .fb_copyarea = cg6_copyarea, |
52 | .fb_imageblit = cg6_imageblit, | 54 | .fb_imageblit = cg6_imageblit, |
@@ -161,6 +163,7 @@ static struct fb_ops cg6_ops = { | |||
161 | #define CG6_THC_MISC_INT_ENAB (1 << 5) | 163 | #define CG6_THC_MISC_INT_ENAB (1 << 5) |
162 | #define CG6_THC_MISC_INT (1 << 4) | 164 | #define CG6_THC_MISC_INT (1 << 4) |
163 | #define CG6_THC_MISC_INIT 0x9f | 165 | #define CG6_THC_MISC_INIT 0x9f |
166 | #define CG6_THC_CURSOFF ((65536-32) | ((65536-32) << 16)) | ||
164 | 167 | ||
165 | /* The contents are unknown */ | 168 | /* The contents are unknown */ |
166 | struct cg6_tec { | 169 | struct cg6_tec { |
@@ -280,6 +283,33 @@ static int cg6_sync(struct fb_info *info) | |||
280 | return 0; | 283 | return 0; |
281 | } | 284 | } |
282 | 285 | ||
286 | static void cg6_switch_from_graph(struct cg6_par *par) | ||
287 | { | ||
288 | struct cg6_thc __iomem *thc = par->thc; | ||
289 | unsigned long flags; | ||
290 | |||
291 | spin_lock_irqsave(&par->lock, flags); | ||
292 | |||
293 | /* Hide the cursor. */ | ||
294 | sbus_writel(CG6_THC_CURSOFF, &thc->thc_cursxy); | ||
295 | |||
296 | spin_unlock_irqrestore(&par->lock, flags); | ||
297 | } | ||
298 | |||
299 | static int cg6_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) | ||
300 | { | ||
301 | struct cg6_par *par = (struct cg6_par *)info->par; | ||
302 | |||
303 | /* We just use this to catch switches out of | ||
304 | * graphics mode. | ||
305 | */ | ||
306 | cg6_switch_from_graph(par); | ||
307 | |||
308 | if (var->xoffset || var->yoffset || var->vmode) | ||
309 | return -EINVAL; | ||
310 | return 0; | ||
311 | } | ||
312 | |||
283 | /** | 313 | /** |
284 | * cg6_fillrect - Draws a rectangle on the screen. | 314 | * cg6_fillrect - Draws a rectangle on the screen. |
285 | * | 315 | * |
@@ -643,9 +673,13 @@ static void __devinit cg6_chip_init(struct fb_info *info) | |||
643 | struct cg6_par *par = (struct cg6_par *)info->par; | 673 | struct cg6_par *par = (struct cg6_par *)info->par; |
644 | struct cg6_tec __iomem *tec = par->tec; | 674 | struct cg6_tec __iomem *tec = par->tec; |
645 | struct cg6_fbc __iomem *fbc = par->fbc; | 675 | struct cg6_fbc __iomem *fbc = par->fbc; |
676 | struct cg6_thc __iomem *thc = par->thc; | ||
646 | u32 rev, conf, mode; | 677 | u32 rev, conf, mode; |
647 | int i; | 678 | int i; |
648 | 679 | ||
680 | /* Hide the cursor. */ | ||
681 | sbus_writel(CG6_THC_CURSOFF, &thc->thc_cursxy); | ||
682 | |||
649 | /* Turn off stuff in the Transform Engine. */ | 683 | /* Turn off stuff in the Transform Engine. */ |
650 | sbus_writel(0, &tec->tec_matrix); | 684 | sbus_writel(0, &tec->tec_matrix); |
651 | sbus_writel(0, &tec->tec_clip); | 685 | sbus_writel(0, &tec->tec_clip); |
@@ -814,7 +848,7 @@ static int __devexit cg6_remove(struct of_device *op) | |||
814 | return 0; | 848 | return 0; |
815 | } | 849 | } |
816 | 850 | ||
817 | static struct of_device_id cg6_match[] = { | 851 | static const struct of_device_id cg6_match[] = { |
818 | { | 852 | { |
819 | .name = "cgsix", | 853 | .name = "cgsix", |
820 | }, | 854 | }, |
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index c14b2435d23e..e729fb279645 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c | |||
@@ -628,27 +628,18 @@ static long cirrusfb_get_mclk(long freq, int bpp, long *div) | |||
628 | static int cirrusfb_check_var(struct fb_var_screeninfo *var, | 628 | static int cirrusfb_check_var(struct fb_var_screeninfo *var, |
629 | struct fb_info *info) | 629 | struct fb_info *info) |
630 | { | 630 | { |
631 | int nom, den; /* translyting from pixels->bytes */ | 631 | int yres; |
632 | int yres, i; | 632 | /* memory size in pixels */ |
633 | static struct { int xres, yres; } modes[] = | 633 | unsigned pixels = info->screen_size * 8 / var->bits_per_pixel; |
634 | { { 1600, 1280 }, | ||
635 | { 1280, 1024 }, | ||
636 | { 1024, 768 }, | ||
637 | { 800, 600 }, | ||
638 | { 640, 480 }, | ||
639 | { -1, -1 } }; | ||
640 | 634 | ||
641 | switch (var->bits_per_pixel) { | 635 | switch (var->bits_per_pixel) { |
642 | case 1: | 636 | case 1: |
643 | nom = 4; | 637 | pixels /= 4; |
644 | den = 8; | ||
645 | break; /* 8 pixel per byte, only 1/4th of mem usable */ | 638 | break; /* 8 pixel per byte, only 1/4th of mem usable */ |
646 | case 8: | 639 | case 8: |
647 | case 16: | 640 | case 16: |
648 | case 24: | 641 | case 24: |
649 | case 32: | 642 | case 32: |
650 | nom = var->bits_per_pixel / 8; | ||
651 | den = 1; | ||
652 | break; /* 1 pixel == 1 byte */ | 643 | break; /* 1 pixel == 1 byte */ |
653 | default: | 644 | default: |
654 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected..." | 645 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected..." |
@@ -658,43 +649,29 @@ static int cirrusfb_check_var(struct fb_var_screeninfo *var, | |||
658 | return -EINVAL; | 649 | return -EINVAL; |
659 | } | 650 | } |
660 | 651 | ||
661 | if (var->xres * nom / den * var->yres > info->screen_size) { | 652 | if (var->xres_virtual < var->xres) |
662 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected..." | 653 | var->xres_virtual = var->xres; |
663 | "resolution too high to fit into video memory!\n", | ||
664 | var->xres, var->yres, var->bits_per_pixel); | ||
665 | DPRINTK("EXIT - EINVAL error\n"); | ||
666 | return -EINVAL; | ||
667 | } | ||
668 | |||
669 | /* use highest possible virtual resolution */ | 654 | /* use highest possible virtual resolution */ |
670 | if (var->xres_virtual == -1 && | 655 | if (var->yres_virtual == -1) { |
671 | var->yres_virtual == -1) { | 656 | var->yres_virtual = pixels / var->xres_virtual; |
672 | printk(KERN_INFO | ||
673 | "cirrusfb: using maximum available virtual resolution\n"); | ||
674 | for (i = 0; modes[i].xres != -1; i++) { | ||
675 | int size = modes[i].xres * nom / den * modes[i].yres; | ||
676 | if (size < info->screen_size / 2) | ||
677 | break; | ||
678 | } | ||
679 | if (modes[i].xres == -1) { | ||
680 | printk(KERN_ERR "cirrusfb: could not find a virtual " | ||
681 | "resolution that fits into video memory!!\n"); | ||
682 | DPRINTK("EXIT - EINVAL error\n"); | ||
683 | return -EINVAL; | ||
684 | } | ||
685 | var->xres_virtual = modes[i].xres; | ||
686 | var->yres_virtual = modes[i].yres; | ||
687 | 657 | ||
688 | printk(KERN_INFO "cirrusfb: virtual resolution set to " | 658 | printk(KERN_INFO "cirrusfb: virtual resolution set to " |
689 | "maximum of %dx%d\n", var->xres_virtual, | 659 | "maximum of %dx%d\n", var->xres_virtual, |
690 | var->yres_virtual); | 660 | var->yres_virtual); |
691 | } | 661 | } |
692 | |||
693 | if (var->xres_virtual < var->xres) | ||
694 | var->xres_virtual = var->xres; | ||
695 | if (var->yres_virtual < var->yres) | 662 | if (var->yres_virtual < var->yres) |
696 | var->yres_virtual = var->yres; | 663 | var->yres_virtual = var->yres; |
697 | 664 | ||
665 | if (var->xres_virtual * var->yres_virtual > pixels) { | ||
666 | printk(KERN_ERR "cirrusfb: mode %dx%dx%d rejected... " | ||
667 | "virtual resolution too high to fit into video memory!\n", | ||
668 | var->xres_virtual, var->yres_virtual, | ||
669 | var->bits_per_pixel); | ||
670 | DPRINTK("EXIT - EINVAL error\n"); | ||
671 | return -EINVAL; | ||
672 | } | ||
673 | |||
674 | |||
698 | if (var->xoffset < 0) | 675 | if (var->xoffset < 0) |
699 | var->xoffset = 0; | 676 | var->xoffset = 0; |
700 | if (var->yoffset < 0) | 677 | if (var->yoffset < 0) |
diff --git a/drivers/video/console/Kconfig b/drivers/video/console/Kconfig index 06f87b04f207..2f50a80b413e 100644 --- a/drivers/video/console/Kconfig +++ b/drivers/video/console/Kconfig | |||
@@ -43,22 +43,6 @@ config VGACON_SOFT_SCROLLBACK_SIZE | |||
43 | buffer. Each 64KB will give you approximately 16 80x25 | 43 | buffer. Each 64KB will give you approximately 16 80x25 |
44 | screenfuls of scrollback buffer | 44 | screenfuls of scrollback buffer |
45 | 45 | ||
46 | config VIDEO_SELECT | ||
47 | bool "Video mode selection support" | ||
48 | depends on X86 && VGA_CONSOLE | ||
49 | ---help--- | ||
50 | This enables support for text mode selection on kernel startup. If | ||
51 | you want to take advantage of some high-resolution text mode your | ||
52 | card's BIOS offers, but the traditional Linux utilities like | ||
53 | SVGATextMode don't, you can say Y here and set the mode using the | ||
54 | "vga=" option from your boot loader (lilo or loadlin) or set | ||
55 | "vga=ask" which brings up a video mode menu on kernel startup. (Try | ||
56 | "man bootparam" or see the documentation of your boot loader about | ||
57 | how to pass options to the kernel.) | ||
58 | |||
59 | Read the file <file:Documentation/svga.txt> for more information | ||
60 | about the Video mode selection support. If unsure, say N. | ||
61 | |||
62 | config MDA_CONSOLE | 46 | config MDA_CONSOLE |
63 | depends on !M68K && !PARISC && ISA | 47 | depends on !M68K && !PARISC && ISA |
64 | tristate "MDA text console (dual-headed) (EXPERIMENTAL)" | 48 | tristate "MDA text console (dual-headed) (EXPERIMENTAL)" |
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index c6299e8a041d..9cbff84b787d 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c | |||
@@ -2400,11 +2400,15 @@ static int fbcon_blank(struct vc_data *vc, int blank, int mode_switch) | |||
2400 | 2400 | ||
2401 | if (!fbcon_is_inactive(vc, info)) { | 2401 | if (!fbcon_is_inactive(vc, info)) { |
2402 | if (ops->blank_state != blank) { | 2402 | if (ops->blank_state != blank) { |
2403 | int ret = 1; | ||
2404 | |||
2403 | ops->blank_state = blank; | 2405 | ops->blank_state = blank; |
2404 | fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); | 2406 | fbcon_cursor(vc, blank ? CM_ERASE : CM_DRAW); |
2405 | ops->cursor_flash = (!blank); | 2407 | ops->cursor_flash = (!blank); |
2406 | 2408 | ||
2407 | if (fb_blank(info, blank)) | 2409 | if (info->fbops->fb_blank) |
2410 | ret = info->fbops->fb_blank(blank, info); | ||
2411 | if (ret) | ||
2408 | fbcon_generic_blank(vc, info, blank); | 2412 | fbcon_generic_blank(vc, info, blank); |
2409 | } | 2413 | } |
2410 | 2414 | ||
diff --git a/drivers/video/console/fbcon.h b/drivers/video/console/fbcon.h index a6e38e9ea73f..89a346880ec0 100644 --- a/drivers/video/console/fbcon.h +++ b/drivers/video/console/fbcon.h | |||
@@ -110,7 +110,7 @@ static inline int mono_col(const struct fb_info *info) | |||
110 | __u32 max_len; | 110 | __u32 max_len; |
111 | max_len = max(info->var.green.length, info->var.red.length); | 111 | max_len = max(info->var.green.length, info->var.red.length); |
112 | max_len = max(info->var.blue.length, max_len); | 112 | max_len = max(info->var.blue.length, max_len); |
113 | return ~(0xfff << (max_len & 0xff)); | 113 | return (~(0xfff << max_len)) & 0xff; |
114 | } | 114 | } |
115 | 115 | ||
116 | static inline int attr_col_ec(int shift, struct vc_data *vc, | 116 | static inline int attr_col_ec(int shift, struct vc_data *vc, |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 98843c2ecf73..0737570030f5 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -979,6 +979,7 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) | |||
979 | 979 | ||
980 | info->flags &= ~FBINFO_MISC_USEREVENT; | 980 | info->flags &= ~FBINFO_MISC_USEREVENT; |
981 | event.info = info; | 981 | event.info = info; |
982 | event.data = &mode; | ||
982 | fb_notifier_call_chain(evnt, &event); | 983 | fb_notifier_call_chain(evnt, &event); |
983 | } | 984 | } |
984 | } | 985 | } |
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c index 7992b13ee68f..9dbb9646081f 100644 --- a/drivers/video/ffb.c +++ b/drivers/video/ffb.c | |||
@@ -1042,7 +1042,7 @@ static int __devexit ffb_remove(struct of_device *op) | |||
1042 | return 0; | 1042 | return 0; |
1043 | } | 1043 | } |
1044 | 1044 | ||
1045 | static struct of_device_id ffb_match[] = { | 1045 | static const struct of_device_id ffb_match[] = { |
1046 | { | 1046 | { |
1047 | .name = "SUNW,ffb", | 1047 | .name = "SUNW,ffb", |
1048 | }, | 1048 | }, |
diff --git a/drivers/video/leo.c b/drivers/video/leo.c index 13fea61d6ae4..7c7e8c2da9d9 100644 --- a/drivers/video/leo.c +++ b/drivers/video/leo.c | |||
@@ -33,6 +33,7 @@ static int leo_blank(int, struct fb_info *); | |||
33 | 33 | ||
34 | static int leo_mmap(struct fb_info *, struct vm_area_struct *); | 34 | static int leo_mmap(struct fb_info *, struct vm_area_struct *); |
35 | static int leo_ioctl(struct fb_info *, unsigned int, unsigned long); | 35 | static int leo_ioctl(struct fb_info *, unsigned int, unsigned long); |
36 | static int leo_pan_display(struct fb_var_screeninfo *, struct fb_info *); | ||
36 | 37 | ||
37 | /* | 38 | /* |
38 | * Frame buffer operations | 39 | * Frame buffer operations |
@@ -42,6 +43,7 @@ static struct fb_ops leo_ops = { | |||
42 | .owner = THIS_MODULE, | 43 | .owner = THIS_MODULE, |
43 | .fb_setcolreg = leo_setcolreg, | 44 | .fb_setcolreg = leo_setcolreg, |
44 | .fb_blank = leo_blank, | 45 | .fb_blank = leo_blank, |
46 | .fb_pan_display = leo_pan_display, | ||
45 | .fb_fillrect = cfb_fillrect, | 47 | .fb_fillrect = cfb_fillrect, |
46 | .fb_copyarea = cfb_copyarea, | 48 | .fb_copyarea = cfb_copyarea, |
47 | .fb_imageblit = cfb_imageblit, | 49 | .fb_imageblit = cfb_imageblit, |
@@ -206,6 +208,60 @@ static void leo_wait(struct leo_lx_krn __iomem *lx_krn) | |||
206 | return; | 208 | return; |
207 | } | 209 | } |
208 | 210 | ||
211 | static void leo_switch_from_graph(struct fb_info *info) | ||
212 | { | ||
213 | struct leo_par *par = (struct leo_par *) info->par; | ||
214 | struct leo_ld_ss0 __iomem *ss = par->ld_ss0; | ||
215 | struct leo_cursor __iomem *cursor = par->cursor; | ||
216 | unsigned long flags; | ||
217 | u32 val; | ||
218 | |||
219 | spin_lock_irqsave(&par->lock, flags); | ||
220 | |||
221 | par->extent = ((info->var.xres - 1) | | ||
222 | ((info->var.yres - 1) << 16)); | ||
223 | |||
224 | sbus_writel(0xffffffff, &ss->wid); | ||
225 | sbus_writel(0xffff, &ss->wmask); | ||
226 | sbus_writel(0, &ss->vclipmin); | ||
227 | sbus_writel(par->extent, &ss->vclipmax); | ||
228 | sbus_writel(0, &ss->fg); | ||
229 | sbus_writel(0xff000000, &ss->planemask); | ||
230 | sbus_writel(0x310850, &ss->rop); | ||
231 | sbus_writel(0, &ss->widclip); | ||
232 | sbus_writel((info->var.xres-1) | ((info->var.yres-1) << 11), | ||
233 | &par->lc_ss0_usr->extent); | ||
234 | sbus_writel(4, &par->lc_ss0_usr->addrspace); | ||
235 | sbus_writel(0x80000000, &par->lc_ss0_usr->fill); | ||
236 | sbus_writel(0, &par->lc_ss0_usr->fontt); | ||
237 | do { | ||
238 | val = sbus_readl(&par->lc_ss0_usr->csr); | ||
239 | } while (val & 0x20000000); | ||
240 | |||
241 | /* setup screen buffer for cfb_* functions */ | ||
242 | sbus_writel(1, &ss->wid); | ||
243 | sbus_writel(0x00ffffff, &ss->planemask); | ||
244 | sbus_writel(0x310b90, &ss->rop); | ||
245 | sbus_writel(0, &par->lc_ss0_usr->addrspace); | ||
246 | |||
247 | /* hide cursor */ | ||
248 | sbus_writel(sbus_readl(&cursor->cur_misc) & ~LEO_CUR_ENABLE, &cursor->cur_misc); | ||
249 | |||
250 | spin_unlock_irqrestore(&par->lock, flags); | ||
251 | } | ||
252 | |||
253 | static int leo_pan_display(struct fb_var_screeninfo *var, struct fb_info *info) | ||
254 | { | ||
255 | /* We just use this to catch switches out of | ||
256 | * graphics mode. | ||
257 | */ | ||
258 | leo_switch_from_graph(info); | ||
259 | |||
260 | if (var->xoffset || var->yoffset || var->vmode) | ||
261 | return -EINVAL; | ||
262 | return 0; | ||
263 | } | ||
264 | |||
209 | /** | 265 | /** |
210 | * leo_setcolreg - Optional function. Sets a color register. | 266 | * leo_setcolreg - Optional function. Sets a color register. |
211 | * @regno: boolean, 0 copy local, 1 get_user() function | 267 | * @regno: boolean, 0 copy local, 1 get_user() function |
@@ -454,44 +510,6 @@ static void leo_init_wids(struct fb_info *info) | |||
454 | leo_wid_put(info, &wl); | 510 | leo_wid_put(info, &wl); |
455 | } | 511 | } |
456 | 512 | ||
457 | static void leo_switch_from_graph(struct fb_info *info) | ||
458 | { | ||
459 | struct leo_par *par = (struct leo_par *) info->par; | ||
460 | struct leo_ld_ss0 __iomem *ss = par->ld_ss0; | ||
461 | unsigned long flags; | ||
462 | u32 val; | ||
463 | |||
464 | spin_lock_irqsave(&par->lock, flags); | ||
465 | |||
466 | par->extent = ((info->var.xres - 1) | | ||
467 | ((info->var.yres - 1) << 16)); | ||
468 | |||
469 | sbus_writel(0xffffffff, &ss->wid); | ||
470 | sbus_writel(0xffff, &ss->wmask); | ||
471 | sbus_writel(0, &ss->vclipmin); | ||
472 | sbus_writel(par->extent, &ss->vclipmax); | ||
473 | sbus_writel(0, &ss->fg); | ||
474 | sbus_writel(0xff000000, &ss->planemask); | ||
475 | sbus_writel(0x310850, &ss->rop); | ||
476 | sbus_writel(0, &ss->widclip); | ||
477 | sbus_writel((info->var.xres-1) | ((info->var.yres-1) << 11), | ||
478 | &par->lc_ss0_usr->extent); | ||
479 | sbus_writel(4, &par->lc_ss0_usr->addrspace); | ||
480 | sbus_writel(0x80000000, &par->lc_ss0_usr->fill); | ||
481 | sbus_writel(0, &par->lc_ss0_usr->fontt); | ||
482 | do { | ||
483 | val = sbus_readl(&par->lc_ss0_usr->csr); | ||
484 | } while (val & 0x20000000); | ||
485 | |||
486 | /* setup screen buffer for cfb_* functions */ | ||
487 | sbus_writel(1, &ss->wid); | ||
488 | sbus_writel(0x00ffffff, &ss->planemask); | ||
489 | sbus_writel(0x310b90, &ss->rop); | ||
490 | sbus_writel(0, &par->lc_ss0_usr->addrspace); | ||
491 | |||
492 | spin_unlock_irqrestore(&par->lock, flags); | ||
493 | } | ||
494 | |||
495 | static void leo_init_hw(struct fb_info *info) | 513 | static void leo_init_hw(struct fb_info *info) |
496 | { | 514 | { |
497 | struct leo_par *par = (struct leo_par *) info->par; | 515 | struct leo_par *par = (struct leo_par *) info->par; |
@@ -641,7 +659,7 @@ static int __devexit leo_remove(struct of_device *op) | |||
641 | return 0; | 659 | return 0; |
642 | } | 660 | } |
643 | 661 | ||
644 | static struct of_device_id leo_match[] = { | 662 | static const struct of_device_id leo_match[] = { |
645 | { | 663 | { |
646 | .name = "SUNW,leo", | 664 | .name = "SUNW,leo", |
647 | }, | 665 | }, |
diff --git a/drivers/video/metronomefb.c b/drivers/video/metronomefb.c index cc4c038a1b3f..afeed0611e3e 100644 --- a/drivers/video/metronomefb.c +++ b/drivers/video/metronomefb.c | |||
@@ -40,29 +40,63 @@ | |||
40 | 40 | ||
41 | #include <asm/unaligned.h> | 41 | #include <asm/unaligned.h> |
42 | 42 | ||
43 | |||
44 | #define DEBUG 1 | ||
45 | #ifdef DEBUG | ||
46 | #define DPRINTK(f, a...) printk(KERN_DEBUG "%s: " f, __func__ , ## a) | ||
47 | #else | ||
48 | #define DPRINTK(f, a...) | ||
49 | #endif | ||
50 | |||
51 | |||
52 | /* Display specific information */ | 43 | /* Display specific information */ |
53 | #define DPY_W 832 | 44 | #define DPY_W 832 |
54 | #define DPY_H 622 | 45 | #define DPY_H 622 |
55 | 46 | ||
47 | static int user_wfm_size; | ||
48 | |||
56 | /* frame differs from image. frame includes non-visible pixels */ | 49 | /* frame differs from image. frame includes non-visible pixels */ |
57 | struct epd_frame { | 50 | struct epd_frame { |
58 | int fw; /* frame width */ | 51 | int fw; /* frame width */ |
59 | int fh; /* frame height */ | 52 | int fh; /* frame height */ |
53 | u16 config[4]; | ||
54 | int wfm_size; | ||
60 | }; | 55 | }; |
61 | 56 | ||
62 | static struct epd_frame epd_frame_table[] = { | 57 | static struct epd_frame epd_frame_table[] = { |
63 | { | 58 | { |
64 | .fw = 832, | 59 | .fw = 832, |
65 | .fh = 622 | 60 | .fh = 622, |
61 | .config = { | ||
62 | 15 /* sdlew */ | ||
63 | | 2 << 8 /* sdosz */ | ||
64 | | 0 << 11 /* sdor */ | ||
65 | | 0 << 12 /* sdces */ | ||
66 | | 0 << 15, /* sdcer */ | ||
67 | 42 /* gdspl */ | ||
68 | | 1 << 8 /* gdr1 */ | ||
69 | | 1 << 9 /* sdshr */ | ||
70 | | 0 << 15, /* gdspp */ | ||
71 | 18 /* gdspw */ | ||
72 | | 0 << 15, /* dispc */ | ||
73 | 599 /* vdlc */ | ||
74 | | 0 << 11 /* dsi */ | ||
75 | | 0 << 12, /* dsic */ | ||
76 | }, | ||
77 | .wfm_size = 47001, | ||
78 | }, | ||
79 | { | ||
80 | .fw = 1088, | ||
81 | .fh = 791, | ||
82 | .config = { | ||
83 | 0x0104, | ||
84 | 0x031f, | ||
85 | 0x0088, | ||
86 | 0x02ff, | ||
87 | }, | ||
88 | .wfm_size = 46770, | ||
89 | }, | ||
90 | { | ||
91 | .fw = 1200, | ||
92 | .fh = 842, | ||
93 | .config = { | ||
94 | 0x0101, | ||
95 | 0x030e, | ||
96 | 0x0012, | ||
97 | 0x0280, | ||
98 | }, | ||
99 | .wfm_size = 46770, | ||
66 | }, | 100 | }, |
67 | }; | 101 | }; |
68 | 102 | ||
@@ -134,9 +168,8 @@ static u16 calc_img_cksum(u16 *start, int length) | |||
134 | } | 168 | } |
135 | 169 | ||
136 | /* here we decode the incoming waveform file and populate metromem */ | 170 | /* here we decode the incoming waveform file and populate metromem */ |
137 | #define EXP_WFORM_SIZE 47001 | 171 | static int __devinit load_waveform(u8 *mem, size_t size, int m, int t, |
138 | static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | 172 | struct metronomefb_par *par) |
139 | u8 *frame_count) | ||
140 | { | 173 | { |
141 | int tta; | 174 | int tta; |
142 | int wmta; | 175 | int wmta; |
@@ -148,26 +181,31 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
148 | int wfm_idx, owfm_idx; | 181 | int wfm_idx, owfm_idx; |
149 | int mem_idx = 0; | 182 | int mem_idx = 0; |
150 | struct waveform_hdr *wfm_hdr; | 183 | struct waveform_hdr *wfm_hdr; |
184 | u8 *metromem = par->metromem_wfm; | ||
185 | struct device *dev = par->info->dev; | ||
151 | 186 | ||
152 | if (size != EXP_WFORM_SIZE) { | 187 | if (user_wfm_size) |
153 | printk(KERN_ERR "Error: unexpected size %d != %d\n", size, | 188 | epd_frame_table[par->dt].wfm_size = user_wfm_size; |
154 | EXP_WFORM_SIZE); | 189 | |
190 | if (size != epd_frame_table[par->dt].wfm_size) { | ||
191 | dev_err(dev, "Error: unexpected size %d != %d\n", size, | ||
192 | epd_frame_table[par->dt].wfm_size); | ||
155 | return -EINVAL; | 193 | return -EINVAL; |
156 | } | 194 | } |
157 | 195 | ||
158 | wfm_hdr = (struct waveform_hdr *) mem; | 196 | wfm_hdr = (struct waveform_hdr *) mem; |
159 | 197 | ||
160 | if (wfm_hdr->fvsn != 1) { | 198 | if (wfm_hdr->fvsn != 1) { |
161 | printk(KERN_ERR "Error: bad fvsn %x\n", wfm_hdr->fvsn); | 199 | dev_err(dev, "Error: bad fvsn %x\n", wfm_hdr->fvsn); |
162 | return -EINVAL; | 200 | return -EINVAL; |
163 | } | 201 | } |
164 | if (wfm_hdr->luts != 0) { | 202 | if (wfm_hdr->luts != 0) { |
165 | printk(KERN_ERR "Error: bad luts %x\n", wfm_hdr->luts); | 203 | dev_err(dev, "Error: bad luts %x\n", wfm_hdr->luts); |
166 | return -EINVAL; | 204 | return -EINVAL; |
167 | } | 205 | } |
168 | cksum = calc_cksum(32, 47, mem); | 206 | cksum = calc_cksum(32, 47, mem); |
169 | if (cksum != wfm_hdr->wfm_cs) { | 207 | if (cksum != wfm_hdr->wfm_cs) { |
170 | printk(KERN_ERR "Error: bad cksum %x != %x\n", cksum, | 208 | dev_err(dev, "Error: bad cksum %x != %x\n", cksum, |
171 | wfm_hdr->wfm_cs); | 209 | wfm_hdr->wfm_cs); |
172 | return -EINVAL; | 210 | return -EINVAL; |
173 | } | 211 | } |
@@ -175,7 +213,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
175 | wfm_hdr->trc += 1; | 213 | wfm_hdr->trc += 1; |
176 | for (i = 0; i < 5; i++) { | 214 | for (i = 0; i < 5; i++) { |
177 | if (*(wfm_hdr->stuff2a + i) != 0) { | 215 | if (*(wfm_hdr->stuff2a + i) != 0) { |
178 | printk(KERN_ERR "Error: unexpected value in padding\n"); | 216 | dev_err(dev, "Error: unexpected value in padding\n"); |
179 | return -EINVAL; | 217 | return -EINVAL; |
180 | } | 218 | } |
181 | } | 219 | } |
@@ -200,7 +238,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
200 | return -EINVAL; | 238 | return -EINVAL; |
201 | cksum = calc_cksum(sizeof(*wfm_hdr), cksum_idx, mem); | 239 | cksum = calc_cksum(sizeof(*wfm_hdr), cksum_idx, mem); |
202 | if (cksum != mem[cksum_idx]) { | 240 | if (cksum != mem[cksum_idx]) { |
203 | printk(KERN_ERR "Error: bad temperature range table cksum" | 241 | dev_err(dev, "Error: bad temperature range table cksum" |
204 | " %x != %x\n", cksum, mem[cksum_idx]); | 242 | " %x != %x\n", cksum, mem[cksum_idx]); |
205 | return -EINVAL; | 243 | return -EINVAL; |
206 | } | 244 | } |
@@ -212,7 +250,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
212 | return -EINVAL; | 250 | return -EINVAL; |
213 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); | 251 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); |
214 | if (cksum != mem[cksum_idx]) { | 252 | if (cksum != mem[cksum_idx]) { |
215 | printk(KERN_ERR "Error: bad mode table address cksum" | 253 | dev_err(dev, "Error: bad mode table address cksum" |
216 | " %x != %x\n", cksum, mem[cksum_idx]); | 254 | " %x != %x\n", cksum, mem[cksum_idx]); |
217 | return -EINVAL; | 255 | return -EINVAL; |
218 | } | 256 | } |
@@ -224,7 +262,7 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
224 | return -EINVAL; | 262 | return -EINVAL; |
225 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); | 263 | cksum = calc_cksum(cksum_idx - 3, cksum_idx, mem); |
226 | if (cksum != mem[cksum_idx]) { | 264 | if (cksum != mem[cksum_idx]) { |
227 | printk(KERN_ERR "Error: bad temperature table address cksum" | 265 | dev_err(dev, "Error: bad temperature table address cksum" |
228 | " %x != %x\n", cksum, mem[cksum_idx]); | 266 | " %x != %x\n", cksum, mem[cksum_idx]); |
229 | return -EINVAL; | 267 | return -EINVAL; |
230 | } | 268 | } |
@@ -259,11 +297,11 @@ static int load_waveform(u8 *mem, size_t size, u8 *metromem, int m, int t, | |||
259 | return -EINVAL; | 297 | return -EINVAL; |
260 | cksum = calc_cksum(owfm_idx, cksum_idx, mem); | 298 | cksum = calc_cksum(owfm_idx, cksum_idx, mem); |
261 | if (cksum != mem[cksum_idx]) { | 299 | if (cksum != mem[cksum_idx]) { |
262 | printk(KERN_ERR "Error: bad waveform data cksum" | 300 | dev_err(dev, "Error: bad waveform data cksum" |
263 | " %x != %x\n", cksum, mem[cksum_idx]); | 301 | " %x != %x\n", cksum, mem[cksum_idx]); |
264 | return -EINVAL; | 302 | return -EINVAL; |
265 | } | 303 | } |
266 | *frame_count = (mem_idx/64); | 304 | par->frame_count = (mem_idx/64); |
267 | 305 | ||
268 | return 0; | 306 | return 0; |
269 | } | 307 | } |
@@ -274,15 +312,12 @@ static int metronome_display_cmd(struct metronomefb_par *par) | |||
274 | u16 cs; | 312 | u16 cs; |
275 | u16 opcode; | 313 | u16 opcode; |
276 | static u8 borderval; | 314 | static u8 borderval; |
277 | u8 *ptr; | ||
278 | 315 | ||
279 | /* setup display command | 316 | /* setup display command |
280 | we can't immediately set the opcode since the controller | 317 | we can't immediately set the opcode since the controller |
281 | will try parse the command before we've set it all up | 318 | will try parse the command before we've set it all up |
282 | so we just set cs here and set the opcode at the end */ | 319 | so we just set cs here and set the opcode at the end */ |
283 | 320 | ||
284 | ptr = par->metromem; | ||
285 | |||
286 | if (par->metromem_cmd->opcode == 0xCC40) | 321 | if (par->metromem_cmd->opcode == 0xCC40) |
287 | opcode = cs = 0xCC41; | 322 | opcode = cs = 0xCC41; |
288 | else | 323 | else |
@@ -335,44 +370,17 @@ static int __devinit metronome_powerup_cmd(struct metronomefb_par *par) | |||
335 | 370 | ||
336 | static int __devinit metronome_config_cmd(struct metronomefb_par *par) | 371 | static int __devinit metronome_config_cmd(struct metronomefb_par *par) |
337 | { | 372 | { |
338 | int i; | ||
339 | u16 cs; | ||
340 | |||
341 | /* setup config command | 373 | /* setup config command |
342 | we can't immediately set the opcode since the controller | 374 | we can't immediately set the opcode since the controller |
343 | will try parse the command before we've set it all up | 375 | will try parse the command before we've set it all up */ |
344 | so we just set cs here and set the opcode at the end */ | ||
345 | |||
346 | cs = 0xCC10; | ||
347 | |||
348 | /* set the 12 args ( 8 bytes ) for config. see spec for meanings */ | ||
349 | i = 0; | ||
350 | par->metromem_cmd->args[i] = 15 /* sdlew */ | ||
351 | | 2 << 8 /* sdosz */ | ||
352 | | 0 << 11 /* sdor */ | ||
353 | | 0 << 12 /* sdces */ | ||
354 | | 0 << 15; /* sdcer */ | ||
355 | cs += par->metromem_cmd->args[i++]; | ||
356 | |||
357 | par->metromem_cmd->args[i] = 42 /* gdspl */ | ||
358 | | 1 << 8 /* gdr1 */ | ||
359 | | 1 << 9 /* sdshr */ | ||
360 | | 0 << 15; /* gdspp */ | ||
361 | cs += par->metromem_cmd->args[i++]; | ||
362 | |||
363 | par->metromem_cmd->args[i] = 18 /* gdspw */ | ||
364 | | 0 << 15; /* dispc */ | ||
365 | cs += par->metromem_cmd->args[i++]; | ||
366 | |||
367 | par->metromem_cmd->args[i] = 599 /* vdlc */ | ||
368 | | 0 << 11 /* dsi */ | ||
369 | | 0 << 12; /* dsic */ | ||
370 | cs += par->metromem_cmd->args[i++]; | ||
371 | 376 | ||
377 | memcpy(par->metromem_cmd->args, epd_frame_table[par->dt].config, | ||
378 | sizeof(epd_frame_table[par->dt].config)); | ||
372 | /* the rest are 0 */ | 379 | /* the rest are 0 */ |
373 | memset((u8 *) (par->metromem_cmd->args + i), 0, (32-i)*2); | 380 | memset((u8 *) (par->metromem_cmd->args + 4), 0, (32-4)*2); |
374 | 381 | ||
375 | par->metromem_cmd->csum = cs; | 382 | par->metromem_cmd->csum = 0xCC10; |
383 | par->metromem_cmd->csum += calc_img_cksum(par->metromem_cmd->args, 4); | ||
376 | par->metromem_cmd->opcode = 0xCC10; /* config cmd */ | 384 | par->metromem_cmd->opcode = 0xCC10; /* config cmd */ |
377 | 385 | ||
378 | return par->board->met_wait_event(par); | 386 | return par->board->met_wait_event(par); |
@@ -408,12 +416,9 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par) | |||
408 | { | 416 | { |
409 | int res; | 417 | int res; |
410 | 418 | ||
411 | par->board->init_gpio_regs(par); | 419 | res = par->board->setup_io(par); |
412 | 420 | if (res) | |
413 | par->board->init_lcdc_regs(par); | 421 | return res; |
414 | |||
415 | /* now that lcd is setup, setup dma descriptor */ | ||
416 | par->board->post_dma_setup(par); | ||
417 | 422 | ||
418 | res = metronome_powerup_cmd(par); | 423 | res = metronome_powerup_cmd(par); |
419 | if (res) | 424 | if (res) |
@@ -430,16 +435,16 @@ static int __devinit metronome_init_regs(struct metronomefb_par *par) | |||
430 | 435 | ||
431 | static void metronomefb_dpy_update(struct metronomefb_par *par) | 436 | static void metronomefb_dpy_update(struct metronomefb_par *par) |
432 | { | 437 | { |
438 | int fbsize; | ||
433 | u16 cksum; | 439 | u16 cksum; |
434 | unsigned char *buf = (unsigned char __force *)par->info->screen_base; | 440 | unsigned char *buf = (unsigned char __force *)par->info->screen_base; |
435 | 441 | ||
442 | fbsize = par->info->fix.smem_len; | ||
436 | /* copy from vm to metromem */ | 443 | /* copy from vm to metromem */ |
437 | memcpy(par->metromem_img, buf, DPY_W*DPY_H); | 444 | memcpy(par->metromem_img, buf, fbsize); |
438 | 445 | ||
439 | cksum = calc_img_cksum((u16 *) par->metromem_img, | 446 | cksum = calc_img_cksum((u16 *) par->metromem_img, fbsize/2); |
440 | (epd_frame_table[0].fw * DPY_H)/2); | 447 | *((u16 *)(par->metromem_img) + fbsize/2) = cksum; |
441 | *((u16 *)(par->metromem_img) + | ||
442 | (epd_frame_table[0].fw * DPY_H)/2) = cksum; | ||
443 | metronome_display_cmd(par); | 448 | metronome_display_cmd(par); |
444 | } | 449 | } |
445 | 450 | ||
@@ -574,8 +579,10 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
574 | unsigned char *videomemory; | 579 | unsigned char *videomemory; |
575 | struct metronomefb_par *par; | 580 | struct metronomefb_par *par; |
576 | const struct firmware *fw_entry; | 581 | const struct firmware *fw_entry; |
577 | int cmd_size, wfm_size, img_size, padding_size, totalsize; | ||
578 | int i; | 582 | int i; |
583 | int panel_type; | ||
584 | int fw, fh; | ||
585 | int epd_dt_index; | ||
579 | 586 | ||
580 | /* pick up board specific routines */ | 587 | /* pick up board specific routines */ |
581 | board = dev->dev.platform_data; | 588 | board = dev->dev.platform_data; |
@@ -586,96 +593,108 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
586 | if (!try_module_get(board->owner)) | 593 | if (!try_module_get(board->owner)) |
587 | return -ENODEV; | 594 | return -ENODEV; |
588 | 595 | ||
596 | info = framebuffer_alloc(sizeof(struct metronomefb_par), &dev->dev); | ||
597 | if (!info) | ||
598 | goto err; | ||
599 | |||
589 | /* we have two blocks of memory. | 600 | /* we have two blocks of memory. |
590 | info->screen_base which is vm, and is the fb used by apps. | 601 | info->screen_base which is vm, and is the fb used by apps. |
591 | par->metromem which is physically contiguous memory and | 602 | par->metromem which is physically contiguous memory and |
592 | contains the display controller commands, waveform, | 603 | contains the display controller commands, waveform, |
593 | processed image data and padding. this is the data pulled | 604 | processed image data and padding. this is the data pulled |
594 | by the device's LCD controller and pushed to Metronome */ | 605 | by the device's LCD controller and pushed to Metronome. |
606 | the metromem memory is allocated by the board driver and | ||
607 | is provided to us */ | ||
608 | |||
609 | panel_type = board->get_panel_type(); | ||
610 | switch (panel_type) { | ||
611 | case 6: | ||
612 | epd_dt_index = 0; | ||
613 | break; | ||
614 | case 8: | ||
615 | epd_dt_index = 1; | ||
616 | break; | ||
617 | case 97: | ||
618 | epd_dt_index = 2; | ||
619 | break; | ||
620 | default: | ||
621 | dev_err(&dev->dev, "Unexpected panel type. Defaulting to 6\n"); | ||
622 | epd_dt_index = 0; | ||
623 | break; | ||
624 | } | ||
625 | |||
626 | fw = epd_frame_table[epd_dt_index].fw; | ||
627 | fh = epd_frame_table[epd_dt_index].fh; | ||
595 | 628 | ||
596 | videomemorysize = (DPY_W*DPY_H); | 629 | /* we need to add a spare page because our csum caching scheme walks |
630 | * to the end of the page */ | ||
631 | videomemorysize = PAGE_SIZE + (fw * fh); | ||
597 | videomemory = vmalloc(videomemorysize); | 632 | videomemory = vmalloc(videomemorysize); |
598 | if (!videomemory) | 633 | if (!videomemory) |
599 | return -ENOMEM; | 634 | goto err_fb_rel; |
600 | 635 | ||
601 | memset(videomemory, 0, videomemorysize); | 636 | memset(videomemory, 0, videomemorysize); |
602 | 637 | ||
603 | info = framebuffer_alloc(sizeof(struct metronomefb_par), &dev->dev); | ||
604 | if (!info) | ||
605 | goto err_vfree; | ||
606 | |||
607 | info->screen_base = (char __force __iomem *)videomemory; | 638 | info->screen_base = (char __force __iomem *)videomemory; |
608 | info->fbops = &metronomefb_ops; | 639 | info->fbops = &metronomefb_ops; |
609 | 640 | ||
641 | metronomefb_fix.line_length = fw; | ||
642 | metronomefb_var.xres = fw; | ||
643 | metronomefb_var.yres = fh; | ||
644 | metronomefb_var.xres_virtual = fw; | ||
645 | metronomefb_var.yres_virtual = fh; | ||
610 | info->var = metronomefb_var; | 646 | info->var = metronomefb_var; |
611 | info->fix = metronomefb_fix; | 647 | info->fix = metronomefb_fix; |
612 | info->fix.smem_len = videomemorysize; | 648 | info->fix.smem_len = videomemorysize; |
613 | par = info->par; | 649 | par = info->par; |
614 | par->info = info; | 650 | par->info = info; |
615 | par->board = board; | 651 | par->board = board; |
652 | par->dt = epd_dt_index; | ||
616 | init_waitqueue_head(&par->waitq); | 653 | init_waitqueue_head(&par->waitq); |
617 | 654 | ||
618 | /* this table caches per page csum values. */ | 655 | /* this table caches per page csum values. */ |
619 | par->csum_table = vmalloc(videomemorysize/PAGE_SIZE); | 656 | par->csum_table = vmalloc(videomemorysize/PAGE_SIZE); |
620 | if (!par->csum_table) | 657 | if (!par->csum_table) |
658 | goto err_vfree; | ||
659 | |||
660 | /* the physical framebuffer that we use is setup by | ||
661 | * the platform device driver. It will provide us | ||
662 | * with cmd, wfm and image memory in a contiguous area. */ | ||
663 | retval = board->setup_fb(par); | ||
664 | if (retval) { | ||
665 | dev_err(&dev->dev, "Failed to setup fb\n"); | ||
621 | goto err_csum_table; | 666 | goto err_csum_table; |
667 | } | ||
622 | 668 | ||
623 | /* the metromem buffer is divided as follows: | 669 | /* after this point we should have a framebuffer */ |
624 | command | CRC | padding | 670 | if ((!par->metromem_wfm) || (!par->metromem_img) || |
625 | 16kb waveform data | CRC | padding | 671 | (!par->metromem_dma)) { |
626 | image data | CRC | 672 | dev_err(&dev->dev, "fb access failure\n"); |
627 | and an extra 256 bytes for dma descriptors | 673 | retval = -EINVAL; |
628 | eg: IW=832 IH=622 WS=128 | 674 | goto err_csum_table; |
629 | */ | ||
630 | |||
631 | cmd_size = 1 * epd_frame_table[0].fw; | ||
632 | wfm_size = ((16*1024 + 2 + epd_frame_table[0].fw - 1) | ||
633 | / epd_frame_table[0].fw) * epd_frame_table[0].fw; | ||
634 | img_size = epd_frame_table[0].fh * epd_frame_table[0].fw; | ||
635 | padding_size = 4 * epd_frame_table[0].fw; | ||
636 | totalsize = cmd_size + wfm_size + img_size + padding_size; | ||
637 | par->metromemsize = PAGE_ALIGN(totalsize + 256); | ||
638 | DPRINTK("desired memory size = %d\n", par->metromemsize); | ||
639 | dev->dev.coherent_dma_mask = 0xffffffffull; | ||
640 | par->metromem = dma_alloc_writecombine(&dev->dev, par->metromemsize, | ||
641 | &par->metromem_dma, GFP_KERNEL); | ||
642 | if (!par->metromem) { | ||
643 | printk(KERN_ERR | ||
644 | "metronomefb: unable to allocate dma buffer\n"); | ||
645 | goto err_vfree; | ||
646 | } | 675 | } |
647 | 676 | ||
648 | info->fix.smem_start = par->metromem_dma; | 677 | info->fix.smem_start = par->metromem_dma; |
649 | par->metromem_cmd = (struct metromem_cmd *) par->metromem; | ||
650 | par->metromem_wfm = par->metromem + cmd_size; | ||
651 | par->metromem_img = par->metromem + cmd_size + wfm_size; | ||
652 | par->metromem_img_csum = (u16 *) (par->metromem_img + | ||
653 | (epd_frame_table[0].fw * DPY_H)); | ||
654 | DPRINTK("img offset=0x%x\n", cmd_size + wfm_size); | ||
655 | par->metromem_desc = (struct metromem_desc *) (par->metromem + cmd_size | ||
656 | + wfm_size + img_size + padding_size); | ||
657 | par->metromem_desc_dma = par->metromem_dma + cmd_size + wfm_size | ||
658 | + img_size + padding_size; | ||
659 | 678 | ||
660 | /* load the waveform in. assume mode 3, temp 31 for now | 679 | /* load the waveform in. assume mode 3, temp 31 for now |
661 | a) request the waveform file from userspace | 680 | a) request the waveform file from userspace |
662 | b) process waveform and decode into metromem */ | 681 | b) process waveform and decode into metromem */ |
663 | retval = request_firmware(&fw_entry, "metronome.wbf", &dev->dev); | 682 | retval = request_firmware(&fw_entry, "metronome.wbf", &dev->dev); |
664 | if (retval < 0) { | 683 | if (retval < 0) { |
665 | printk(KERN_ERR "metronomefb: couldn't get waveform\n"); | 684 | dev_err(&dev->dev, "Failed to get waveform\n"); |
666 | goto err_dma_free; | 685 | goto err_csum_table; |
667 | } | 686 | } |
668 | 687 | ||
669 | retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, | 688 | retval = load_waveform((u8 *) fw_entry->data, fw_entry->size, 3, 31, |
670 | par->metromem_wfm, 3, 31, &par->frame_count); | 689 | par); |
671 | release_firmware(fw_entry); | 690 | release_firmware(fw_entry); |
672 | if (retval < 0) { | 691 | if (retval < 0) { |
673 | printk(KERN_ERR "metronomefb: couldn't process waveform\n"); | 692 | dev_err(&dev->dev, "Failed processing waveform\n"); |
674 | goto err_dma_free; | 693 | goto err_csum_table; |
675 | } | 694 | } |
676 | 695 | ||
677 | if (board->setup_irq(info)) | 696 | if (board->setup_irq(info)) |
678 | goto err_dma_free; | 697 | goto err_csum_table; |
679 | 698 | ||
680 | retval = metronome_init_regs(par); | 699 | retval = metronome_init_regs(par); |
681 | if (retval < 0) | 700 | if (retval < 0) |
@@ -688,8 +707,8 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
688 | 707 | ||
689 | retval = fb_alloc_cmap(&info->cmap, 8, 0); | 708 | retval = fb_alloc_cmap(&info->cmap, 8, 0); |
690 | if (retval < 0) { | 709 | if (retval < 0) { |
691 | printk(KERN_ERR "Failed to allocate colormap\n"); | 710 | dev_err(&dev->dev, "Failed to allocate colormap\n"); |
692 | goto err_fb_rel; | 711 | goto err_free_irq; |
693 | } | 712 | } |
694 | 713 | ||
695 | /* set cmap */ | 714 | /* set cmap */ |
@@ -704,7 +723,7 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
704 | 723 | ||
705 | platform_set_drvdata(dev, info); | 724 | platform_set_drvdata(dev, info); |
706 | 725 | ||
707 | printk(KERN_INFO | 726 | dev_dbg(&dev->dev, |
708 | "fb%d: Metronome frame buffer device, using %dK of video" | 727 | "fb%d: Metronome frame buffer device, using %dK of video" |
709 | " memory\n", info->node, videomemorysize >> 10); | 728 | " memory\n", info->node, videomemorysize >> 10); |
710 | 729 | ||
@@ -712,17 +731,15 @@ static int __devinit metronomefb_probe(struct platform_device *dev) | |||
712 | 731 | ||
713 | err_cmap: | 732 | err_cmap: |
714 | fb_dealloc_cmap(&info->cmap); | 733 | fb_dealloc_cmap(&info->cmap); |
715 | err_fb_rel: | ||
716 | framebuffer_release(info); | ||
717 | err_free_irq: | 734 | err_free_irq: |
718 | board->free_irq(info); | 735 | board->cleanup(par); |
719 | err_dma_free: | ||
720 | dma_free_writecombine(&dev->dev, par->metromemsize, par->metromem, | ||
721 | par->metromem_dma); | ||
722 | err_csum_table: | 736 | err_csum_table: |
723 | vfree(par->csum_table); | 737 | vfree(par->csum_table); |
724 | err_vfree: | 738 | err_vfree: |
725 | vfree(videomemory); | 739 | vfree(videomemory); |
740 | err_fb_rel: | ||
741 | framebuffer_release(info); | ||
742 | err: | ||
726 | module_put(board->owner); | 743 | module_put(board->owner); |
727 | return retval; | 744 | return retval; |
728 | } | 745 | } |
@@ -733,15 +750,15 @@ static int __devexit metronomefb_remove(struct platform_device *dev) | |||
733 | 750 | ||
734 | if (info) { | 751 | if (info) { |
735 | struct metronomefb_par *par = info->par; | 752 | struct metronomefb_par *par = info->par; |
753 | |||
754 | unregister_framebuffer(info); | ||
736 | fb_deferred_io_cleanup(info); | 755 | fb_deferred_io_cleanup(info); |
737 | dma_free_writecombine(&dev->dev, par->metromemsize, | ||
738 | par->metromem, par->metromem_dma); | ||
739 | fb_dealloc_cmap(&info->cmap); | 756 | fb_dealloc_cmap(&info->cmap); |
757 | par->board->cleanup(par); | ||
740 | vfree(par->csum_table); | 758 | vfree(par->csum_table); |
741 | unregister_framebuffer(info); | ||
742 | vfree((void __force *)info->screen_base); | 759 | vfree((void __force *)info->screen_base); |
743 | par->board->free_irq(info); | ||
744 | module_put(par->board->owner); | 760 | module_put(par->board->owner); |
761 | dev_dbg(&dev->dev, "calling release\n"); | ||
745 | framebuffer_release(info); | 762 | framebuffer_release(info); |
746 | } | 763 | } |
747 | return 0; | 764 | return 0; |
@@ -766,6 +783,9 @@ static void __exit metronomefb_exit(void) | |||
766 | platform_driver_unregister(&metronomefb_driver); | 783 | platform_driver_unregister(&metronomefb_driver); |
767 | } | 784 | } |
768 | 785 | ||
786 | module_param(user_wfm_size, uint, 0); | ||
787 | MODULE_PARM_DESC(user_wfm_size, "Set custom waveform size"); | ||
788 | |||
769 | module_init(metronomefb_init); | 789 | module_init(metronomefb_init); |
770 | module_exit(metronomefb_exit); | 790 | module_exit(metronomefb_exit); |
771 | 791 | ||
diff --git a/drivers/video/p9100.c b/drivers/video/p9100.c index 9e903454ffc1..7000f2cd5854 100644 --- a/drivers/video/p9100.c +++ b/drivers/video/p9100.c | |||
@@ -349,7 +349,7 @@ static int __devexit p9100_remove(struct of_device *op) | |||
349 | return 0; | 349 | return 0; |
350 | } | 350 | } |
351 | 351 | ||
352 | static struct of_device_id p9100_match[] = { | 352 | static const struct of_device_id p9100_match[] = { |
353 | { | 353 | { |
354 | .name = "p9100", | 354 | .name = "p9100", |
355 | }, | 355 | }, |
diff --git a/drivers/video/tcx.c b/drivers/video/tcx.c index 2a03f78bbb0d..643afbfe8277 100644 --- a/drivers/video/tcx.c +++ b/drivers/video/tcx.c | |||
@@ -505,7 +505,7 @@ static int __devexit tcx_remove(struct of_device *op) | |||
505 | return 0; | 505 | return 0; |
506 | } | 506 | } |
507 | 507 | ||
508 | static struct of_device_id tcx_match[] = { | 508 | static const struct of_device_id tcx_match[] = { |
509 | { | 509 | { |
510 | .name = "SUNW,tcx", | 510 | .name = "SUNW,tcx", |
511 | }, | 511 | }, |
diff --git a/drivers/video/tdfxfb.c b/drivers/video/tdfxfb.c index 77aafcfae037..4599a4385bc9 100644 --- a/drivers/video/tdfxfb.c +++ b/drivers/video/tdfxfb.c | |||
@@ -95,7 +95,6 @@ static inline int mtrr_del(int reg, unsigned long base, | |||
95 | #define VOODOO5_MAX_PIXCLOCK 350000 | 95 | #define VOODOO5_MAX_PIXCLOCK 350000 |
96 | 96 | ||
97 | static struct fb_fix_screeninfo tdfx_fix __devinitdata = { | 97 | static struct fb_fix_screeninfo tdfx_fix __devinitdata = { |
98 | .id = "3Dfx", | ||
99 | .type = FB_TYPE_PACKED_PIXELS, | 98 | .type = FB_TYPE_PACKED_PIXELS, |
100 | .visual = FB_VISUAL_PSEUDOCOLOR, | 99 | .visual = FB_VISUAL_PSEUDOCOLOR, |
101 | .ypanstep = 1, | 100 | .ypanstep = 1, |
@@ -426,7 +425,7 @@ static unsigned long do_lfb_size(struct tdfx_par *par, unsigned short dev_id) | |||
426 | if (dev_id < PCI_DEVICE_ID_3DFX_VOODOO5) { | 425 | if (dev_id < PCI_DEVICE_ID_3DFX_VOODOO5) { |
427 | /* Banshee/Voodoo3 */ | 426 | /* Banshee/Voodoo3 */ |
428 | chip_size = 2; | 427 | chip_size = 2; |
429 | if (has_sgram && (draminit0 & DRAMINIT0_SGRAM_TYPE)) | 428 | if (has_sgram && !(draminit0 & DRAMINIT0_SGRAM_TYPE)) |
430 | chip_size = 1; | 429 | chip_size = 1; |
431 | } else { | 430 | } else { |
432 | /* Voodoo4/5 */ | 431 | /* Voodoo4/5 */ |
@@ -1200,15 +1199,15 @@ static int __devinit tdfxfb_probe(struct pci_dev *pdev, | |||
1200 | /* Configure the default fb_fix_screeninfo first */ | 1199 | /* Configure the default fb_fix_screeninfo first */ |
1201 | switch (pdev->device) { | 1200 | switch (pdev->device) { |
1202 | case PCI_DEVICE_ID_3DFX_BANSHEE: | 1201 | case PCI_DEVICE_ID_3DFX_BANSHEE: |
1203 | strcat(tdfx_fix.id, " Banshee"); | 1202 | strcpy(tdfx_fix.id, "3Dfx Banshee"); |
1204 | default_par->max_pixclock = BANSHEE_MAX_PIXCLOCK; | 1203 | default_par->max_pixclock = BANSHEE_MAX_PIXCLOCK; |
1205 | break; | 1204 | break; |
1206 | case PCI_DEVICE_ID_3DFX_VOODOO3: | 1205 | case PCI_DEVICE_ID_3DFX_VOODOO3: |
1207 | strcat(tdfx_fix.id, " Voodoo3"); | 1206 | strcpy(tdfx_fix.id, "3Dfx Voodoo3"); |
1208 | default_par->max_pixclock = VOODOO3_MAX_PIXCLOCK; | 1207 | default_par->max_pixclock = VOODOO3_MAX_PIXCLOCK; |
1209 | break; | 1208 | break; |
1210 | case PCI_DEVICE_ID_3DFX_VOODOO5: | 1209 | case PCI_DEVICE_ID_3DFX_VOODOO5: |
1211 | strcat(tdfx_fix.id, " Voodoo5"); | 1210 | strcpy(tdfx_fix.id, "3Dfx Voodoo5"); |
1212 | default_par->max_pixclock = VOODOO5_MAX_PIXCLOCK; | 1211 | default_par->max_pixclock = VOODOO5_MAX_PIXCLOCK; |
1213 | break; | 1212 | break; |
1214 | } | 1213 | } |
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c index 47ed39b52f9c..a463b3dd837b 100644 --- a/drivers/video/xen-fbfront.c +++ b/drivers/video/xen-fbfront.c | |||
@@ -680,11 +680,11 @@ static struct xenbus_driver xenfb = { | |||
680 | 680 | ||
681 | static int __init xenfb_init(void) | 681 | static int __init xenfb_init(void) |
682 | { | 682 | { |
683 | if (!is_running_on_xen()) | 683 | if (!xen_domain()) |
684 | return -ENODEV; | 684 | return -ENODEV; |
685 | 685 | ||
686 | /* Nothing to do if running in dom0. */ | 686 | /* Nothing to do if running in dom0. */ |
687 | if (is_initial_xendomain()) | 687 | if (xen_initial_domain()) |
688 | return -ENODEV; | 688 | return -ENODEV; |
689 | 689 | ||
690 | return xenbus_register_frontend(&xenfb); | 690 | return xenbus_register_frontend(&xenfb); |