aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2012-06-13 04:24:38 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2012-06-13 04:24:38 -0400
commit289733ed456f7c1cbdb1f1ca58312f77c239953b (patch)
tree99bed0a5c21d0bdc5f6c10bc80a1ae8dbbd56be6 /drivers/video
parentc3a21fc79b6bc097d8b0e47498903a649a111127 (diff)
parentcfaf025112d3856637ff34a767ef785ef5cf2ca9 (diff)
Merge tag 'v3.5-rc2'
Merge v3.5-rc2 to get latest device tree and dynamic debug changes.
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/Kconfig35
-rw-r--r--drivers/video/Makefile3
-rw-r--r--drivers/video/au1100fb.c2
-rw-r--r--drivers/video/auo_k1900fb.c198
-rw-r--r--drivers/video/auo_k1901fb.c251
-rw-r--r--drivers/video/auo_k190x.c1046
-rw-r--r--drivers/video/auo_k190x.h129
-rw-r--r--drivers/video/backlight/Kconfig12
-rw-r--r--drivers/video/backlight/Makefile1
-rw-r--r--drivers/video/backlight/adp5520_bl.c4
-rw-r--r--drivers/video/backlight/adp8860_bl.c28
-rw-r--r--drivers/video/backlight/adp8870_bl.c28
-rw-r--r--drivers/video/backlight/ams369fg06.c16
-rw-r--r--drivers/video/backlight/apple_bl.c21
-rw-r--r--drivers/video/backlight/backlight.c11
-rw-r--r--drivers/video/backlight/corgi_lcd.c12
-rw-r--r--drivers/video/backlight/cr_bllcd.c9
-rw-r--r--drivers/video/backlight/da903x_bl.c1
-rw-r--r--drivers/video/backlight/generic_bl.c6
-rw-r--r--drivers/video/backlight/ili9320.c9
-rw-r--r--drivers/video/backlight/jornada720_bl.c14
-rw-r--r--drivers/video/backlight/jornada720_lcd.c8
-rw-r--r--drivers/video/backlight/l4f00242t03.c27
-rw-r--r--drivers/video/backlight/lcd.c20
-rw-r--r--drivers/video/backlight/ld9040.c15
-rw-r--r--drivers/video/backlight/lm3533_bl.c423
-rw-r--r--drivers/video/backlight/lms283gf05.c9
-rw-r--r--drivers/video/backlight/ltv350qv.c24
-rw-r--r--drivers/video/backlight/omap1_bl.c4
-rw-r--r--drivers/video/backlight/pcf50633-backlight.c1
-rw-r--r--drivers/video/backlight/progear_bl.c6
-rw-r--r--drivers/video/backlight/s6e63m0.c16
-rw-r--r--drivers/video/backlight/tdo24m.c21
-rw-r--r--drivers/video/backlight/tosa_bl.c11
-rw-r--r--drivers/video/backlight/tosa_lcd.c8
-rw-r--r--drivers/video/backlight/wm831x_bl.c1
-rw-r--r--drivers/video/bfin-lq035q1-fb.c1
-rw-r--r--drivers/video/bfin_adv7393fb.c43
-rw-r--r--drivers/video/clps711xfb.c1
-rw-r--r--drivers/video/cobalt_lcdfb.c45
-rw-r--r--drivers/video/console/sticore.c2
-rw-r--r--drivers/video/efifb.c79
-rw-r--r--drivers/video/ep93xx-fb.c32
-rw-r--r--drivers/video/exynos/exynos_dp_core.c69
-rw-r--r--drivers/video/exynos/exynos_dp_core.h3
-rw-r--r--drivers/video/exynos/exynos_dp_reg.c45
-rw-r--r--drivers/video/exynos/exynos_dp_reg.h29
-rw-r--r--drivers/video/exynos/exynos_mipi_dsi.c49
-rw-r--r--drivers/video/exynos/exynos_mipi_dsi_common.c36
-rw-r--r--drivers/video/exynos/s6e8ax0.c15
-rw-r--r--drivers/video/fb_defio.c6
-rw-r--r--drivers/video/fbmem.c21
-rw-r--r--drivers/video/fbsysfs.c2
-rw-r--r--drivers/video/fsl-diu-fb.c1
-rw-r--r--drivers/video/imxfb.c50
-rw-r--r--drivers/video/intelfb/intelfbdrv.c2
-rw-r--r--drivers/video/matrox/matroxfb_maven.c1
-rw-r--r--drivers/video/mb862xx/mb862xx-i2c.c2
-rw-r--r--drivers/video/mb862xx/mb862xxfbdrv.c2
-rw-r--r--drivers/video/mbx/mbxfb.c2
-rw-r--r--drivers/video/mxsfb.c22
-rw-r--r--drivers/video/omap2/displays/panel-acx565akm.c1
-rw-r--r--drivers/video/pxa3xx-gcu.c5
-rw-r--r--drivers/video/s3c-fb.c148
-rw-r--r--drivers/video/sh_mobile_hdmi.c219
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c5
-rw-r--r--drivers/video/sh_mobile_lcdcfb.h1
-rw-r--r--drivers/video/sis/init.h45
-rw-r--r--drivers/video/sis/sis_main.c41
-rw-r--r--drivers/video/skeletonfb.c2
-rw-r--r--drivers/video/smscufx.c4
-rw-r--r--drivers/video/udlfb.c4
-rw-r--r--drivers/video/uvesafb.c2
-rw-r--r--drivers/video/via/viafbdev.c34
-rw-r--r--drivers/video/xen-fbfront.c27
75 files changed, 2967 insertions, 561 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index a290be51a1f4..0217f7415ef5 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -2210,7 +2210,7 @@ config FB_XILINX
2210 2210
2211config FB_COBALT 2211config FB_COBALT
2212 tristate "Cobalt server LCD frame buffer support" 2212 tristate "Cobalt server LCD frame buffer support"
2213 depends on FB && MIPS_COBALT 2213 depends on FB && (MIPS_COBALT || MIPS_SEAD3)
2214 2214
2215config FB_SH7760 2215config FB_SH7760
2216 bool "SH7760/SH7763/SH7720/SH7721 LCDC support" 2216 bool "SH7760/SH7763/SH7720/SH7721 LCDC support"
@@ -2382,6 +2382,39 @@ config FB_BROADSHEET
2382 and could also have been called by other names when coupled with 2382 and could also have been called by other names when coupled with
2383 a bridge adapter. 2383 a bridge adapter.
2384 2384
2385config FB_AUO_K190X
2386 tristate "AUO-K190X EPD controller support"
2387 depends on FB
2388 select FB_SYS_FILLRECT
2389 select FB_SYS_COPYAREA
2390 select FB_SYS_IMAGEBLIT
2391 select FB_SYS_FOPS
2392 select FB_DEFERRED_IO
2393 help
2394 Provides support for epaper controllers from the K190X series
2395 of AUO. These controllers can be used to drive epaper displays
2396 from Sipix.
2397
2398 This option enables the common support, shared by the individual
2399 controller drivers. You will also have to enable the driver
2400 for the controller type used in your device.
2401
2402config FB_AUO_K1900
2403 tristate "AUO-K1900 EPD controller support"
2404 depends on FB && FB_AUO_K190X
2405 help
2406 This driver implements support for the AUO K1900 epd-controller.
2407 This controller can drive Sipix epaper displays but can only do
2408 serial updates, reducing the number of possible frames per second.
2409
2410config FB_AUO_K1901
2411 tristate "AUO-K1901 EPD controller support"
2412 depends on FB && FB_AUO_K190X
2413 help
2414 This driver implements support for the AUO K1901 epd-controller.
2415 This controller can drive Sipix epaper displays and supports
2416 concurrent updates, making higher frames per second possible.
2417
2385config FB_JZ4740 2418config FB_JZ4740
2386 tristate "JZ4740 LCD framebuffer support" 2419 tristate "JZ4740 LCD framebuffer support"
2387 depends on FB && MACH_JZ4740 2420 depends on FB && MACH_JZ4740
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 9356add945b3..ee8dafb69e36 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -118,6 +118,9 @@ obj-$(CONFIG_FB_PMAGB_B) += pmagb-b-fb.o
118obj-$(CONFIG_FB_MAXINE) += maxinefb.o 118obj-$(CONFIG_FB_MAXINE) += maxinefb.o
119obj-$(CONFIG_FB_METRONOME) += metronomefb.o 119obj-$(CONFIG_FB_METRONOME) += metronomefb.o
120obj-$(CONFIG_FB_BROADSHEET) += broadsheetfb.o 120obj-$(CONFIG_FB_BROADSHEET) += broadsheetfb.o
121obj-$(CONFIG_FB_AUO_K190X) += auo_k190x.o
122obj-$(CONFIG_FB_AUO_K1900) += auo_k1900fb.o
123obj-$(CONFIG_FB_AUO_K1901) += auo_k1901fb.o
121obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o 124obj-$(CONFIG_FB_S1D13XXX) += s1d13xxxfb.o
122obj-$(CONFIG_FB_SH7760) += sh7760fb.o 125obj-$(CONFIG_FB_SH7760) += sh7760fb.o
123obj-$(CONFIG_FB_IMX) += imxfb.o 126obj-$(CONFIG_FB_IMX) += imxfb.o
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index ffbce4525468..fe3b6ec87122 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -536,7 +536,7 @@ static int __devinit au1100fb_drv_probe(struct platform_device *dev)
536 for (page = (unsigned long)fbdev->fb_mem; 536 for (page = (unsigned long)fbdev->fb_mem;
537 page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len); 537 page < PAGE_ALIGN((unsigned long)fbdev->fb_mem + fbdev->fb_len);
538 page += PAGE_SIZE) { 538 page += PAGE_SIZE) {
539#if CONFIG_DMA_NONCOHERENT 539#ifdef CONFIG_DMA_NONCOHERENT
540 SetPageReserved(virt_to_page(CAC_ADDR((void *)page))); 540 SetPageReserved(virt_to_page(CAC_ADDR((void *)page)));
541#else 541#else
542 SetPageReserved(virt_to_page(page)); 542 SetPageReserved(virt_to_page(page));
diff --git a/drivers/video/auo_k1900fb.c b/drivers/video/auo_k1900fb.c
new file mode 100644
index 000000000000..c36cf961dcb2
--- /dev/null
+++ b/drivers/video/auo_k1900fb.c
@@ -0,0 +1,198 @@
1/*
2 * auok190xfb.c -- FB driver for AUO-K1900 controllers
3 *
4 * Copyright (C) 2011, 2012 Heiko Stuebner <heiko@sntech.de>
5 *
6 * based on broadsheetfb.c
7 *
8 * Copyright (C) 2008, Jaya Kumar
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
15 *
16 * This driver is written to be used with the AUO-K1900 display controller.
17 *
18 * It is intended to be architecture independent. A board specific driver
19 * must be used to perform all the physical IO interactions.
20 *
21 * The controller supports different update modes:
22 * mode0+1 16 step gray (4bit)
23 * mode2 4 step gray (2bit) - FIXME: add strange refresh
24 * mode3 2 step gray (1bit) - FIXME: add strange refresh
25 * mode4 handwriting mode (strange behaviour)
26 * mode5 automatic selection of update mode
27 */
28
29#include <linux/module.h>
30#include <linux/kernel.h>
31#include <linux/errno.h>
32#include <linux/string.h>
33#include <linux/mm.h>
34#include <linux/slab.h>
35#include <linux/delay.h>
36#include <linux/interrupt.h>
37#include <linux/fb.h>
38#include <linux/init.h>
39#include <linux/platform_device.h>
40#include <linux/list.h>
41#include <linux/firmware.h>
42#include <linux/gpio.h>
43#include <linux/pm_runtime.h>
44
45#include <video/auo_k190xfb.h>
46
47#include "auo_k190x.h"
48
49/*
50 * AUO-K1900 specific commands
51 */
52
53#define AUOK1900_CMD_PARTIALDISP 0x1001
54#define AUOK1900_CMD_ROTATION 0x1006
55#define AUOK1900_CMD_LUT_STOP 0x1009
56
57#define AUOK1900_INIT_TEMP_AVERAGE (1 << 13)
58#define AUOK1900_INIT_ROTATE(_x) ((_x & 0x3) << 10)
59#define AUOK1900_INIT_RESOLUTION(_res) ((_res & 0x7) << 2)
60
61static void auok1900_init(struct auok190xfb_par *par)
62{
63 struct auok190x_board *board = par->board;
64 u16 init_param = 0;
65
66 init_param |= AUOK1900_INIT_TEMP_AVERAGE;
67 init_param |= AUOK1900_INIT_ROTATE(par->rotation);
68 init_param |= AUOK190X_INIT_INVERSE_WHITE;
69 init_param |= AUOK190X_INIT_FORMAT0;
70 init_param |= AUOK1900_INIT_RESOLUTION(par->resolution);
71 init_param |= AUOK190X_INIT_SHIFT_RIGHT;
72
73 auok190x_send_cmdargs(par, AUOK190X_CMD_INIT, 1, &init_param);
74
75 /* let the controller finish */
76 board->wait_for_rdy(par);
77}
78
79static void auok1900_update_region(struct auok190xfb_par *par, int mode,
80 u16 y1, u16 y2)
81{
82 struct device *dev = par->info->device;
83 unsigned char *buf = (unsigned char *)par->info->screen_base;
84 int xres = par->info->var.xres;
85 u16 args[4];
86
87 pm_runtime_get_sync(dev);
88
89 mutex_lock(&(par->io_lock));
90
91 /* y1 and y2 must be a multiple of 2 so drop the lowest bit */
92 y1 &= 0xfffe;
93 y2 &= 0xfffe;
94
95 dev_dbg(dev, "update (x,y,w,h,mode)=(%d,%d,%d,%d,%d)\n",
96 1, y1+1, xres, y2-y1, mode);
97
98 /* to FIX handle different partial update modes */
99 args[0] = mode | 1;
100 args[1] = y1 + 1;
101 args[2] = xres;
102 args[3] = y2 - y1;
103 buf += y1 * xres;
104 auok190x_send_cmdargs_pixels(par, AUOK1900_CMD_PARTIALDISP, 4, args,
105 ((y2 - y1) * xres)/2, (u16 *) buf);
106 auok190x_send_command(par, AUOK190X_CMD_DATA_STOP);
107
108 par->update_cnt++;
109
110 mutex_unlock(&(par->io_lock));
111
112 pm_runtime_mark_last_busy(dev);
113 pm_runtime_put_autosuspend(dev);
114}
115
116static void auok1900fb_dpy_update_pages(struct auok190xfb_par *par,
117 u16 y1, u16 y2)
118{
119 int mode;
120
121 if (par->update_mode < 0) {
122 mode = AUOK190X_UPDATE_MODE(1);
123 par->last_mode = -1;
124 } else {
125 mode = AUOK190X_UPDATE_MODE(par->update_mode);
126 par->last_mode = par->update_mode;
127 }
128
129 if (par->flash)
130 mode |= AUOK190X_UPDATE_NONFLASH;
131
132 auok1900_update_region(par, mode, y1, y2);
133}
134
135static void auok1900fb_dpy_update(struct auok190xfb_par *par)
136{
137 int mode;
138
139 if (par->update_mode < 0) {
140 mode = AUOK190X_UPDATE_MODE(0);
141 par->last_mode = -1;
142 } else {
143 mode = AUOK190X_UPDATE_MODE(par->update_mode);
144 par->last_mode = par->update_mode;
145 }
146
147 if (par->flash)
148 mode |= AUOK190X_UPDATE_NONFLASH;
149
150 auok1900_update_region(par, mode, 0, par->info->var.yres);
151 par->update_cnt = 0;
152}
153
154static bool auok1900fb_need_refresh(struct auok190xfb_par *par)
155{
156 return (par->update_cnt > 10);
157}
158
159static int __devinit auok1900fb_probe(struct platform_device *pdev)
160{
161 struct auok190x_init_data init;
162 struct auok190x_board *board;
163
164 /* pick up board specific routines */
165 board = pdev->dev.platform_data;
166 if (!board)
167 return -EINVAL;
168
169 /* fill temporary init struct for common init */
170 init.id = "auo_k1900fb";
171 init.board = board;
172 init.update_partial = auok1900fb_dpy_update_pages;
173 init.update_all = auok1900fb_dpy_update;
174 init.need_refresh = auok1900fb_need_refresh;
175 init.init = auok1900_init;
176
177 return auok190x_common_probe(pdev, &init);
178}
179
180static int __devexit auok1900fb_remove(struct platform_device *pdev)
181{
182 return auok190x_common_remove(pdev);
183}
184
185static struct platform_driver auok1900fb_driver = {
186 .probe = auok1900fb_probe,
187 .remove = __devexit_p(auok1900fb_remove),
188 .driver = {
189 .owner = THIS_MODULE,
190 .name = "auo_k1900fb",
191 .pm = &auok190x_pm,
192 },
193};
194module_platform_driver(auok1900fb_driver);
195
196MODULE_DESCRIPTION("framebuffer driver for the AUO-K1900 EPD controller");
197MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
198MODULE_LICENSE("GPL");
diff --git a/drivers/video/auo_k1901fb.c b/drivers/video/auo_k1901fb.c
new file mode 100644
index 000000000000..1c054c18616e
--- /dev/null
+++ b/drivers/video/auo_k1901fb.c
@@ -0,0 +1,251 @@
1/*
2 * auok190xfb.c -- FB driver for AUO-K1901 controllers
3 *
4 * Copyright (C) 2011, 2012 Heiko Stuebner <heiko@sntech.de>
5 *
6 * based on broadsheetfb.c
7 *
8 * Copyright (C) 2008, Jaya Kumar
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
15 *
16 * This driver is written to be used with the AUO-K1901 display controller.
17 *
18 * It is intended to be architecture independent. A board specific driver
19 * must be used to perform all the physical IO interactions.
20 *
21 * The controller supports different update modes:
22 * mode0+1 16 step gray (4bit)
23 * mode2+3 4 step gray (2bit)
24 * mode4+5 2 step gray (1bit)
25 * - mode4 is described as "without LUT"
26 * mode7 automatic selection of update mode
27 *
28 * The most interesting difference to the K1900 is the ability to do screen
29 * updates in an asynchronous fashion. Where the K1900 needs to wait for the
30 * current update to complete, the K1901 can process later updates already.
31 */
32
33#include <linux/module.h>
34#include <linux/kernel.h>
35#include <linux/errno.h>
36#include <linux/string.h>
37#include <linux/mm.h>
38#include <linux/slab.h>
39#include <linux/delay.h>
40#include <linux/interrupt.h>
41#include <linux/fb.h>
42#include <linux/init.h>
43#include <linux/platform_device.h>
44#include <linux/list.h>
45#include <linux/firmware.h>
46#include <linux/gpio.h>
47#include <linux/pm_runtime.h>
48
49#include <video/auo_k190xfb.h>
50
51#include "auo_k190x.h"
52
53/*
54 * AUO-K1901 specific commands
55 */
56
57#define AUOK1901_CMD_LUT_INTERFACE 0x0005
58#define AUOK1901_CMD_DMA_START 0x1001
59#define AUOK1901_CMD_CURSOR_START 0x1007
60#define AUOK1901_CMD_CURSOR_STOP AUOK190X_CMD_DATA_STOP
61#define AUOK1901_CMD_DDMA_START 0x1009
62
63#define AUOK1901_INIT_GATE_PULSE_LOW (0 << 14)
64#define AUOK1901_INIT_GATE_PULSE_HIGH (1 << 14)
65#define AUOK1901_INIT_SINGLE_GATE (0 << 13)
66#define AUOK1901_INIT_DOUBLE_GATE (1 << 13)
67
68/* Bits to pixels
69 * Mode 15-12 11-8 7-4 3-0
70 * format2 2 T 1 T
71 * format3 1 T 2 T
72 * format4 T 2 T 1
73 * format5 T 1 T 2
74 *
75 * halftone modes:
76 * format6 2 2 1 1
77 * format7 1 1 2 2
78 */
79#define AUOK1901_INIT_FORMAT2 (1 << 7)
80#define AUOK1901_INIT_FORMAT3 ((1 << 7) | (1 << 6))
81#define AUOK1901_INIT_FORMAT4 (1 << 8)
82#define AUOK1901_INIT_FORMAT5 ((1 << 8) | (1 << 6))
83#define AUOK1901_INIT_FORMAT6 ((1 << 8) | (1 << 7))
84#define AUOK1901_INIT_FORMAT7 ((1 << 8) | (1 << 7) | (1 << 6))
85
86/* res[4] to bit 10
87 * res[3-0] to bits 5-2
88 */
89#define AUOK1901_INIT_RESOLUTION(_res) (((_res & (1 << 4)) << 6) \
90 | ((_res & 0xf) << 2))
91
92/*
93 * portrait / landscape orientation in AUOK1901_CMD_DMA_START
94 */
95#define AUOK1901_DMA_ROTATE90(_rot) ((_rot & 1) << 13)
96
97/*
98 * equivalent to 1 << 11, needs the ~ to have same rotation like K1900
99 */
100#define AUOK1901_DDMA_ROTATE180(_rot) ((~_rot & 2) << 10)
101
102static void auok1901_init(struct auok190xfb_par *par)
103{
104 struct auok190x_board *board = par->board;
105 u16 init_param = 0;
106
107 init_param |= AUOK190X_INIT_INVERSE_WHITE;
108 init_param |= AUOK190X_INIT_FORMAT0;
109 init_param |= AUOK1901_INIT_RESOLUTION(par->resolution);
110 init_param |= AUOK190X_INIT_SHIFT_LEFT;
111
112 auok190x_send_cmdargs(par, AUOK190X_CMD_INIT, 1, &init_param);
113
114 /* let the controller finish */
115 board->wait_for_rdy(par);
116}
117
118static void auok1901_update_region(struct auok190xfb_par *par, int mode,
119 u16 y1, u16 y2)
120{
121 struct device *dev = par->info->device;
122 unsigned char *buf = (unsigned char *)par->info->screen_base;
123 int xres = par->info->var.xres;
124 u16 args[5];
125
126 pm_runtime_get_sync(dev);
127
128 mutex_lock(&(par->io_lock));
129
130 /* y1 and y2 must be a multiple of 2 so drop the lowest bit */
131 y1 &= 0xfffe;
132 y2 &= 0xfffe;
133
134 dev_dbg(dev, "update (x,y,w,h,mode)=(%d,%d,%d,%d,%d)\n",
135 1, y1+1, xres, y2-y1, mode);
136
137 /* K1901: first transfer the region data */
138 args[0] = AUOK1901_DMA_ROTATE90(par->rotation) | 1;
139 args[1] = y1 + 1;
140 args[2] = xres;
141 args[3] = y2 - y1;
142 buf += y1 * xres;
143 auok190x_send_cmdargs_pixels_nowait(par, AUOK1901_CMD_DMA_START, 4,
144 args, ((y2 - y1) * xres)/2,
145 (u16 *) buf);
146 auok190x_send_command_nowait(par, AUOK190X_CMD_DATA_STOP);
147
148 /* K1901: second tell the controller to update the region with mode */
149 args[0] = mode | AUOK1901_DDMA_ROTATE180(par->rotation);
150 args[1] = 1;
151 args[2] = y1 + 1;
152 args[3] = xres;
153 args[4] = y2 - y1;
154 auok190x_send_cmdargs_nowait(par, AUOK1901_CMD_DDMA_START, 5, args);
155
156 par->update_cnt++;
157
158 mutex_unlock(&(par->io_lock));
159
160 pm_runtime_mark_last_busy(dev);
161 pm_runtime_put_autosuspend(dev);
162}
163
164static void auok1901fb_dpy_update_pages(struct auok190xfb_par *par,
165 u16 y1, u16 y2)
166{
167 int mode;
168
169 if (par->update_mode < 0) {
170 mode = AUOK190X_UPDATE_MODE(1);
171 par->last_mode = -1;
172 } else {
173 mode = AUOK190X_UPDATE_MODE(par->update_mode);
174 par->last_mode = par->update_mode;
175 }
176
177 if (par->flash)
178 mode |= AUOK190X_UPDATE_NONFLASH;
179
180 auok1901_update_region(par, mode, y1, y2);
181}
182
183static void auok1901fb_dpy_update(struct auok190xfb_par *par)
184{
185 int mode;
186
187 /* When doing full updates, wait for the controller to be ready
188 * This will hopefully catch some hangs of the K1901
189 */
190 par->board->wait_for_rdy(par);
191
192 if (par->update_mode < 0) {
193 mode = AUOK190X_UPDATE_MODE(0);
194 par->last_mode = -1;
195 } else {
196 mode = AUOK190X_UPDATE_MODE(par->update_mode);
197 par->last_mode = par->update_mode;
198 }
199
200 if (par->flash)
201 mode |= AUOK190X_UPDATE_NONFLASH;
202
203 auok1901_update_region(par, mode, 0, par->info->var.yres);
204 par->update_cnt = 0;
205}
206
207static bool auok1901fb_need_refresh(struct auok190xfb_par *par)
208{
209 return (par->update_cnt > 10);
210}
211
212static int __devinit auok1901fb_probe(struct platform_device *pdev)
213{
214 struct auok190x_init_data init;
215 struct auok190x_board *board;
216
217 /* pick up board specific routines */
218 board = pdev->dev.platform_data;
219 if (!board)
220 return -EINVAL;
221
222 /* fill temporary init struct for common init */
223 init.id = "auo_k1901fb";
224 init.board = board;
225 init.update_partial = auok1901fb_dpy_update_pages;
226 init.update_all = auok1901fb_dpy_update;
227 init.need_refresh = auok1901fb_need_refresh;
228 init.init = auok1901_init;
229
230 return auok190x_common_probe(pdev, &init);
231}
232
233static int __devexit auok1901fb_remove(struct platform_device *pdev)
234{
235 return auok190x_common_remove(pdev);
236}
237
238static struct platform_driver auok1901fb_driver = {
239 .probe = auok1901fb_probe,
240 .remove = __devexit_p(auok1901fb_remove),
241 .driver = {
242 .owner = THIS_MODULE,
243 .name = "auo_k1901fb",
244 .pm = &auok190x_pm,
245 },
246};
247module_platform_driver(auok1901fb_driver);
248
249MODULE_DESCRIPTION("framebuffer driver for the AUO-K1901 EPD controller");
250MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
251MODULE_LICENSE("GPL");
diff --git a/drivers/video/auo_k190x.c b/drivers/video/auo_k190x.c
new file mode 100644
index 000000000000..77da6a2f43dc
--- /dev/null
+++ b/drivers/video/auo_k190x.c
@@ -0,0 +1,1046 @@
1/*
2 * Common code for AUO-K190X framebuffer drivers
3 *
4 * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/module.h>
12#include <linux/kernel.h>
13#include <linux/gpio.h>
14#include <linux/pm_runtime.h>
15#include <linux/fb.h>
16#include <linux/delay.h>
17#include <linux/uaccess.h>
18#include <linux/vmalloc.h>
19#include <linux/regulator/consumer.h>
20
21#include <video/auo_k190xfb.h>
22
23#include "auo_k190x.h"
24
25struct panel_info {
26 int w;
27 int h;
28};
29
30/* table of panel specific parameters to be indexed into by the board drivers */
31static struct panel_info panel_table[] = {
32 /* standard 6" */
33 [AUOK190X_RESOLUTION_800_600] = {
34 .w = 800,
35 .h = 600,
36 },
37 /* standard 9" */
38 [AUOK190X_RESOLUTION_1024_768] = {
39 .w = 1024,
40 .h = 768,
41 },
42};
43
44/*
45 * private I80 interface to the board driver
46 */
47
48static void auok190x_issue_data(struct auok190xfb_par *par, u16 data)
49{
50 par->board->set_ctl(par, AUOK190X_I80_WR, 0);
51 par->board->set_hdb(par, data);
52 par->board->set_ctl(par, AUOK190X_I80_WR, 1);
53}
54
55static void auok190x_issue_cmd(struct auok190xfb_par *par, u16 data)
56{
57 par->board->set_ctl(par, AUOK190X_I80_DC, 0);
58 auok190x_issue_data(par, data);
59 par->board->set_ctl(par, AUOK190X_I80_DC, 1);
60}
61
62static int auok190x_issue_pixels(struct auok190xfb_par *par, int size,
63 u16 *data)
64{
65 struct device *dev = par->info->device;
66 int i;
67 u16 tmp;
68
69 if (size & 3) {
70 dev_err(dev, "issue_pixels: size %d must be a multiple of 4\n",
71 size);
72 return -EINVAL;
73 }
74
75 for (i = 0; i < (size >> 1); i++) {
76 par->board->set_ctl(par, AUOK190X_I80_WR, 0);
77
78 /* simple reduction of 8bit staticgray to 4bit gray
79 * combines 4 * 4bit pixel values into a 16bit value
80 */
81 tmp = (data[2*i] & 0xF0) >> 4;
82 tmp |= (data[2*i] & 0xF000) >> 8;
83 tmp |= (data[2*i+1] & 0xF0) << 4;
84 tmp |= (data[2*i+1] & 0xF000);
85
86 par->board->set_hdb(par, tmp);
87 par->board->set_ctl(par, AUOK190X_I80_WR, 1);
88 }
89
90 return 0;
91}
92
93static u16 auok190x_read_data(struct auok190xfb_par *par)
94{
95 u16 data;
96
97 par->board->set_ctl(par, AUOK190X_I80_OE, 0);
98 data = par->board->get_hdb(par);
99 par->board->set_ctl(par, AUOK190X_I80_OE, 1);
100
101 return data;
102}
103
104/*
105 * Command interface for the controller drivers
106 */
107
108void auok190x_send_command_nowait(struct auok190xfb_par *par, u16 data)
109{
110 par->board->set_ctl(par, AUOK190X_I80_CS, 0);
111 auok190x_issue_cmd(par, data);
112 par->board->set_ctl(par, AUOK190X_I80_CS, 1);
113}
114EXPORT_SYMBOL_GPL(auok190x_send_command_nowait);
115
116void auok190x_send_cmdargs_nowait(struct auok190xfb_par *par, u16 cmd,
117 int argc, u16 *argv)
118{
119 int i;
120
121 par->board->set_ctl(par, AUOK190X_I80_CS, 0);
122 auok190x_issue_cmd(par, cmd);
123
124 for (i = 0; i < argc; i++)
125 auok190x_issue_data(par, argv[i]);
126 par->board->set_ctl(par, AUOK190X_I80_CS, 1);
127}
128EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_nowait);
129
130int auok190x_send_command(struct auok190xfb_par *par, u16 data)
131{
132 int ret;
133
134 ret = par->board->wait_for_rdy(par);
135 if (ret)
136 return ret;
137
138 auok190x_send_command_nowait(par, data);
139 return 0;
140}
141EXPORT_SYMBOL_GPL(auok190x_send_command);
142
143int auok190x_send_cmdargs(struct auok190xfb_par *par, u16 cmd,
144 int argc, u16 *argv)
145{
146 int ret;
147
148 ret = par->board->wait_for_rdy(par);
149 if (ret)
150 return ret;
151
152 auok190x_send_cmdargs_nowait(par, cmd, argc, argv);
153 return 0;
154}
155EXPORT_SYMBOL_GPL(auok190x_send_cmdargs);
156
157int auok190x_read_cmdargs(struct auok190xfb_par *par, u16 cmd,
158 int argc, u16 *argv)
159{
160 int i, ret;
161
162 ret = par->board->wait_for_rdy(par);
163 if (ret)
164 return ret;
165
166 par->board->set_ctl(par, AUOK190X_I80_CS, 0);
167 auok190x_issue_cmd(par, cmd);
168
169 for (i = 0; i < argc; i++)
170 argv[i] = auok190x_read_data(par);
171 par->board->set_ctl(par, AUOK190X_I80_CS, 1);
172
173 return 0;
174}
175EXPORT_SYMBOL_GPL(auok190x_read_cmdargs);
176
177void auok190x_send_cmdargs_pixels_nowait(struct auok190xfb_par *par, u16 cmd,
178 int argc, u16 *argv, int size, u16 *data)
179{
180 int i;
181
182 par->board->set_ctl(par, AUOK190X_I80_CS, 0);
183
184 auok190x_issue_cmd(par, cmd);
185
186 for (i = 0; i < argc; i++)
187 auok190x_issue_data(par, argv[i]);
188
189 auok190x_issue_pixels(par, size, data);
190
191 par->board->set_ctl(par, AUOK190X_I80_CS, 1);
192}
193EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels_nowait);
194
195int auok190x_send_cmdargs_pixels(struct auok190xfb_par *par, u16 cmd,
196 int argc, u16 *argv, int size, u16 *data)
197{
198 int ret;
199
200 ret = par->board->wait_for_rdy(par);
201 if (ret)
202 return ret;
203
204 auok190x_send_cmdargs_pixels_nowait(par, cmd, argc, argv, size, data);
205
206 return 0;
207}
208EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels);
209
210/*
211 * fbdefio callbacks - common on both controllers.
212 */
213
214static void auok190xfb_dpy_first_io(struct fb_info *info)
215{
216 /* tell runtime-pm that we wish to use the device in a short time */
217 pm_runtime_get(info->device);
218}
219
220/* this is called back from the deferred io workqueue */
221static void auok190xfb_dpy_deferred_io(struct fb_info *info,
222 struct list_head *pagelist)
223{
224 struct fb_deferred_io *fbdefio = info->fbdefio;
225 struct auok190xfb_par *par = info->par;
226 u16 yres = info->var.yres;
227 u16 xres = info->var.xres;
228 u16 y1 = 0, h = 0;
229 int prev_index = -1;
230 struct page *cur;
231 int h_inc;
232 int threshold;
233
234 if (!list_empty(pagelist))
235 /* the device resume should've been requested through first_io,
236 * if the resume did not finish until now, wait for it.
237 */
238 pm_runtime_barrier(info->device);
239 else
240 /* We reached this via the fsync or some other way.
241 * In either case the first_io function did not run,
242 * so we runtime_resume the device here synchronously.
243 */
244 pm_runtime_get_sync(info->device);
245
246 /* Do a full screen update every n updates to prevent
247 * excessive darkening of the Sipix display.
248 * If we do this, there is no need to walk the pages.
249 */
250 if (par->need_refresh(par)) {
251 par->update_all(par);
252 goto out;
253 }
254
255 /* height increment is fixed per page */
256 h_inc = DIV_ROUND_UP(PAGE_SIZE , xres);
257
258 /* calculate number of pages from pixel height */
259 threshold = par->consecutive_threshold / h_inc;
260 if (threshold < 1)
261 threshold = 1;
262
263 /* walk the written page list and swizzle the data */
264 list_for_each_entry(cur, &fbdefio->pagelist, lru) {
265 if (prev_index < 0) {
266 /* just starting so assign first page */
267 y1 = (cur->index << PAGE_SHIFT) / xres;
268 h = h_inc;
269 } else if ((cur->index - prev_index) <= threshold) {
270 /* page is within our threshold for single updates */
271 h += h_inc * (cur->index - prev_index);
272 } else {
273 /* page not consecutive, issue previous update first */
274 par->update_partial(par, y1, y1 + h);
275
276 /* start over with our non consecutive page */
277 y1 = (cur->index << PAGE_SHIFT) / xres;
278 h = h_inc;
279 }
280 prev_index = cur->index;
281 }
282
283 /* if we still have any pages to update we do so now */
284 if (h >= yres)
285 /* its a full screen update, just do it */
286 par->update_all(par);
287 else
288 par->update_partial(par, y1, min((u16) (y1 + h), yres));
289
290out:
291 pm_runtime_mark_last_busy(info->device);
292 pm_runtime_put_autosuspend(info->device);
293}
294
295/*
296 * framebuffer operations
297 */
298
299/*
300 * this is the slow path from userspace. they can seek and write to
301 * the fb. it's inefficient to do anything less than a full screen draw
302 */
303static ssize_t auok190xfb_write(struct fb_info *info, const char __user *buf,
304 size_t count, loff_t *ppos)
305{
306 struct auok190xfb_par *par = info->par;
307 unsigned long p = *ppos;
308 void *dst;
309 int err = 0;
310 unsigned long total_size;
311
312 if (info->state != FBINFO_STATE_RUNNING)
313 return -EPERM;
314
315 total_size = info->fix.smem_len;
316
317 if (p > total_size)
318 return -EFBIG;
319
320 if (count > total_size) {
321 err = -EFBIG;
322 count = total_size;
323 }
324
325 if (count + p > total_size) {
326 if (!err)
327 err = -ENOSPC;
328
329 count = total_size - p;
330 }
331
332 dst = (void *)(info->screen_base + p);
333
334 if (copy_from_user(dst, buf, count))
335 err = -EFAULT;
336
337 if (!err)
338 *ppos += count;
339
340 par->update_all(par);
341
342 return (err) ? err : count;
343}
344
345static void auok190xfb_fillrect(struct fb_info *info,
346 const struct fb_fillrect *rect)
347{
348 struct auok190xfb_par *par = info->par;
349
350 sys_fillrect(info, rect);
351
352 par->update_all(par);
353}
354
355static void auok190xfb_copyarea(struct fb_info *info,
356 const struct fb_copyarea *area)
357{
358 struct auok190xfb_par *par = info->par;
359
360 sys_copyarea(info, area);
361
362 par->update_all(par);
363}
364
365static void auok190xfb_imageblit(struct fb_info *info,
366 const struct fb_image *image)
367{
368 struct auok190xfb_par *par = info->par;
369
370 sys_imageblit(info, image);
371
372 par->update_all(par);
373}
374
375static int auok190xfb_check_var(struct fb_var_screeninfo *var,
376 struct fb_info *info)
377{
378 if (info->var.xres != var->xres || info->var.yres != var->yres ||
379 info->var.xres_virtual != var->xres_virtual ||
380 info->var.yres_virtual != var->yres_virtual) {
381 pr_info("%s: Resolution not supported: X%u x Y%u\n",
382 __func__, var->xres, var->yres);
383 return -EINVAL;
384 }
385
386 /*
387 * Memory limit
388 */
389
390 if ((info->fix.line_length * var->yres_virtual) > info->fix.smem_len) {
391 pr_info("%s: Memory Limit requested yres_virtual = %u\n",
392 __func__, var->yres_virtual);
393 return -ENOMEM;
394 }
395
396 return 0;
397}
398
399static struct fb_ops auok190xfb_ops = {
400 .owner = THIS_MODULE,
401 .fb_read = fb_sys_read,
402 .fb_write = auok190xfb_write,
403 .fb_fillrect = auok190xfb_fillrect,
404 .fb_copyarea = auok190xfb_copyarea,
405 .fb_imageblit = auok190xfb_imageblit,
406 .fb_check_var = auok190xfb_check_var,
407};
408
409/*
410 * Controller-functions common to both K1900 and K1901
411 */
412
413static int auok190x_read_temperature(struct auok190xfb_par *par)
414{
415 struct device *dev = par->info->device;
416 u16 data[4];
417 int temp;
418
419 pm_runtime_get_sync(dev);
420
421 mutex_lock(&(par->io_lock));
422
423 auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data);
424
425 mutex_unlock(&(par->io_lock));
426
427 pm_runtime_mark_last_busy(dev);
428 pm_runtime_put_autosuspend(dev);
429
430 /* sanitize and split of half-degrees for now */
431 temp = ((data[0] & AUOK190X_VERSION_TEMP_MASK) >> 1);
432
433 /* handle positive and negative temperatures */
434 if (temp >= 201)
435 return (255 - temp + 1) * (-1);
436 else
437 return temp;
438}
439
440static void auok190x_identify(struct auok190xfb_par *par)
441{
442 struct device *dev = par->info->device;
443 u16 data[4];
444
445 pm_runtime_get_sync(dev);
446
447 mutex_lock(&(par->io_lock));
448
449 auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data);
450
451 mutex_unlock(&(par->io_lock));
452
453 par->epd_type = data[1] & AUOK190X_VERSION_TEMP_MASK;
454
455 par->panel_size_int = AUOK190X_VERSION_SIZE_INT(data[2]);
456 par->panel_size_float = AUOK190X_VERSION_SIZE_FLOAT(data[2]);
457 par->panel_model = AUOK190X_VERSION_MODEL(data[2]);
458
459 par->tcon_version = AUOK190X_VERSION_TCON(data[3]);
460 par->lut_version = AUOK190X_VERSION_LUT(data[3]);
461
462 dev_dbg(dev, "panel %d.%din, model 0x%x, EPD 0x%x TCON-rev 0x%x, LUT-rev 0x%x",
463 par->panel_size_int, par->panel_size_float, par->panel_model,
464 par->epd_type, par->tcon_version, par->lut_version);
465
466 pm_runtime_mark_last_busy(dev);
467 pm_runtime_put_autosuspend(dev);
468}
469
470/*
471 * Sysfs functions
472 */
473
474static ssize_t update_mode_show(struct device *dev,
475 struct device_attribute *attr, char *buf)
476{
477 struct fb_info *info = dev_get_drvdata(dev);
478 struct auok190xfb_par *par = info->par;
479
480 return sprintf(buf, "%d\n", par->update_mode);
481}
482
483static ssize_t update_mode_store(struct device *dev,
484 struct device_attribute *attr,
485 const char *buf, size_t count)
486{
487 struct fb_info *info = dev_get_drvdata(dev);
488 struct auok190xfb_par *par = info->par;
489 int mode, ret;
490
491 ret = kstrtoint(buf, 10, &mode);
492 if (ret)
493 return ret;
494
495 par->update_mode = mode;
496
497 /* if we enter a better mode, do a full update */
498 if (par->last_mode > 1 && mode < par->last_mode)
499 par->update_all(par);
500
501 return count;
502}
503
504static ssize_t flash_show(struct device *dev, struct device_attribute *attr,
505 char *buf)
506{
507 struct fb_info *info = dev_get_drvdata(dev);
508 struct auok190xfb_par *par = info->par;
509
510 return sprintf(buf, "%d\n", par->flash);
511}
512
513static ssize_t flash_store(struct device *dev, struct device_attribute *attr,
514 const char *buf, size_t count)
515{
516 struct fb_info *info = dev_get_drvdata(dev);
517 struct auok190xfb_par *par = info->par;
518 int flash, ret;
519
520 ret = kstrtoint(buf, 10, &flash);
521 if (ret)
522 return ret;
523
524 if (flash > 0)
525 par->flash = 1;
526 else
527 par->flash = 0;
528
529 return count;
530}
531
532static ssize_t temp_show(struct device *dev, struct device_attribute *attr,
533 char *buf)
534{
535 struct fb_info *info = dev_get_drvdata(dev);
536 struct auok190xfb_par *par = info->par;
537 int temp;
538
539 temp = auok190x_read_temperature(par);
540 return sprintf(buf, "%d\n", temp);
541}
542
543static DEVICE_ATTR(update_mode, 0644, update_mode_show, update_mode_store);
544static DEVICE_ATTR(flash, 0644, flash_show, flash_store);
545static DEVICE_ATTR(temp, 0644, temp_show, NULL);
546
547static struct attribute *auok190x_attributes[] = {
548 &dev_attr_update_mode.attr,
549 &dev_attr_flash.attr,
550 &dev_attr_temp.attr,
551 NULL
552};
553
554static const struct attribute_group auok190x_attr_group = {
555 .attrs = auok190x_attributes,
556};
557
558static int auok190x_power(struct auok190xfb_par *par, bool on)
559{
560 struct auok190x_board *board = par->board;
561 int ret;
562
563 if (on) {
564 /* We should maintain POWER up for at least 80ms before set
565 * RST_N and SLP_N to high (TCON spec 20100803_v35 p59)
566 */
567 ret = regulator_enable(par->regulator);
568 if (ret)
569 return ret;
570
571 msleep(200);
572 gpio_set_value(board->gpio_nrst, 1);
573 gpio_set_value(board->gpio_nsleep, 1);
574 msleep(200);
575 } else {
576 regulator_disable(par->regulator);
577 gpio_set_value(board->gpio_nrst, 0);
578 gpio_set_value(board->gpio_nsleep, 0);
579 }
580
581 return 0;
582}
583
584/*
585 * Recovery - powercycle the controller
586 */
587
588static void auok190x_recover(struct auok190xfb_par *par)
589{
590 auok190x_power(par, 0);
591 msleep(100);
592 auok190x_power(par, 1);
593
594 par->init(par);
595
596 /* wait for init to complete */
597 par->board->wait_for_rdy(par);
598}
599
600/*
601 * Power-management
602 */
603
604#ifdef CONFIG_PM
605static int auok190x_runtime_suspend(struct device *dev)
606{
607 struct platform_device *pdev = to_platform_device(dev);
608 struct fb_info *info = platform_get_drvdata(pdev);
609 struct auok190xfb_par *par = info->par;
610 struct auok190x_board *board = par->board;
611 u16 standby_param;
612
613 /* take and keep the lock until we are resumed, as the controller
614 * will never reach the non-busy state when in standby mode
615 */
616 mutex_lock(&(par->io_lock));
617
618 if (par->standby) {
619 dev_warn(dev, "already in standby, runtime-pm pairing mismatch\n");
620 mutex_unlock(&(par->io_lock));
621 return 0;
622 }
623
624 /* according to runtime_pm.txt runtime_suspend only means, that the
625 * device will not process data and will not communicate with the CPU
626 * As we hold the lock, this stays true even without standby
627 */
628 if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
629 dev_dbg(dev, "runtime suspend without standby\n");
630 goto finish;
631 } else if (board->quirks & AUOK190X_QUIRK_STANDBYPARAM) {
632 /* for some TCON versions STANDBY expects a parameter (0) but
633 * it seems the real tcon version has to be determined yet.
634 */
635 dev_dbg(dev, "runtime suspend with additional empty param\n");
636 standby_param = 0;
637 auok190x_send_cmdargs(par, AUOK190X_CMD_STANDBY, 1,
638 &standby_param);
639 } else {
640 dev_dbg(dev, "runtime suspend without param\n");
641 auok190x_send_command(par, AUOK190X_CMD_STANDBY);
642 }
643
644 msleep(64);
645
646finish:
647 par->standby = 1;
648
649 return 0;
650}
651
652static int auok190x_runtime_resume(struct device *dev)
653{
654 struct platform_device *pdev = to_platform_device(dev);
655 struct fb_info *info = platform_get_drvdata(pdev);
656 struct auok190xfb_par *par = info->par;
657 struct auok190x_board *board = par->board;
658
659 if (!par->standby) {
660 dev_warn(dev, "not in standby, runtime-pm pairing mismatch\n");
661 return 0;
662 }
663
664 if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
665 dev_dbg(dev, "runtime resume without standby\n");
666 } else {
667 /* when in standby, controller is always busy
668 * and only accepts the wakeup command
669 */
670 dev_dbg(dev, "runtime resume from standby\n");
671 auok190x_send_command_nowait(par, AUOK190X_CMD_WAKEUP);
672
673 msleep(160);
674
675 /* wait for the controller to be ready and release the lock */
676 board->wait_for_rdy(par);
677 }
678
679 par->standby = 0;
680
681 mutex_unlock(&(par->io_lock));
682
683 return 0;
684}
685
686static int auok190x_suspend(struct device *dev)
687{
688 struct platform_device *pdev = to_platform_device(dev);
689 struct fb_info *info = platform_get_drvdata(pdev);
690 struct auok190xfb_par *par = info->par;
691 struct auok190x_board *board = par->board;
692 int ret;
693
694 dev_dbg(dev, "suspend\n");
695 if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
696 /* suspend via powering off the ic */
697 dev_dbg(dev, "suspend with broken standby\n");
698
699 auok190x_power(par, 0);
700 } else {
701 dev_dbg(dev, "suspend using sleep\n");
702
703 /* the sleep state can only be entered from the standby state.
704 * pm_runtime_get_noresume gets called before the suspend call.
705 * So the devices usage count is >0 but it is not necessarily
706 * active.
707 */
708 if (!pm_runtime_status_suspended(dev)) {
709 ret = auok190x_runtime_suspend(dev);
710 if (ret < 0) {
711 dev_err(dev, "auok190x_runtime_suspend failed with %d\n",
712 ret);
713 return ret;
714 }
715 par->manual_standby = 1;
716 }
717
718 gpio_direction_output(board->gpio_nsleep, 0);
719 }
720
721 msleep(100);
722
723 return 0;
724}
725
726static int auok190x_resume(struct device *dev)
727{
728 struct platform_device *pdev = to_platform_device(dev);
729 struct fb_info *info = platform_get_drvdata(pdev);
730 struct auok190xfb_par *par = info->par;
731 struct auok190x_board *board = par->board;
732
733 dev_dbg(dev, "resume\n");
734 if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
735 dev_dbg(dev, "resume with broken standby\n");
736
737 auok190x_power(par, 1);
738
739 par->init(par);
740 } else {
741 dev_dbg(dev, "resume from sleep\n");
742
743 /* device should be in runtime suspend when we were suspended
744 * and pm_runtime_put_sync gets called after this function.
745 * So there is no need to touch the standby mode here at all.
746 */
747 gpio_direction_output(board->gpio_nsleep, 1);
748 msleep(100);
749
750 /* an additional init call seems to be necessary after sleep */
751 auok190x_runtime_resume(dev);
752 par->init(par);
753
754 /* if we were runtime-suspended before, suspend again*/
755 if (!par->manual_standby)
756 auok190x_runtime_suspend(dev);
757 else
758 par->manual_standby = 0;
759 }
760
761 return 0;
762}
763#endif
764
765const struct dev_pm_ops auok190x_pm = {
766 SET_RUNTIME_PM_OPS(auok190x_runtime_suspend, auok190x_runtime_resume,
767 NULL)
768 SET_SYSTEM_SLEEP_PM_OPS(auok190x_suspend, auok190x_resume)
769};
770EXPORT_SYMBOL_GPL(auok190x_pm);
771
772/*
773 * Common probe and remove code
774 */
775
776int __devinit auok190x_common_probe(struct platform_device *pdev,
777 struct auok190x_init_data *init)
778{
779 struct auok190x_board *board = init->board;
780 struct auok190xfb_par *par;
781 struct fb_info *info;
782 struct panel_info *panel;
783 int videomemorysize, ret;
784 unsigned char *videomemory;
785
786 /* check board contents */
787 if (!board->init || !board->cleanup || !board->wait_for_rdy
788 || !board->set_ctl || !board->set_hdb || !board->get_hdb
789 || !board->setup_irq)
790 return -EINVAL;
791
792 info = framebuffer_alloc(sizeof(struct auok190xfb_par), &pdev->dev);
793 if (!info)
794 return -ENOMEM;
795
796 par = info->par;
797 par->info = info;
798 par->board = board;
799 par->recover = auok190x_recover;
800 par->update_partial = init->update_partial;
801 par->update_all = init->update_all;
802 par->need_refresh = init->need_refresh;
803 par->init = init->init;
804
805 /* init update modes */
806 par->update_cnt = 0;
807 par->update_mode = -1;
808 par->last_mode = -1;
809 par->flash = 0;
810
811 par->regulator = regulator_get(info->device, "vdd");
812 if (IS_ERR(par->regulator)) {
813 ret = PTR_ERR(par->regulator);
814 dev_err(info->device, "Failed to get regulator: %d\n", ret);
815 goto err_reg;
816 }
817
818 ret = board->init(par);
819 if (ret) {
820 dev_err(info->device, "board init failed, %d\n", ret);
821 goto err_board;
822 }
823
824 ret = gpio_request(board->gpio_nsleep, "AUOK190x sleep");
825 if (ret) {
826 dev_err(info->device, "could not request sleep gpio, %d\n",
827 ret);
828 goto err_gpio1;
829 }
830
831 ret = gpio_direction_output(board->gpio_nsleep, 0);
832 if (ret) {
833 dev_err(info->device, "could not set sleep gpio, %d\n", ret);
834 goto err_gpio2;
835 }
836
837 ret = gpio_request(board->gpio_nrst, "AUOK190x reset");
838 if (ret) {
839 dev_err(info->device, "could not request reset gpio, %d\n",
840 ret);
841 goto err_gpio2;
842 }
843
844 ret = gpio_direction_output(board->gpio_nrst, 0);
845 if (ret) {
846 dev_err(info->device, "could not set reset gpio, %d\n", ret);
847 goto err_gpio3;
848 }
849
850 ret = auok190x_power(par, 1);
851 if (ret) {
852 dev_err(info->device, "could not power on the device, %d\n",
853 ret);
854 goto err_gpio3;
855 }
856
857 mutex_init(&par->io_lock);
858
859 init_waitqueue_head(&par->waitq);
860
861 ret = par->board->setup_irq(par->info);
862 if (ret) {
863 dev_err(info->device, "could not setup ready-irq, %d\n", ret);
864 goto err_irq;
865 }
866
867 /* wait for init to complete */
868 par->board->wait_for_rdy(par);
869
870 /*
871 * From here on the controller can talk to us
872 */
873
874 /* initialise fix, var, resolution and rotation */
875
876 strlcpy(info->fix.id, init->id, 16);
877 info->fix.type = FB_TYPE_PACKED_PIXELS;
878 info->fix.visual = FB_VISUAL_STATIC_PSEUDOCOLOR;
879 info->fix.xpanstep = 0;
880 info->fix.ypanstep = 0;
881 info->fix.ywrapstep = 0;
882 info->fix.accel = FB_ACCEL_NONE;
883
884 info->var.bits_per_pixel = 8;
885 info->var.grayscale = 1;
886 info->var.red.length = 8;
887 info->var.green.length = 8;
888 info->var.blue.length = 8;
889
890 panel = &panel_table[board->resolution];
891
892 /* if 90 degree rotation, switch width and height */
893 if (board->rotation & 1) {
894 info->var.xres = panel->h;
895 info->var.yres = panel->w;
896 info->var.xres_virtual = panel->h;
897 info->var.yres_virtual = panel->w;
898 info->fix.line_length = panel->h;
899 } else {
900 info->var.xres = panel->w;
901 info->var.yres = panel->h;
902 info->var.xres_virtual = panel->w;
903 info->var.yres_virtual = panel->h;
904 info->fix.line_length = panel->w;
905 }
906
907 par->resolution = board->resolution;
908 par->rotation = board->rotation;
909
910 /* videomemory handling */
911
912 videomemorysize = roundup((panel->w * panel->h), PAGE_SIZE);
913 videomemory = vmalloc(videomemorysize);
914 if (!videomemory) {
915 ret = -ENOMEM;
916 goto err_irq;
917 }
918
919 memset(videomemory, 0, videomemorysize);
920 info->screen_base = (char *)videomemory;
921 info->fix.smem_len = videomemorysize;
922
923 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB;
924 info->fbops = &auok190xfb_ops;
925
926 /* deferred io init */
927
928 info->fbdefio = devm_kzalloc(info->device,
929 sizeof(struct fb_deferred_io),
930 GFP_KERNEL);
931 if (!info->fbdefio) {
932 dev_err(info->device, "Failed to allocate memory\n");
933 ret = -ENOMEM;
934 goto err_defio;
935 }
936
937 dev_dbg(info->device, "targetting %d frames per second\n", board->fps);
938 info->fbdefio->delay = HZ / board->fps;
939 info->fbdefio->first_io = auok190xfb_dpy_first_io,
940 info->fbdefio->deferred_io = auok190xfb_dpy_deferred_io,
941 fb_deferred_io_init(info);
942
943 /* color map */
944
945 ret = fb_alloc_cmap(&info->cmap, 256, 0);
946 if (ret < 0) {
947 dev_err(info->device, "Failed to allocate colormap\n");
948 goto err_cmap;
949 }
950
951 /* controller init */
952
953 par->consecutive_threshold = 100;
954 par->init(par);
955 auok190x_identify(par);
956
957 platform_set_drvdata(pdev, info);
958
959 ret = register_framebuffer(info);
960 if (ret < 0)
961 goto err_regfb;
962
963 ret = sysfs_create_group(&info->device->kobj, &auok190x_attr_group);
964 if (ret)
965 goto err_sysfs;
966
967 dev_info(info->device, "fb%d: %dx%d using %dK of video memory\n",
968 info->node, info->var.xres, info->var.yres,
969 videomemorysize >> 10);
970
971 /* increase autosuspend_delay when we use alternative methods
972 * for runtime_pm
973 */
974 par->autosuspend_delay = (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN)
975 ? 1000 : 200;
976
977 pm_runtime_set_active(info->device);
978 pm_runtime_enable(info->device);
979 pm_runtime_set_autosuspend_delay(info->device, par->autosuspend_delay);
980 pm_runtime_use_autosuspend(info->device);
981
982 return 0;
983
984err_sysfs:
985 unregister_framebuffer(info);
986err_regfb:
987 fb_dealloc_cmap(&info->cmap);
988err_cmap:
989 fb_deferred_io_cleanup(info);
990 kfree(info->fbdefio);
991err_defio:
992 vfree((void *)info->screen_base);
993err_irq:
994 auok190x_power(par, 0);
995err_gpio3:
996 gpio_free(board->gpio_nrst);
997err_gpio2:
998 gpio_free(board->gpio_nsleep);
999err_gpio1:
1000 board->cleanup(par);
1001err_board:
1002 regulator_put(par->regulator);
1003err_reg:
1004 framebuffer_release(info);
1005
1006 return ret;
1007}
1008EXPORT_SYMBOL_GPL(auok190x_common_probe);
1009
1010int __devexit auok190x_common_remove(struct platform_device *pdev)
1011{
1012 struct fb_info *info = platform_get_drvdata(pdev);
1013 struct auok190xfb_par *par = info->par;
1014 struct auok190x_board *board = par->board;
1015
1016 pm_runtime_disable(info->device);
1017
1018 sysfs_remove_group(&info->device->kobj, &auok190x_attr_group);
1019
1020 unregister_framebuffer(info);
1021
1022 fb_dealloc_cmap(&info->cmap);
1023
1024 fb_deferred_io_cleanup(info);
1025 kfree(info->fbdefio);
1026
1027 vfree((void *)info->screen_base);
1028
1029 auok190x_power(par, 0);
1030
1031 gpio_free(board->gpio_nrst);
1032 gpio_free(board->gpio_nsleep);
1033
1034 board->cleanup(par);
1035
1036 regulator_put(par->regulator);
1037
1038 framebuffer_release(info);
1039
1040 return 0;
1041}
1042EXPORT_SYMBOL_GPL(auok190x_common_remove);
1043
1044MODULE_DESCRIPTION("Common code for AUO-K190X controllers");
1045MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
1046MODULE_LICENSE("GPL");
diff --git a/drivers/video/auo_k190x.h b/drivers/video/auo_k190x.h
new file mode 100644
index 000000000000..e35af1f51b28
--- /dev/null
+++ b/drivers/video/auo_k190x.h
@@ -0,0 +1,129 @@
1/*
2 * Private common definitions for AUO-K190X framebuffer drivers
3 *
4 * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11/*
12 * I80 interface specific defines
13 */
14
15#define AUOK190X_I80_CS 0x01
16#define AUOK190X_I80_DC 0x02
17#define AUOK190X_I80_WR 0x03
18#define AUOK190X_I80_OE 0x04
19
20/*
21 * AUOK190x commands, common to both controllers
22 */
23
24#define AUOK190X_CMD_INIT 0x0000
25#define AUOK190X_CMD_STANDBY 0x0001
26#define AUOK190X_CMD_WAKEUP 0x0002
27#define AUOK190X_CMD_TCON_RESET 0x0003
28#define AUOK190X_CMD_DATA_STOP 0x1002
29#define AUOK190X_CMD_LUT_START 0x1003
30#define AUOK190X_CMD_DISP_REFRESH 0x1004
31#define AUOK190X_CMD_DISP_RESET 0x1005
32#define AUOK190X_CMD_PRE_DISPLAY_START 0x100D
33#define AUOK190X_CMD_PRE_DISPLAY_STOP 0x100F
34#define AUOK190X_CMD_FLASH_W 0x2000
35#define AUOK190X_CMD_FLASH_E 0x2001
36#define AUOK190X_CMD_FLASH_STS 0x2002
37#define AUOK190X_CMD_FRAMERATE 0x3000
38#define AUOK190X_CMD_READ_VERSION 0x4000
39#define AUOK190X_CMD_READ_STATUS 0x4001
40#define AUOK190X_CMD_READ_LUT 0x4003
41#define AUOK190X_CMD_DRIVERTIMING 0x5000
42#define AUOK190X_CMD_LBALANCE 0x5001
43#define AUOK190X_CMD_AGINGMODE 0x6000
44#define AUOK190X_CMD_AGINGEXIT 0x6001
45
46/*
47 * Common settings for AUOK190X_CMD_INIT
48 */
49
50#define AUOK190X_INIT_DATA_FILTER (0 << 12)
51#define AUOK190X_INIT_DATA_BYPASS (1 << 12)
52#define AUOK190X_INIT_INVERSE_WHITE (0 << 9)
53#define AUOK190X_INIT_INVERSE_BLACK (1 << 9)
54#define AUOK190X_INIT_SCAN_DOWN (0 << 1)
55#define AUOK190X_INIT_SCAN_UP (1 << 1)
56#define AUOK190X_INIT_SHIFT_LEFT (0 << 0)
57#define AUOK190X_INIT_SHIFT_RIGHT (1 << 0)
58
59/* Common bits to pixels
60 * Mode 15-12 11-8 7-4 3-0
61 * format0 4 3 2 1
62 * format1 3 4 1 2
63 */
64
65#define AUOK190X_INIT_FORMAT0 0
66#define AUOK190X_INIT_FORMAT1 (1 << 6)
67
68/*
69 * settings for AUOK190X_CMD_RESET
70 */
71
72#define AUOK190X_RESET_TCON (0 << 0)
73#define AUOK190X_RESET_NORMAL (1 << 0)
74#define AUOK190X_RESET_PON (1 << 1)
75
76/*
77 * AUOK190X_CMD_VERSION
78 */
79
80#define AUOK190X_VERSION_TEMP_MASK (0x1ff)
81#define AUOK190X_VERSION_EPD_MASK (0xff)
82#define AUOK190X_VERSION_SIZE_INT(_val) ((_val & 0xfc00) >> 10)
83#define AUOK190X_VERSION_SIZE_FLOAT(_val) ((_val & 0x3c0) >> 6)
84#define AUOK190X_VERSION_MODEL(_val) (_val & 0x3f)
85#define AUOK190X_VERSION_LUT(_val) (_val & 0xff)
86#define AUOK190X_VERSION_TCON(_val) ((_val & 0xff00) >> 8)
87
88/*
89 * update modes for CMD_PARTIALDISP on K1900 and CMD_DDMA on K1901
90 */
91
92#define AUOK190X_UPDATE_MODE(_res) ((_res & 0x7) << 12)
93#define AUOK190X_UPDATE_NONFLASH (1 << 15)
94
95/*
96 * track panel specific parameters for common init
97 */
98
99struct auok190x_init_data {
100 char *id;
101 struct auok190x_board *board;
102
103 void (*update_partial)(struct auok190xfb_par *par, u16 y1, u16 y2);
104 void (*update_all)(struct auok190xfb_par *par);
105 bool (*need_refresh)(struct auok190xfb_par *par);
106 void (*init)(struct auok190xfb_par *par);
107};
108
109
110extern void auok190x_send_command_nowait(struct auok190xfb_par *par, u16 data);
111extern int auok190x_send_command(struct auok190xfb_par *par, u16 data);
112extern void auok190x_send_cmdargs_nowait(struct auok190xfb_par *par, u16 cmd,
113 int argc, u16 *argv);
114extern int auok190x_send_cmdargs(struct auok190xfb_par *par, u16 cmd,
115 int argc, u16 *argv);
116extern void auok190x_send_cmdargs_pixels_nowait(struct auok190xfb_par *par,
117 u16 cmd, int argc, u16 *argv,
118 int size, u16 *data);
119extern int auok190x_send_cmdargs_pixels(struct auok190xfb_par *par, u16 cmd,
120 int argc, u16 *argv, int size,
121 u16 *data);
122extern int auok190x_read_cmdargs(struct auok190xfb_par *par, u16 cmd,
123 int argc, u16 *argv);
124
125extern int auok190x_common_probe(struct platform_device *pdev,
126 struct auok190x_init_data *init);
127extern int auok190x_common_remove(struct platform_device *pdev);
128
129extern const struct dev_pm_ops auok190x_pm;
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index af16884491ed..fa2b03750316 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -184,6 +184,18 @@ config BACKLIGHT_GENERIC
184 known as the Corgi backlight driver. If you have a Sharp Zaurus 184 known as the Corgi backlight driver. If you have a Sharp Zaurus
185 SL-C7xx, SL-Cxx00 or SL-6000x say y. 185 SL-C7xx, SL-Cxx00 or SL-6000x say y.
186 186
187config BACKLIGHT_LM3533
188 tristate "Backlight Driver for LM3533"
189 depends on BACKLIGHT_CLASS_DEVICE
190 depends on MFD_LM3533
191 help
192 Say Y to enable the backlight driver for National Semiconductor / TI
193 LM3533 Lighting Power chips.
194
195 The backlights can be controlled directly, through PWM input, or by
196 the ambient-light-sensor interface. The chip supports 256 brightness
197 levels.
198
187config BACKLIGHT_LOCOMO 199config BACKLIGHT_LOCOMO
188 tristate "Sharp LOCOMO LCD/Backlight Driver" 200 tristate "Sharp LOCOMO LCD/Backlight Driver"
189 depends on SHARP_LOCOMO 201 depends on SHARP_LOCOMO
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile
index 36855ae887d6..a2ac9cfbaf6b 100644
--- a/drivers/video/backlight/Makefile
+++ b/drivers/video/backlight/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_BACKLIGHT_EP93XX) += ep93xx_bl.o
21obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o 21obj-$(CONFIG_BACKLIGHT_GENERIC) += generic_bl.o
22obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o 22obj-$(CONFIG_BACKLIGHT_HP700) += jornada720_bl.o
23obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o 23obj-$(CONFIG_BACKLIGHT_HP680) += hp680_bl.o
24obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_bl.o
24obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o 25obj-$(CONFIG_BACKLIGHT_LOCOMO) += locomolcd.o
25obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o 26obj-$(CONFIG_BACKLIGHT_LP855X) += lp855x_bl.o
26obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o 27obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o
diff --git a/drivers/video/backlight/adp5520_bl.c b/drivers/video/backlight/adp5520_bl.c
index 4911ea7989c8..df5db99af23d 100644
--- a/drivers/video/backlight/adp5520_bl.c
+++ b/drivers/video/backlight/adp5520_bl.c
@@ -160,7 +160,7 @@ static ssize_t adp5520_store(struct device *dev, const char *buf,
160 unsigned long val; 160 unsigned long val;
161 int ret; 161 int ret;
162 162
163 ret = strict_strtoul(buf, 10, &val); 163 ret = kstrtoul(buf, 10, &val);
164 if (ret) 164 if (ret)
165 return ret; 165 return ret;
166 166
@@ -214,7 +214,7 @@ static ssize_t adp5520_bl_daylight_max_store(struct device *dev,
214 struct adp5520_bl *data = dev_get_drvdata(dev); 214 struct adp5520_bl *data = dev_get_drvdata(dev);
215 int ret; 215 int ret;
216 216
217 ret = strict_strtoul(buf, 10, &data->cached_daylight_max); 217 ret = kstrtoul(buf, 10, &data->cached_daylight_max);
218 if (ret < 0) 218 if (ret < 0)
219 return ret; 219 return ret;
220 220
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 550dbf0bb896..77d1fdba597f 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -222,7 +222,8 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
222 struct led_info *cur_led; 222 struct led_info *cur_led;
223 int ret, i; 223 int ret, i;
224 224
225 led = kzalloc(sizeof(*led) * pdata->num_leds, GFP_KERNEL); 225 led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds,
226 GFP_KERNEL);
226 if (led == NULL) { 227 if (led == NULL) {
227 dev_err(&client->dev, "failed to alloc memory\n"); 228 dev_err(&client->dev, "failed to alloc memory\n");
228 return -ENOMEM; 229 return -ENOMEM;
@@ -236,7 +237,7 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
236 237
237 if (ret) { 238 if (ret) {
238 dev_err(&client->dev, "failed to write\n"); 239 dev_err(&client->dev, "failed to write\n");
239 goto err_free; 240 return ret;
240 } 241 }
241 242
242 for (i = 0; i < pdata->num_leds; ++i) { 243 for (i = 0; i < pdata->num_leds; ++i) {
@@ -291,9 +292,6 @@ static int __devinit adp8860_led_probe(struct i2c_client *client)
291 cancel_work_sync(&led[i].work); 292 cancel_work_sync(&led[i].work);
292 } 293 }
293 294
294 err_free:
295 kfree(led);
296
297 return ret; 295 return ret;
298} 296}
299 297
@@ -309,7 +307,6 @@ static int __devexit adp8860_led_remove(struct i2c_client *client)
309 cancel_work_sync(&data->led[i].work); 307 cancel_work_sync(&data->led[i].work);
310 } 308 }
311 309
312 kfree(data->led);
313 return 0; 310 return 0;
314} 311}
315#else 312#else
@@ -451,7 +448,7 @@ static ssize_t adp8860_store(struct device *dev, const char *buf,
451 unsigned long val; 448 unsigned long val;
452 int ret; 449 int ret;
453 450
454 ret = strict_strtoul(buf, 10, &val); 451 ret = kstrtoul(buf, 10, &val);
455 if (ret) 452 if (ret)
456 return ret; 453 return ret;
457 454
@@ -501,7 +498,7 @@ static ssize_t adp8860_bl_l1_daylight_max_store(struct device *dev,
501 struct device_attribute *attr, const char *buf, size_t count) 498 struct device_attribute *attr, const char *buf, size_t count)
502{ 499{
503 struct adp8860_bl *data = dev_get_drvdata(dev); 500 struct adp8860_bl *data = dev_get_drvdata(dev);
504 int ret = strict_strtoul(buf, 10, &data->cached_daylight_max); 501 int ret = kstrtoul(buf, 10, &data->cached_daylight_max);
505 if (ret) 502 if (ret)
506 return ret; 503 return ret;
507 504
@@ -608,7 +605,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,
608 uint8_t reg_val; 605 uint8_t reg_val;
609 int ret; 606 int ret;
610 607
611 ret = strict_strtoul(buf, 10, &val); 608 ret = kstrtoul(buf, 10, &val);
612 if (ret) 609 if (ret)
613 return ret; 610 return ret;
614 611
@@ -675,13 +672,13 @@ static int __devinit adp8860_probe(struct i2c_client *client,
675 return -EINVAL; 672 return -EINVAL;
676 } 673 }
677 674
678 data = kzalloc(sizeof(*data), GFP_KERNEL); 675 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
679 if (data == NULL) 676 if (data == NULL)
680 return -ENOMEM; 677 return -ENOMEM;
681 678
682 ret = adp8860_read(client, ADP8860_MFDVID, &reg_val); 679 ret = adp8860_read(client, ADP8860_MFDVID, &reg_val);
683 if (ret < 0) 680 if (ret < 0)
684 goto out2; 681 return ret;
685 682
686 switch (ADP8860_MANID(reg_val)) { 683 switch (ADP8860_MANID(reg_val)) {
687 case ADP8863_MANUFID: 684 case ADP8863_MANUFID:
@@ -694,8 +691,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
694 break; 691 break;
695 default: 692 default:
696 dev_err(&client->dev, "failed to probe\n"); 693 dev_err(&client->dev, "failed to probe\n");
697 ret = -ENODEV; 694 return -ENODEV;
698 goto out2;
699 } 695 }
700 696
701 /* It's confirmed that the DEVID field is actually a REVID */ 697 /* It's confirmed that the DEVID field is actually a REVID */
@@ -717,8 +713,7 @@ static int __devinit adp8860_probe(struct i2c_client *client,
717 &client->dev, data, &adp8860_bl_ops, &props); 713 &client->dev, data, &adp8860_bl_ops, &props);
718 if (IS_ERR(bl)) { 714 if (IS_ERR(bl)) {
719 dev_err(&client->dev, "failed to register backlight\n"); 715 dev_err(&client->dev, "failed to register backlight\n");
720 ret = PTR_ERR(bl); 716 return PTR_ERR(bl);
721 goto out2;
722 } 717 }
723 718
724 bl->props.brightness = ADP8860_MAX_BRIGHTNESS; 719 bl->props.brightness = ADP8860_MAX_BRIGHTNESS;
@@ -756,8 +751,6 @@ out:
756 &adp8860_bl_attr_group); 751 &adp8860_bl_attr_group);
757out1: 752out1:
758 backlight_device_unregister(bl); 753 backlight_device_unregister(bl);
759out2:
760 kfree(data);
761 754
762 return ret; 755 return ret;
763} 756}
@@ -776,7 +769,6 @@ static int __devexit adp8860_remove(struct i2c_client *client)
776 &adp8860_bl_attr_group); 769 &adp8860_bl_attr_group);
777 770
778 backlight_device_unregister(data->bl); 771 backlight_device_unregister(data->bl);
779 kfree(data);
780 772
781 return 0; 773 return 0;
782} 774}
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 9be58c6f18f1..edf7f91c8e61 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -244,8 +244,8 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
244 struct led_info *cur_led; 244 struct led_info *cur_led;
245 int ret, i; 245 int ret, i;
246 246
247 247 led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led),
248 led = kcalloc(pdata->num_leds, sizeof(*led), GFP_KERNEL); 248 GFP_KERNEL);
249 if (led == NULL) { 249 if (led == NULL) {
250 dev_err(&client->dev, "failed to alloc memory\n"); 250 dev_err(&client->dev, "failed to alloc memory\n");
251 return -ENOMEM; 251 return -ENOMEM;
@@ -253,17 +253,17 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
253 253
254 ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law); 254 ret = adp8870_write(client, ADP8870_ISCLAW, pdata->led_fade_law);
255 if (ret) 255 if (ret)
256 goto err_free; 256 return ret;
257 257
258 ret = adp8870_write(client, ADP8870_ISCT1, 258 ret = adp8870_write(client, ADP8870_ISCT1,
259 (pdata->led_on_time & 0x3) << 6); 259 (pdata->led_on_time & 0x3) << 6);
260 if (ret) 260 if (ret)
261 goto err_free; 261 return ret;
262 262
263 ret = adp8870_write(client, ADP8870_ISCF, 263 ret = adp8870_write(client, ADP8870_ISCF,
264 FADE_VAL(pdata->led_fade_in, pdata->led_fade_out)); 264 FADE_VAL(pdata->led_fade_in, pdata->led_fade_out));
265 if (ret) 265 if (ret)
266 goto err_free; 266 return ret;
267 267
268 for (i = 0; i < pdata->num_leds; ++i) { 268 for (i = 0; i < pdata->num_leds; ++i) {
269 cur_led = &pdata->leds[i]; 269 cur_led = &pdata->leds[i];
@@ -317,9 +317,6 @@ static int __devinit adp8870_led_probe(struct i2c_client *client)
317 cancel_work_sync(&led[i].work); 317 cancel_work_sync(&led[i].work);
318 } 318 }
319 319
320 err_free:
321 kfree(led);
322
323 return ret; 320 return ret;
324} 321}
325 322
@@ -335,7 +332,6 @@ static int __devexit adp8870_led_remove(struct i2c_client *client)
335 cancel_work_sync(&data->led[i].work); 332 cancel_work_sync(&data->led[i].work);
336 } 333 }
337 334
338 kfree(data->led);
339 return 0; 335 return 0;
340} 336}
341#else 337#else
@@ -572,7 +568,7 @@ static ssize_t adp8870_store(struct device *dev, const char *buf,
572 unsigned long val; 568 unsigned long val;
573 int ret; 569 int ret;
574 570
575 ret = strict_strtoul(buf, 10, &val); 571 ret = kstrtoul(buf, 10, &val);
576 if (ret) 572 if (ret)
577 return ret; 573 return ret;
578 574
@@ -652,7 +648,7 @@ static ssize_t adp8870_bl_l1_daylight_max_store(struct device *dev,
652 struct device_attribute *attr, const char *buf, size_t count) 648 struct device_attribute *attr, const char *buf, size_t count)
653{ 649{
654 struct adp8870_bl *data = dev_get_drvdata(dev); 650 struct adp8870_bl *data = dev_get_drvdata(dev);
655 int ret = strict_strtoul(buf, 10, &data->cached_daylight_max); 651 int ret = kstrtoul(buf, 10, &data->cached_daylight_max);
656 if (ret) 652 if (ret)
657 return ret; 653 return ret;
658 654
@@ -794,7 +790,7 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev,
794 uint8_t reg_val; 790 uint8_t reg_val;
795 int ret; 791 int ret;
796 792
797 ret = strict_strtoul(buf, 10, &val); 793 ret = kstrtoul(buf, 10, &val);
798 if (ret) 794 if (ret)
799 return ret; 795 return ret;
800 796
@@ -874,7 +870,7 @@ static int __devinit adp8870_probe(struct i2c_client *client,
874 return -ENODEV; 870 return -ENODEV;
875 } 871 }
876 872
877 data = kzalloc(sizeof(*data), GFP_KERNEL); 873 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
878 if (data == NULL) 874 if (data == NULL)
879 return -ENOMEM; 875 return -ENOMEM;
880 876
@@ -894,8 +890,7 @@ static int __devinit adp8870_probe(struct i2c_client *client,
894 &client->dev, data, &adp8870_bl_ops, &props); 890 &client->dev, data, &adp8870_bl_ops, &props);
895 if (IS_ERR(bl)) { 891 if (IS_ERR(bl)) {
896 dev_err(&client->dev, "failed to register backlight\n"); 892 dev_err(&client->dev, "failed to register backlight\n");
897 ret = PTR_ERR(bl); 893 return PTR_ERR(bl);
898 goto out2;
899 } 894 }
900 895
901 data->bl = bl; 896 data->bl = bl;
@@ -930,8 +925,6 @@ out:
930 &adp8870_bl_attr_group); 925 &adp8870_bl_attr_group);
931out1: 926out1:
932 backlight_device_unregister(bl); 927 backlight_device_unregister(bl);
933out2:
934 kfree(data);
935 928
936 return ret; 929 return ret;
937} 930}
@@ -950,7 +943,6 @@ static int __devexit adp8870_remove(struct i2c_client *client)
950 &adp8870_bl_attr_group); 943 &adp8870_bl_attr_group);
951 944
952 backlight_device_unregister(data->bl); 945 backlight_device_unregister(data->bl);
953 kfree(data);
954 946
955 return 0; 947 return 0;
956} 948}
diff --git a/drivers/video/backlight/ams369fg06.c b/drivers/video/backlight/ams369fg06.c
index 7bdadc790117..3729238e7096 100644
--- a/drivers/video/backlight/ams369fg06.c
+++ b/drivers/video/backlight/ams369fg06.c
@@ -482,7 +482,7 @@ static int __devinit ams369fg06_probe(struct spi_device *spi)
482 struct backlight_device *bd = NULL; 482 struct backlight_device *bd = NULL;
483 struct backlight_properties props; 483 struct backlight_properties props;
484 484
485 lcd = kzalloc(sizeof(struct ams369fg06), GFP_KERNEL); 485 lcd = devm_kzalloc(&spi->dev, sizeof(struct ams369fg06), GFP_KERNEL);
486 if (!lcd) 486 if (!lcd)
487 return -ENOMEM; 487 return -ENOMEM;
488 488
@@ -492,7 +492,7 @@ static int __devinit ams369fg06_probe(struct spi_device *spi)
492 ret = spi_setup(spi); 492 ret = spi_setup(spi);
493 if (ret < 0) { 493 if (ret < 0) {
494 dev_err(&spi->dev, "spi setup failed.\n"); 494 dev_err(&spi->dev, "spi setup failed.\n");
495 goto out_free_lcd; 495 return ret;
496 } 496 }
497 497
498 lcd->spi = spi; 498 lcd->spi = spi;
@@ -501,15 +501,13 @@ static int __devinit ams369fg06_probe(struct spi_device *spi)
501 lcd->lcd_pd = spi->dev.platform_data; 501 lcd->lcd_pd = spi->dev.platform_data;
502 if (!lcd->lcd_pd) { 502 if (!lcd->lcd_pd) {
503 dev_err(&spi->dev, "platform data is NULL\n"); 503 dev_err(&spi->dev, "platform data is NULL\n");
504 goto out_free_lcd; 504 return -EFAULT;
505 } 505 }
506 506
507 ld = lcd_device_register("ams369fg06", &spi->dev, lcd, 507 ld = lcd_device_register("ams369fg06", &spi->dev, lcd,
508 &ams369fg06_lcd_ops); 508 &ams369fg06_lcd_ops);
509 if (IS_ERR(ld)) { 509 if (IS_ERR(ld))
510 ret = PTR_ERR(ld); 510 return PTR_ERR(ld);
511 goto out_free_lcd;
512 }
513 511
514 lcd->ld = ld; 512 lcd->ld = ld;
515 513
@@ -547,8 +545,6 @@ static int __devinit ams369fg06_probe(struct spi_device *spi)
547 545
548out_lcd_unregister: 546out_lcd_unregister:
549 lcd_device_unregister(ld); 547 lcd_device_unregister(ld);
550out_free_lcd:
551 kfree(lcd);
552 return ret; 548 return ret;
553} 549}
554 550
@@ -559,7 +555,6 @@ static int __devexit ams369fg06_remove(struct spi_device *spi)
559 ams369fg06_power(lcd, FB_BLANK_POWERDOWN); 555 ams369fg06_power(lcd, FB_BLANK_POWERDOWN);
560 backlight_device_unregister(lcd->bd); 556 backlight_device_unregister(lcd->bd);
561 lcd_device_unregister(lcd->ld); 557 lcd_device_unregister(lcd->ld);
562 kfree(lcd);
563 558
564 return 0; 559 return 0;
565} 560}
@@ -619,7 +614,6 @@ static void ams369fg06_shutdown(struct spi_device *spi)
619static struct spi_driver ams369fg06_driver = { 614static struct spi_driver ams369fg06_driver = {
620 .driver = { 615 .driver = {
621 .name = "ams369fg06", 616 .name = "ams369fg06",
622 .bus = &spi_bus_type,
623 .owner = THIS_MODULE, 617 .owner = THIS_MODULE,
624 }, 618 },
625 .probe = ams369fg06_probe, 619 .probe = ams369fg06_probe,
diff --git a/drivers/video/backlight/apple_bl.c b/drivers/video/backlight/apple_bl.c
index a523b255e124..9dc73ac3709a 100644
--- a/drivers/video/backlight/apple_bl.c
+++ b/drivers/video/backlight/apple_bl.c
@@ -16,6 +16,8 @@
16 * get at the firmware code in order to figure out what it's actually doing. 16 * get at the firmware code in order to figure out what it's actually doing.
17 */ 17 */
18 18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
19#include <linux/module.h> 21#include <linux/module.h>
20#include <linux/kernel.h> 22#include <linux/kernel.h>
21#include <linux/init.h> 23#include <linux/init.h>
@@ -25,6 +27,7 @@
25#include <linux/pci.h> 27#include <linux/pci.h>
26#include <linux/acpi.h> 28#include <linux/acpi.h>
27#include <linux/atomic.h> 29#include <linux/atomic.h>
30#include <linux/apple_bl.h>
28 31
29static struct backlight_device *apple_backlight_device; 32static struct backlight_device *apple_backlight_device;
30 33
@@ -39,8 +42,6 @@ struct hw_data {
39 42
40static const struct hw_data *hw_data; 43static const struct hw_data *hw_data;
41 44
42#define DRIVER "apple_backlight: "
43
44/* Module parameters. */ 45/* Module parameters. */
45static int debug; 46static int debug;
46module_param_named(debug, debug, int, 0644); 47module_param_named(debug, debug, int, 0644);
@@ -60,8 +61,7 @@ static int intel_chipset_send_intensity(struct backlight_device *bd)
60 int intensity = bd->props.brightness; 61 int intensity = bd->props.brightness;
61 62
62 if (debug) 63 if (debug)
63 printk(KERN_DEBUG DRIVER "setting brightness to %d\n", 64 pr_debug("setting brightness to %d\n", intensity);
64 intensity);
65 65
66 intel_chipset_set_brightness(intensity); 66 intel_chipset_set_brightness(intensity);
67 return 0; 67 return 0;
@@ -76,8 +76,7 @@ static int intel_chipset_get_intensity(struct backlight_device *bd)
76 intensity = inb(0xb3) >> 4; 76 intensity = inb(0xb3) >> 4;
77 77
78 if (debug) 78 if (debug)
79 printk(KERN_DEBUG DRIVER "read brightness of %d\n", 79 pr_debug("read brightness of %d\n", intensity);
80 intensity);
81 80
82 return intensity; 81 return intensity;
83} 82}
@@ -107,8 +106,7 @@ static int nvidia_chipset_send_intensity(struct backlight_device *bd)
107 int intensity = bd->props.brightness; 106 int intensity = bd->props.brightness;
108 107
109 if (debug) 108 if (debug)
110 printk(KERN_DEBUG DRIVER "setting brightness to %d\n", 109 pr_debug("setting brightness to %d\n", intensity);
111 intensity);
112 110
113 nvidia_chipset_set_brightness(intensity); 111 nvidia_chipset_set_brightness(intensity);
114 return 0; 112 return 0;
@@ -123,8 +121,7 @@ static int nvidia_chipset_get_intensity(struct backlight_device *bd)
123 intensity = inb(0x52f) >> 4; 121 intensity = inb(0x52f) >> 4;
124 122
125 if (debug) 123 if (debug)
126 printk(KERN_DEBUG DRIVER "read brightness of %d\n", 124 pr_debug("read brightness of %d\n", intensity);
127 intensity);
128 125
129 return intensity; 126 return intensity;
130} 127}
@@ -149,7 +146,7 @@ static int __devinit apple_bl_add(struct acpi_device *dev)
149 host = pci_get_bus_and_slot(0, 0); 146 host = pci_get_bus_and_slot(0, 0);
150 147
151 if (!host) { 148 if (!host) {
152 printk(KERN_ERR DRIVER "unable to find PCI host\n"); 149 pr_err("unable to find PCI host\n");
153 return -ENODEV; 150 return -ENODEV;
154 } 151 }
155 152
@@ -161,7 +158,7 @@ static int __devinit apple_bl_add(struct acpi_device *dev)
161 pci_dev_put(host); 158 pci_dev_put(host);
162 159
163 if (!hw_data) { 160 if (!hw_data) {
164 printk(KERN_ERR DRIVER "unknown hardware\n"); 161 pr_err("unknown hardware\n");
165 return -ENODEV; 162 return -ENODEV;
166 } 163 }
167 164
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index bf5b1ece7160..297db2fa91f5 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -5,6 +5,8 @@
5 * 5 *
6 */ 6 */
7 7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
8#include <linux/module.h> 10#include <linux/module.h>
9#include <linux/init.h> 11#include <linux/init.h>
10#include <linux/device.h> 12#include <linux/device.h>
@@ -123,7 +125,7 @@ static ssize_t backlight_store_power(struct device *dev,
123 rc = -ENXIO; 125 rc = -ENXIO;
124 mutex_lock(&bd->ops_lock); 126 mutex_lock(&bd->ops_lock);
125 if (bd->ops) { 127 if (bd->ops) {
126 pr_debug("backlight: set power to %lu\n", power); 128 pr_debug("set power to %lu\n", power);
127 if (bd->props.power != power) { 129 if (bd->props.power != power) {
128 bd->props.power = power; 130 bd->props.power = power;
129 backlight_update_status(bd); 131 backlight_update_status(bd);
@@ -161,8 +163,7 @@ static ssize_t backlight_store_brightness(struct device *dev,
161 if (brightness > bd->props.max_brightness) 163 if (brightness > bd->props.max_brightness)
162 rc = -EINVAL; 164 rc = -EINVAL;
163 else { 165 else {
164 pr_debug("backlight: set brightness to %lu\n", 166 pr_debug("set brightness to %lu\n", brightness);
165 brightness);
166 bd->props.brightness = brightness; 167 bd->props.brightness = brightness;
167 backlight_update_status(bd); 168 backlight_update_status(bd);
168 rc = count; 169 rc = count;
@@ -378,8 +379,8 @@ static int __init backlight_class_init(void)
378{ 379{
379 backlight_class = class_create(THIS_MODULE, "backlight"); 380 backlight_class = class_create(THIS_MODULE, "backlight");
380 if (IS_ERR(backlight_class)) { 381 if (IS_ERR(backlight_class)) {
381 printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n", 382 pr_warn("Unable to create backlight class; errno = %ld\n",
382 PTR_ERR(backlight_class)); 383 PTR_ERR(backlight_class));
383 return PTR_ERR(backlight_class); 384 return PTR_ERR(backlight_class);
384 } 385 }
385 386
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c
index 6dab13fe562e..23d732677ba1 100644
--- a/drivers/video/backlight/corgi_lcd.c
+++ b/drivers/video/backlight/corgi_lcd.c
@@ -544,7 +544,7 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
544 return -EINVAL; 544 return -EINVAL;
545 } 545 }
546 546
547 lcd = kzalloc(sizeof(struct corgi_lcd), GFP_KERNEL); 547 lcd = devm_kzalloc(&spi->dev, sizeof(struct corgi_lcd), GFP_KERNEL);
548 if (!lcd) { 548 if (!lcd) {
549 dev_err(&spi->dev, "failed to allocate memory\n"); 549 dev_err(&spi->dev, "failed to allocate memory\n");
550 return -ENOMEM; 550 return -ENOMEM;
@@ -554,10 +554,9 @@ static int __devinit corgi_lcd_probe(struct spi_device *spi)
554 554
555 lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev, 555 lcd->lcd_dev = lcd_device_register("corgi_lcd", &spi->dev,
556 lcd, &corgi_lcd_ops); 556 lcd, &corgi_lcd_ops);
557 if (IS_ERR(lcd->lcd_dev)) { 557 if (IS_ERR(lcd->lcd_dev))
558 ret = PTR_ERR(lcd->lcd_dev); 558 return PTR_ERR(lcd->lcd_dev);
559 goto err_free_lcd; 559
560 }
561 lcd->power = FB_BLANK_POWERDOWN; 560 lcd->power = FB_BLANK_POWERDOWN;
562 lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA; 561 lcd->mode = (pdata) ? pdata->init_mode : CORGI_LCD_MODE_VGA;
563 562
@@ -591,8 +590,6 @@ err_unregister_bl:
591 backlight_device_unregister(lcd->bl_dev); 590 backlight_device_unregister(lcd->bl_dev);
592err_unregister_lcd: 591err_unregister_lcd:
593 lcd_device_unregister(lcd->lcd_dev); 592 lcd_device_unregister(lcd->lcd_dev);
594err_free_lcd:
595 kfree(lcd);
596 return ret; 593 return ret;
597} 594}
598 595
@@ -613,7 +610,6 @@ static int __devexit corgi_lcd_remove(struct spi_device *spi)
613 610
614 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN); 611 corgi_lcd_set_power(lcd->lcd_dev, FB_BLANK_POWERDOWN);
615 lcd_device_unregister(lcd->lcd_dev); 612 lcd_device_unregister(lcd->lcd_dev);
616 kfree(lcd);
617 613
618 return 0; 614 return 0;
619} 615}
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 22489eb5f3e0..37bae801e23b 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -27,6 +27,8 @@
27 * Alan Hourihane <alanh-at-tungstengraphics-dot-com> 27 * Alan Hourihane <alanh-at-tungstengraphics-dot-com>
28 */ 28 */
29 29
30#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31
30#include <linux/module.h> 32#include <linux/module.h>
31#include <linux/kernel.h> 33#include <linux/kernel.h>
32#include <linux/init.h> 34#include <linux/init.h>
@@ -180,14 +182,13 @@ static int cr_backlight_probe(struct platform_device *pdev)
180 lpc_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 182 lpc_dev = pci_get_device(PCI_VENDOR_ID_INTEL,
181 CRVML_DEVICE_LPC, NULL); 183 CRVML_DEVICE_LPC, NULL);
182 if (!lpc_dev) { 184 if (!lpc_dev) {
183 printk("INTEL CARILLO RANCH LPC not found.\n"); 185 pr_err("INTEL CARILLO RANCH LPC not found.\n");
184 return -ENODEV; 186 return -ENODEV;
185 } 187 }
186 188
187 pci_read_config_byte(lpc_dev, CRVML_REG_GPIOEN, &dev_en); 189 pci_read_config_byte(lpc_dev, CRVML_REG_GPIOEN, &dev_en);
188 if (!(dev_en & CRVML_GPIOEN_BIT)) { 190 if (!(dev_en & CRVML_GPIOEN_BIT)) {
189 printk(KERN_ERR 191 pr_err("Carillo Ranch GPIO device was not enabled.\n");
190 "Carillo Ranch GPIO device was not enabled.\n");
191 pci_dev_put(lpc_dev); 192 pci_dev_put(lpc_dev);
192 return -ENODEV; 193 return -ENODEV;
193 } 194 }
@@ -270,7 +271,7 @@ static int __init cr_backlight_init(void)
270 return PTR_ERR(crp); 271 return PTR_ERR(crp);
271 } 272 }
272 273
273 printk("Carillo Ranch Backlight Driver Initialized.\n"); 274 pr_info("Carillo Ranch Backlight Driver Initialized.\n");
274 275
275 return 0; 276 return 0;
276} 277}
diff --git a/drivers/video/backlight/da903x_bl.c b/drivers/video/backlight/da903x_bl.c
index 30e19681a30b..573c7ece0fde 100644
--- a/drivers/video/backlight/da903x_bl.c
+++ b/drivers/video/backlight/da903x_bl.c
@@ -136,6 +136,7 @@ static int da903x_backlight_probe(struct platform_device *pdev)
136 da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2, 136 da903x_write(data->da903x_dev, DA9034_WLED_CONTROL2,
137 DA9034_WLED_ISET(pdata->output_current)); 137 DA9034_WLED_ISET(pdata->output_current));
138 138
139 memset(&props, 0, sizeof(props));
139 props.type = BACKLIGHT_RAW; 140 props.type = BACKLIGHT_RAW;
140 props.max_brightness = max_brightness; 141 props.max_brightness = max_brightness;
141 bl = backlight_device_register(pdev->name, data->da903x_dev, data, 142 bl = backlight_device_register(pdev->name, data->da903x_dev, data,
diff --git a/drivers/video/backlight/generic_bl.c b/drivers/video/backlight/generic_bl.c
index 9ce6170c1860..8c660fcd250d 100644
--- a/drivers/video/backlight/generic_bl.c
+++ b/drivers/video/backlight/generic_bl.c
@@ -9,6 +9,8 @@
9 * 9 *
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/module.h> 14#include <linux/module.h>
13#include <linux/kernel.h> 15#include <linux/kernel.h>
14#include <linux/init.h> 16#include <linux/init.h>
@@ -106,7 +108,7 @@ static int genericbl_probe(struct platform_device *pdev)
106 108
107 generic_backlight_device = bd; 109 generic_backlight_device = bd;
108 110
109 printk("Generic Backlight Driver Initialized.\n"); 111 pr_info("Generic Backlight Driver Initialized.\n");
110 return 0; 112 return 0;
111} 113}
112 114
@@ -120,7 +122,7 @@ static int genericbl_remove(struct platform_device *pdev)
120 122
121 backlight_device_unregister(bd); 123 backlight_device_unregister(bd);
122 124
123 printk("Generic Backlight Driver Unloaded\n"); 125 pr_info("Generic Backlight Driver Unloaded\n");
124 return 0; 126 return 0;
125} 127}
126 128
diff --git a/drivers/video/backlight/ili9320.c b/drivers/video/backlight/ili9320.c
index 5118a9f029ab..6c9399341bcf 100644
--- a/drivers/video/backlight/ili9320.c
+++ b/drivers/video/backlight/ili9320.c
@@ -220,7 +220,7 @@ int __devinit ili9320_probe_spi(struct spi_device *spi,
220 220
221 /* allocate and initialse our state */ 221 /* allocate and initialse our state */
222 222
223 ili = kzalloc(sizeof(struct ili9320), GFP_KERNEL); 223 ili = devm_kzalloc(&spi->dev, sizeof(struct ili9320), GFP_KERNEL);
224 if (ili == NULL) { 224 if (ili == NULL) {
225 dev_err(dev, "no memory for device\n"); 225 dev_err(dev, "no memory for device\n");
226 return -ENOMEM; 226 return -ENOMEM;
@@ -240,8 +240,7 @@ int __devinit ili9320_probe_spi(struct spi_device *spi,
240 lcd = lcd_device_register("ili9320", dev, ili, &ili9320_ops); 240 lcd = lcd_device_register("ili9320", dev, ili, &ili9320_ops);
241 if (IS_ERR(lcd)) { 241 if (IS_ERR(lcd)) {
242 dev_err(dev, "failed to register lcd device\n"); 242 dev_err(dev, "failed to register lcd device\n");
243 ret = PTR_ERR(lcd); 243 return PTR_ERR(lcd);
244 goto err_free;
245 } 244 }
246 245
247 ili->lcd = lcd; 246 ili->lcd = lcd;
@@ -259,9 +258,6 @@ int __devinit ili9320_probe_spi(struct spi_device *spi,
259 err_unregister: 258 err_unregister:
260 lcd_device_unregister(lcd); 259 lcd_device_unregister(lcd);
261 260
262 err_free:
263 kfree(ili);
264
265 return ret; 261 return ret;
266} 262}
267 263
@@ -272,7 +268,6 @@ int __devexit ili9320_remove(struct ili9320 *ili)
272 ili9320_power(ili, FB_BLANK_POWERDOWN); 268 ili9320_power(ili, FB_BLANK_POWERDOWN);
273 269
274 lcd_device_unregister(ili->lcd); 270 lcd_device_unregister(ili->lcd);
275 kfree(ili);
276 271
277 return 0; 272 return 0;
278} 273}
diff --git a/drivers/video/backlight/jornada720_bl.c b/drivers/video/backlight/jornada720_bl.c
index 2f8af5d786ab..16f593b64427 100644
--- a/drivers/video/backlight/jornada720_bl.c
+++ b/drivers/video/backlight/jornada720_bl.c
@@ -9,6 +9,8 @@
9 * 9 *
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/backlight.h> 14#include <linux/backlight.h>
13#include <linux/device.h> 15#include <linux/device.h>
14#include <linux/fb.h> 16#include <linux/fb.h>
@@ -38,7 +40,7 @@ static int jornada_bl_get_brightness(struct backlight_device *bd)
38 ret = jornada_ssp_byte(GETBRIGHTNESS); 40 ret = jornada_ssp_byte(GETBRIGHTNESS);
39 41
40 if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) { 42 if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) {
41 printk(KERN_ERR "bl : get brightness timeout\n"); 43 pr_err("get brightness timeout\n");
42 jornada_ssp_end(); 44 jornada_ssp_end();
43 return -ETIMEDOUT; 45 return -ETIMEDOUT;
44 } else /* exchange txdummy for value */ 46 } else /* exchange txdummy for value */
@@ -59,7 +61,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
59 if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) { 61 if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
60 ret = jornada_ssp_byte(BRIGHTNESSOFF); 62 ret = jornada_ssp_byte(BRIGHTNESSOFF);
61 if (ret != TXDUMMY) { 63 if (ret != TXDUMMY) {
62 printk(KERN_INFO "bl : brightness off timeout\n"); 64 pr_info("brightness off timeout\n");
63 /* turn off backlight */ 65 /* turn off backlight */
64 PPSR &= ~PPC_LDD1; 66 PPSR &= ~PPC_LDD1;
65 PPDR |= PPC_LDD1; 67 PPDR |= PPC_LDD1;
@@ -70,7 +72,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
70 72
71 /* send command to our mcu */ 73 /* send command to our mcu */
72 if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) { 74 if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) {
73 printk(KERN_INFO "bl : failed to set brightness\n"); 75 pr_info("failed to set brightness\n");
74 ret = -ETIMEDOUT; 76 ret = -ETIMEDOUT;
75 goto out; 77 goto out;
76 } 78 }
@@ -81,7 +83,7 @@ static int jornada_bl_update_status(struct backlight_device *bd)
81 but due to physical layout it is equal to 0, so we simply 83 but due to physical layout it is equal to 0, so we simply
82 invert the value (MAX VALUE - NEW VALUE). */ 84 invert the value (MAX VALUE - NEW VALUE). */
83 if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) != TXDUMMY) { 85 if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness) != TXDUMMY) {
84 printk(KERN_ERR "bl : set brightness failed\n"); 86 pr_err("set brightness failed\n");
85 ret = -ETIMEDOUT; 87 ret = -ETIMEDOUT;
86 } 88 }
87 89
@@ -113,7 +115,7 @@ static int jornada_bl_probe(struct platform_device *pdev)
113 115
114 if (IS_ERR(bd)) { 116 if (IS_ERR(bd)) {
115 ret = PTR_ERR(bd); 117 ret = PTR_ERR(bd);
116 printk(KERN_ERR "bl : failed to register device, err=%x\n", ret); 118 pr_err("failed to register device, err=%x\n", ret);
117 return ret; 119 return ret;
118 } 120 }
119 121
@@ -125,7 +127,7 @@ static int jornada_bl_probe(struct platform_device *pdev)
125 jornada_bl_update_status(bd); 127 jornada_bl_update_status(bd);
126 128
127 platform_set_drvdata(pdev, bd); 129 platform_set_drvdata(pdev, bd);
128 printk(KERN_INFO "HP Jornada 700 series backlight driver\n"); 130 pr_info("HP Jornada 700 series backlight driver\n");
129 131
130 return 0; 132 return 0;
131} 133}
diff --git a/drivers/video/backlight/jornada720_lcd.c b/drivers/video/backlight/jornada720_lcd.c
index 22d231a17e3c..635b30523fd5 100644
--- a/drivers/video/backlight/jornada720_lcd.c
+++ b/drivers/video/backlight/jornada720_lcd.c
@@ -9,6 +9,8 @@
9 * 9 *
10 */ 10 */
11 11
12#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13
12#include <linux/device.h> 14#include <linux/device.h>
13#include <linux/fb.h> 15#include <linux/fb.h>
14#include <linux/kernel.h> 16#include <linux/kernel.h>
@@ -44,7 +46,7 @@ static int jornada_lcd_get_contrast(struct lcd_device *dev)
44 jornada_ssp_start(); 46 jornada_ssp_start();
45 47
46 if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) { 48 if (jornada_ssp_byte(GETCONTRAST) != TXDUMMY) {
47 printk(KERN_ERR "lcd: get contrast failed\n"); 49 pr_err("get contrast failed\n");
48 jornada_ssp_end(); 50 jornada_ssp_end();
49 return -ETIMEDOUT; 51 return -ETIMEDOUT;
50 } else { 52 } else {
@@ -65,7 +67,7 @@ static int jornada_lcd_set_contrast(struct lcd_device *dev, int value)
65 67
66 /* push the new value */ 68 /* push the new value */
67 if (jornada_ssp_byte(value) != TXDUMMY) { 69 if (jornada_ssp_byte(value) != TXDUMMY) {
68 printk(KERN_ERR "lcd : set contrast failed\n"); 70 pr_err("set contrast failed\n");
69 jornada_ssp_end(); 71 jornada_ssp_end();
70 return -ETIMEDOUT; 72 return -ETIMEDOUT;
71 } 73 }
@@ -103,7 +105,7 @@ static int jornada_lcd_probe(struct platform_device *pdev)
103 105
104 if (IS_ERR(lcd_device)) { 106 if (IS_ERR(lcd_device)) {
105 ret = PTR_ERR(lcd_device); 107 ret = PTR_ERR(lcd_device);
106 printk(KERN_ERR "lcd : failed to register device\n"); 108 pr_err("failed to register device\n");
107 return ret; 109 return ret;
108 } 110 }
109 111
diff --git a/drivers/video/backlight/l4f00242t03.c b/drivers/video/backlight/l4f00242t03.c
index 6022b67285ec..40f606a86093 100644
--- a/drivers/video/backlight/l4f00242t03.c
+++ b/drivers/video/backlight/l4f00242t03.c
@@ -11,6 +11,8 @@
11 * published by the Free Software Foundation. 11 * published by the Free Software Foundation.
12 */ 12 */
13 13
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15
14#include <linux/device.h> 16#include <linux/device.h>
15#include <linux/kernel.h> 17#include <linux/kernel.h>
16#include <linux/delay.h> 18#include <linux/delay.h>
@@ -159,7 +161,8 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
159 return -EINVAL; 161 return -EINVAL;
160 } 162 }
161 163
162 priv = kzalloc(sizeof(struct l4f00242t03_priv), GFP_KERNEL); 164 priv = devm_kzalloc(&spi->dev, sizeof(struct l4f00242t03_priv),
165 GFP_KERNEL);
163 166
164 if (priv == NULL) { 167 if (priv == NULL) {
165 dev_err(&spi->dev, "No memory for this device.\n"); 168 dev_err(&spi->dev, "No memory for this device.\n");
@@ -177,7 +180,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
177 if (ret) { 180 if (ret) {
178 dev_err(&spi->dev, 181 dev_err(&spi->dev,
179 "Unable to get the lcd l4f00242t03 reset gpio.\n"); 182 "Unable to get the lcd l4f00242t03 reset gpio.\n");
180 goto err; 183 return ret;
181 } 184 }
182 185
183 ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW, 186 ret = gpio_request_one(pdata->data_enable_gpio, GPIOF_OUT_INIT_LOW,
@@ -185,7 +188,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
185 if (ret) { 188 if (ret) {
186 dev_err(&spi->dev, 189 dev_err(&spi->dev,
187 "Unable to get the lcd l4f00242t03 data en gpio.\n"); 190 "Unable to get the lcd l4f00242t03 data en gpio.\n");
188 goto err2; 191 goto err;
189 } 192 }
190 193
191 priv->io_reg = regulator_get(&spi->dev, "vdd"); 194 priv->io_reg = regulator_get(&spi->dev, "vdd");
@@ -193,7 +196,7 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
193 ret = PTR_ERR(priv->io_reg); 196 ret = PTR_ERR(priv->io_reg);
194 dev_err(&spi->dev, "%s: Unable to get the IO regulator\n", 197 dev_err(&spi->dev, "%s: Unable to get the IO regulator\n",
195 __func__); 198 __func__);
196 goto err3; 199 goto err2;
197 } 200 }
198 201
199 priv->core_reg = regulator_get(&spi->dev, "vcore"); 202 priv->core_reg = regulator_get(&spi->dev, "vcore");
@@ -201,14 +204,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
201 ret = PTR_ERR(priv->core_reg); 204 ret = PTR_ERR(priv->core_reg);
202 dev_err(&spi->dev, "%s: Unable to get the core regulator\n", 205 dev_err(&spi->dev, "%s: Unable to get the core regulator\n",
203 __func__); 206 __func__);
204 goto err4; 207 goto err3;
205 } 208 }
206 209
207 priv->ld = lcd_device_register("l4f00242t03", 210 priv->ld = lcd_device_register("l4f00242t03",
208 &spi->dev, priv, &l4f_ops); 211 &spi->dev, priv, &l4f_ops);
209 if (IS_ERR(priv->ld)) { 212 if (IS_ERR(priv->ld)) {
210 ret = PTR_ERR(priv->ld); 213 ret = PTR_ERR(priv->ld);
211 goto err5; 214 goto err4;
212 } 215 }
213 216
214 /* Init the LCD */ 217 /* Init the LCD */
@@ -220,16 +223,14 @@ static int __devinit l4f00242t03_probe(struct spi_device *spi)
220 223
221 return 0; 224 return 0;
222 225
223err5:
224 regulator_put(priv->core_reg);
225err4: 226err4:
226 regulator_put(priv->io_reg); 227 regulator_put(priv->core_reg);
227err3: 228err3:
228 gpio_free(pdata->data_enable_gpio); 229 regulator_put(priv->io_reg);
229err2: 230err2:
230 gpio_free(pdata->reset_gpio); 231 gpio_free(pdata->data_enable_gpio);
231err: 232err:
232 kfree(priv); 233 gpio_free(pdata->reset_gpio);
233 234
234 return ret; 235 return ret;
235} 236}
@@ -250,8 +251,6 @@ static int __devexit l4f00242t03_remove(struct spi_device *spi)
250 regulator_put(priv->io_reg); 251 regulator_put(priv->io_reg);
251 regulator_put(priv->core_reg); 252 regulator_put(priv->core_reg);
252 253
253 kfree(priv);
254
255 return 0; 254 return 0;
256} 255}
257 256
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 79c1b0d609a8..a5d0d024bb92 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -5,6 +5,8 @@
5 * 5 *
6 */ 6 */
7 7
8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
9
8#include <linux/module.h> 10#include <linux/module.h>
9#include <linux/init.h> 11#include <linux/init.h>
10#include <linux/device.h> 12#include <linux/device.h>
@@ -32,6 +34,8 @@ static int fb_notifier_callback(struct notifier_block *self,
32 case FB_EVENT_BLANK: 34 case FB_EVENT_BLANK:
33 case FB_EVENT_MODE_CHANGE: 35 case FB_EVENT_MODE_CHANGE:
34 case FB_EVENT_MODE_CHANGE_ALL: 36 case FB_EVENT_MODE_CHANGE_ALL:
37 case FB_EARLY_EVENT_BLANK:
38 case FB_R_EARLY_EVENT_BLANK:
35 break; 39 break;
36 default: 40 default:
37 return 0; 41 return 0;
@@ -46,6 +50,14 @@ static int fb_notifier_callback(struct notifier_block *self,
46 if (event == FB_EVENT_BLANK) { 50 if (event == FB_EVENT_BLANK) {
47 if (ld->ops->set_power) 51 if (ld->ops->set_power)
48 ld->ops->set_power(ld, *(int *)evdata->data); 52 ld->ops->set_power(ld, *(int *)evdata->data);
53 } else if (event == FB_EARLY_EVENT_BLANK) {
54 if (ld->ops->early_set_power)
55 ld->ops->early_set_power(ld,
56 *(int *)evdata->data);
57 } else if (event == FB_R_EARLY_EVENT_BLANK) {
58 if (ld->ops->r_early_set_power)
59 ld->ops->r_early_set_power(ld,
60 *(int *)evdata->data);
49 } else { 61 } else {
50 if (ld->ops->set_mode) 62 if (ld->ops->set_mode)
51 ld->ops->set_mode(ld, evdata->data); 63 ld->ops->set_mode(ld, evdata->data);
@@ -106,7 +118,7 @@ static ssize_t lcd_store_power(struct device *dev,
106 118
107 mutex_lock(&ld->ops_lock); 119 mutex_lock(&ld->ops_lock);
108 if (ld->ops && ld->ops->set_power) { 120 if (ld->ops && ld->ops->set_power) {
109 pr_debug("lcd: set power to %lu\n", power); 121 pr_debug("set power to %lu\n", power);
110 ld->ops->set_power(ld, power); 122 ld->ops->set_power(ld, power);
111 rc = count; 123 rc = count;
112 } 124 }
@@ -142,7 +154,7 @@ static ssize_t lcd_store_contrast(struct device *dev,
142 154
143 mutex_lock(&ld->ops_lock); 155 mutex_lock(&ld->ops_lock);
144 if (ld->ops && ld->ops->set_contrast) { 156 if (ld->ops && ld->ops->set_contrast) {
145 pr_debug("lcd: set contrast to %lu\n", contrast); 157 pr_debug("set contrast to %lu\n", contrast);
146 ld->ops->set_contrast(ld, contrast); 158 ld->ops->set_contrast(ld, contrast);
147 rc = count; 159 rc = count;
148 } 160 }
@@ -253,8 +265,8 @@ static int __init lcd_class_init(void)
253{ 265{
254 lcd_class = class_create(THIS_MODULE, "lcd"); 266 lcd_class = class_create(THIS_MODULE, "lcd");
255 if (IS_ERR(lcd_class)) { 267 if (IS_ERR(lcd_class)) {
256 printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n", 268 pr_warn("Unable to create backlight class; errno = %ld\n",
257 PTR_ERR(lcd_class)); 269 PTR_ERR(lcd_class));
258 return PTR_ERR(lcd_class); 270 return PTR_ERR(lcd_class);
259 } 271 }
260 272
diff --git a/drivers/video/backlight/ld9040.c b/drivers/video/backlight/ld9040.c
index efd352be21ae..58f517fb7d40 100644
--- a/drivers/video/backlight/ld9040.c
+++ b/drivers/video/backlight/ld9040.c
@@ -707,7 +707,7 @@ static int ld9040_probe(struct spi_device *spi)
707 struct backlight_device *bd = NULL; 707 struct backlight_device *bd = NULL;
708 struct backlight_properties props; 708 struct backlight_properties props;
709 709
710 lcd = kzalloc(sizeof(struct ld9040), GFP_KERNEL); 710 lcd = devm_kzalloc(&spi->dev, sizeof(struct ld9040), GFP_KERNEL);
711 if (!lcd) 711 if (!lcd)
712 return -ENOMEM; 712 return -ENOMEM;
713 713
@@ -717,7 +717,7 @@ static int ld9040_probe(struct spi_device *spi)
717 ret = spi_setup(spi); 717 ret = spi_setup(spi);
718 if (ret < 0) { 718 if (ret < 0) {
719 dev_err(&spi->dev, "spi setup failed.\n"); 719 dev_err(&spi->dev, "spi setup failed.\n");
720 goto out_free_lcd; 720 return ret;
721 } 721 }
722 722
723 lcd->spi = spi; 723 lcd->spi = spi;
@@ -726,7 +726,7 @@ static int ld9040_probe(struct spi_device *spi)
726 lcd->lcd_pd = spi->dev.platform_data; 726 lcd->lcd_pd = spi->dev.platform_data;
727 if (!lcd->lcd_pd) { 727 if (!lcd->lcd_pd) {
728 dev_err(&spi->dev, "platform data is NULL.\n"); 728 dev_err(&spi->dev, "platform data is NULL.\n");
729 goto out_free_lcd; 729 return -EFAULT;
730 } 730 }
731 731
732 mutex_init(&lcd->lock); 732 mutex_init(&lcd->lock);
@@ -734,13 +734,13 @@ static int ld9040_probe(struct spi_device *spi)
734 ret = regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies); 734 ret = regulator_bulk_get(lcd->dev, ARRAY_SIZE(supplies), supplies);
735 if (ret) { 735 if (ret) {
736 dev_err(lcd->dev, "Failed to get regulators: %d\n", ret); 736 dev_err(lcd->dev, "Failed to get regulators: %d\n", ret);
737 goto out_free_lcd; 737 return ret;
738 } 738 }
739 739
740 ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops); 740 ld = lcd_device_register("ld9040", &spi->dev, lcd, &ld9040_lcd_ops);
741 if (IS_ERR(ld)) { 741 if (IS_ERR(ld)) {
742 ret = PTR_ERR(ld); 742 ret = PTR_ERR(ld);
743 goto out_free_lcd; 743 goto out_free_regulator;
744 } 744 }
745 745
746 lcd->ld = ld; 746 lcd->ld = ld;
@@ -782,10 +782,9 @@ static int ld9040_probe(struct spi_device *spi)
782 782
783out_unregister_lcd: 783out_unregister_lcd:
784 lcd_device_unregister(lcd->ld); 784 lcd_device_unregister(lcd->ld);
785out_free_lcd: 785out_free_regulator:
786 regulator_bulk_free(ARRAY_SIZE(supplies), supplies); 786 regulator_bulk_free(ARRAY_SIZE(supplies), supplies);
787 787
788 kfree(lcd);
789 return ret; 788 return ret;
790} 789}
791 790
@@ -797,7 +796,6 @@ static int __devexit ld9040_remove(struct spi_device *spi)
797 backlight_device_unregister(lcd->bd); 796 backlight_device_unregister(lcd->bd);
798 lcd_device_unregister(lcd->ld); 797 lcd_device_unregister(lcd->ld);
799 regulator_bulk_free(ARRAY_SIZE(supplies), supplies); 798 regulator_bulk_free(ARRAY_SIZE(supplies), supplies);
800 kfree(lcd);
801 799
802 return 0; 800 return 0;
803} 801}
@@ -846,7 +844,6 @@ static void ld9040_shutdown(struct spi_device *spi)
846static struct spi_driver ld9040_driver = { 844static struct spi_driver ld9040_driver = {
847 .driver = { 845 .driver = {
848 .name = "ld9040", 846 .name = "ld9040",
849 .bus = &spi_bus_type,
850 .owner = THIS_MODULE, 847 .owner = THIS_MODULE,
851 }, 848 },
852 .probe = ld9040_probe, 849 .probe = ld9040_probe,
diff --git a/drivers/video/backlight/lm3533_bl.c b/drivers/video/backlight/lm3533_bl.c
new file mode 100644
index 000000000000..bebeb63607db
--- /dev/null
+++ b/drivers/video/backlight/lm3533_bl.c
@@ -0,0 +1,423 @@
1/*
2 * lm3533-bl.c -- LM3533 Backlight driver
3 *
4 * Copyright (C) 2011-2012 Texas Instruments
5 *
6 * Author: Johan Hovold <jhovold@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 */
13
14#include <linux/module.h>
15#include <linux/init.h>
16#include <linux/platform_device.h>
17#include <linux/backlight.h>
18#include <linux/fb.h>
19#include <linux/slab.h>
20
21#include <linux/mfd/lm3533.h>
22
23
24#define LM3533_HVCTRLBANK_COUNT 2
25#define LM3533_BL_MAX_BRIGHTNESS 255
26
27#define LM3533_REG_CTRLBANK_AB_BCONF 0x1a
28
29
30struct lm3533_bl {
31 struct lm3533 *lm3533;
32 struct lm3533_ctrlbank cb;
33 struct backlight_device *bd;
34 int id;
35};
36
37
38static inline int lm3533_bl_get_ctrlbank_id(struct lm3533_bl *bl)
39{
40 return bl->id;
41}
42
43static int lm3533_bl_update_status(struct backlight_device *bd)
44{
45 struct lm3533_bl *bl = bl_get_data(bd);
46 int brightness = bd->props.brightness;
47
48 if (bd->props.power != FB_BLANK_UNBLANK)
49 brightness = 0;
50 if (bd->props.fb_blank != FB_BLANK_UNBLANK)
51 brightness = 0;
52
53 return lm3533_ctrlbank_set_brightness(&bl->cb, (u8)brightness);
54}
55
56static int lm3533_bl_get_brightness(struct backlight_device *bd)
57{
58 struct lm3533_bl *bl = bl_get_data(bd);
59 u8 val;
60 int ret;
61
62 ret = lm3533_ctrlbank_get_brightness(&bl->cb, &val);
63 if (ret)
64 return ret;
65
66 return val;
67}
68
69static const struct backlight_ops lm3533_bl_ops = {
70 .get_brightness = lm3533_bl_get_brightness,
71 .update_status = lm3533_bl_update_status,
72};
73
74static ssize_t show_id(struct device *dev,
75 struct device_attribute *attr, char *buf)
76{
77 struct lm3533_bl *bl = dev_get_drvdata(dev);
78
79 return scnprintf(buf, PAGE_SIZE, "%d\n", bl->id);
80}
81
82static ssize_t show_als_channel(struct device *dev,
83 struct device_attribute *attr, char *buf)
84{
85 struct lm3533_bl *bl = dev_get_drvdata(dev);
86 unsigned channel = lm3533_bl_get_ctrlbank_id(bl);
87
88 return scnprintf(buf, PAGE_SIZE, "%u\n", channel);
89}
90
91static ssize_t show_als_en(struct device *dev,
92 struct device_attribute *attr, char *buf)
93{
94 struct lm3533_bl *bl = dev_get_drvdata(dev);
95 int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
96 u8 val;
97 u8 mask;
98 bool enable;
99 int ret;
100
101 ret = lm3533_read(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, &val);
102 if (ret)
103 return ret;
104
105 mask = 1 << (2 * ctrlbank);
106 enable = val & mask;
107
108 return scnprintf(buf, PAGE_SIZE, "%d\n", enable);
109}
110
111static ssize_t store_als_en(struct device *dev,
112 struct device_attribute *attr,
113 const char *buf, size_t len)
114{
115 struct lm3533_bl *bl = dev_get_drvdata(dev);
116 int ctrlbank = lm3533_bl_get_ctrlbank_id(bl);
117 int enable;
118 u8 val;
119 u8 mask;
120 int ret;
121
122 if (kstrtoint(buf, 0, &enable))
123 return -EINVAL;
124
125 mask = 1 << (2 * ctrlbank);
126
127 if (enable)
128 val = mask;
129 else
130 val = 0;
131
132 ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val,
133 mask);
134 if (ret)
135 return ret;
136
137 return len;
138}
139
140static ssize_t show_linear(struct device *dev,
141 struct device_attribute *attr, char *buf)
142{
143 struct lm3533_bl *bl = dev_get_drvdata(dev);
144 u8 val;
145 u8 mask;
146 int linear;
147 int ret;
148
149 ret = lm3533_read(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, &val);
150 if (ret)
151 return ret;
152
153 mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
154
155 if (val & mask)
156 linear = 1;
157 else
158 linear = 0;
159
160 return scnprintf(buf, PAGE_SIZE, "%x\n", linear);
161}
162
163static ssize_t store_linear(struct device *dev,
164 struct device_attribute *attr,
165 const char *buf, size_t len)
166{
167 struct lm3533_bl *bl = dev_get_drvdata(dev);
168 unsigned long linear;
169 u8 mask;
170 u8 val;
171 int ret;
172
173 if (kstrtoul(buf, 0, &linear))
174 return -EINVAL;
175
176 mask = 1 << (2 * lm3533_bl_get_ctrlbank_id(bl) + 1);
177
178 if (linear)
179 val = mask;
180 else
181 val = 0;
182
183 ret = lm3533_update(bl->lm3533, LM3533_REG_CTRLBANK_AB_BCONF, val,
184 mask);
185 if (ret)
186 return ret;
187
188 return len;
189}
190
191static ssize_t show_pwm(struct device *dev,
192 struct device_attribute *attr,
193 char *buf)
194{
195 struct lm3533_bl *bl = dev_get_drvdata(dev);
196 u8 val;
197 int ret;
198
199 ret = lm3533_ctrlbank_get_pwm(&bl->cb, &val);
200 if (ret)
201 return ret;
202
203 return scnprintf(buf, PAGE_SIZE, "%u\n", val);
204}
205
206static ssize_t store_pwm(struct device *dev,
207 struct device_attribute *attr,
208 const char *buf, size_t len)
209{
210 struct lm3533_bl *bl = dev_get_drvdata(dev);
211 u8 val;
212 int ret;
213
214 if (kstrtou8(buf, 0, &val))
215 return -EINVAL;
216
217 ret = lm3533_ctrlbank_set_pwm(&bl->cb, val);
218 if (ret)
219 return ret;
220
221 return len;
222}
223
224static LM3533_ATTR_RO(als_channel);
225static LM3533_ATTR_RW(als_en);
226static LM3533_ATTR_RO(id);
227static LM3533_ATTR_RW(linear);
228static LM3533_ATTR_RW(pwm);
229
230static struct attribute *lm3533_bl_attributes[] = {
231 &dev_attr_als_channel.attr,
232 &dev_attr_als_en.attr,
233 &dev_attr_id.attr,
234 &dev_attr_linear.attr,
235 &dev_attr_pwm.attr,
236 NULL,
237};
238
239static umode_t lm3533_bl_attr_is_visible(struct kobject *kobj,
240 struct attribute *attr, int n)
241{
242 struct device *dev = container_of(kobj, struct device, kobj);
243 struct lm3533_bl *bl = dev_get_drvdata(dev);
244 umode_t mode = attr->mode;
245
246 if (attr == &dev_attr_als_channel.attr ||
247 attr == &dev_attr_als_en.attr) {
248 if (!bl->lm3533->have_als)
249 mode = 0;
250 }
251
252 return mode;
253};
254
255static struct attribute_group lm3533_bl_attribute_group = {
256 .is_visible = lm3533_bl_attr_is_visible,
257 .attrs = lm3533_bl_attributes
258};
259
260static int __devinit lm3533_bl_setup(struct lm3533_bl *bl,
261 struct lm3533_bl_platform_data *pdata)
262{
263 int ret;
264
265 ret = lm3533_ctrlbank_set_max_current(&bl->cb, pdata->max_current);
266 if (ret)
267 return ret;
268
269 return lm3533_ctrlbank_set_pwm(&bl->cb, pdata->pwm);
270}
271
272static int __devinit lm3533_bl_probe(struct platform_device *pdev)
273{
274 struct lm3533 *lm3533;
275 struct lm3533_bl_platform_data *pdata;
276 struct lm3533_bl *bl;
277 struct backlight_device *bd;
278 struct backlight_properties props;
279 int ret;
280
281 dev_dbg(&pdev->dev, "%s\n", __func__);
282
283 lm3533 = dev_get_drvdata(pdev->dev.parent);
284 if (!lm3533)
285 return -EINVAL;
286
287 pdata = pdev->dev.platform_data;
288 if (!pdata) {
289 dev_err(&pdev->dev, "no platform data\n");
290 return -EINVAL;
291 }
292
293 if (pdev->id < 0 || pdev->id >= LM3533_HVCTRLBANK_COUNT) {
294 dev_err(&pdev->dev, "illegal backlight id %d\n", pdev->id);
295 return -EINVAL;
296 }
297
298 bl = kzalloc(sizeof(*bl), GFP_KERNEL);
299 if (!bl) {
300 dev_err(&pdev->dev,
301 "failed to allocate memory for backlight\n");
302 return -ENOMEM;
303 }
304
305 bl->lm3533 = lm3533;
306 bl->id = pdev->id;
307
308 bl->cb.lm3533 = lm3533;
309 bl->cb.id = lm3533_bl_get_ctrlbank_id(bl);
310 bl->cb.dev = NULL; /* until registered */
311
312 memset(&props, 0, sizeof(props));
313 props.type = BACKLIGHT_RAW;
314 props.max_brightness = LM3533_BL_MAX_BRIGHTNESS;
315 props.brightness = pdata->default_brightness;
316 bd = backlight_device_register(pdata->name, pdev->dev.parent, bl,
317 &lm3533_bl_ops, &props);
318 if (IS_ERR(bd)) {
319 dev_err(&pdev->dev, "failed to register backlight device\n");
320 ret = PTR_ERR(bd);
321 goto err_free;
322 }
323
324 bl->bd = bd;
325 bl->cb.dev = &bl->bd->dev;
326
327 platform_set_drvdata(pdev, bl);
328
329 ret = sysfs_create_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
330 if (ret < 0) {
331 dev_err(&pdev->dev, "failed to create sysfs attributes\n");
332 goto err_unregister;
333 }
334
335 backlight_update_status(bd);
336
337 ret = lm3533_bl_setup(bl, pdata);
338 if (ret)
339 goto err_sysfs_remove;
340
341 ret = lm3533_ctrlbank_enable(&bl->cb);
342 if (ret)
343 goto err_sysfs_remove;
344
345 return 0;
346
347err_sysfs_remove:
348 sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
349err_unregister:
350 backlight_device_unregister(bd);
351err_free:
352 kfree(bl);
353
354 return ret;
355}
356
357static int __devexit lm3533_bl_remove(struct platform_device *pdev)
358{
359 struct lm3533_bl *bl = platform_get_drvdata(pdev);
360 struct backlight_device *bd = bl->bd;
361
362 dev_dbg(&bd->dev, "%s\n", __func__);
363
364 bd->props.power = FB_BLANK_POWERDOWN;
365 bd->props.brightness = 0;
366
367 lm3533_ctrlbank_disable(&bl->cb);
368 sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
369 backlight_device_unregister(bd);
370 kfree(bl);
371
372 return 0;
373}
374
375#ifdef CONFIG_PM
376static int lm3533_bl_suspend(struct platform_device *pdev, pm_message_t state)
377{
378 struct lm3533_bl *bl = platform_get_drvdata(pdev);
379
380 dev_dbg(&pdev->dev, "%s\n", __func__);
381
382 return lm3533_ctrlbank_disable(&bl->cb);
383}
384
385static int lm3533_bl_resume(struct platform_device *pdev)
386{
387 struct lm3533_bl *bl = platform_get_drvdata(pdev);
388
389 dev_dbg(&pdev->dev, "%s\n", __func__);
390
391 return lm3533_ctrlbank_enable(&bl->cb);
392}
393#else
394#define lm3533_bl_suspend NULL
395#define lm3533_bl_resume NULL
396#endif
397
398static void lm3533_bl_shutdown(struct platform_device *pdev)
399{
400 struct lm3533_bl *bl = platform_get_drvdata(pdev);
401
402 dev_dbg(&pdev->dev, "%s\n", __func__);
403
404 lm3533_ctrlbank_disable(&bl->cb);
405}
406
407static struct platform_driver lm3533_bl_driver = {
408 .driver = {
409 .name = "lm3533-backlight",
410 .owner = THIS_MODULE,
411 },
412 .probe = lm3533_bl_probe,
413 .remove = __devexit_p(lm3533_bl_remove),
414 .shutdown = lm3533_bl_shutdown,
415 .suspend = lm3533_bl_suspend,
416 .resume = lm3533_bl_resume,
417};
418module_platform_driver(lm3533_bl_driver);
419
420MODULE_AUTHOR("Johan Hovold <jhovold@gmail.com>");
421MODULE_DESCRIPTION("LM3533 Backlight driver");
422MODULE_LICENSE("GPL");
423MODULE_ALIAS("platform:lm3533-backlight");
diff --git a/drivers/video/backlight/lms283gf05.c b/drivers/video/backlight/lms283gf05.c
index 4161f9e3982a..a9f2c36966f1 100644
--- a/drivers/video/backlight/lms283gf05.c
+++ b/drivers/video/backlight/lms283gf05.c
@@ -168,7 +168,8 @@ static int __devinit lms283gf05_probe(struct spi_device *spi)
168 goto err; 168 goto err;
169 } 169 }
170 170
171 st = kzalloc(sizeof(struct lms283gf05_state), GFP_KERNEL); 171 st = devm_kzalloc(&spi->dev, sizeof(struct lms283gf05_state),
172 GFP_KERNEL);
172 if (st == NULL) { 173 if (st == NULL) {
173 dev_err(&spi->dev, "No memory for device state\n"); 174 dev_err(&spi->dev, "No memory for device state\n");
174 ret = -ENOMEM; 175 ret = -ENOMEM;
@@ -178,7 +179,7 @@ static int __devinit lms283gf05_probe(struct spi_device *spi)
178 ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops); 179 ld = lcd_device_register("lms283gf05", &spi->dev, st, &lms_ops);
179 if (IS_ERR(ld)) { 180 if (IS_ERR(ld)) {
180 ret = PTR_ERR(ld); 181 ret = PTR_ERR(ld);
181 goto err2; 182 goto err;
182 } 183 }
183 184
184 st->spi = spi; 185 st->spi = spi;
@@ -193,8 +194,6 @@ static int __devinit lms283gf05_probe(struct spi_device *spi)
193 194
194 return 0; 195 return 0;
195 196
196err2:
197 kfree(st);
198err: 197err:
199 if (pdata != NULL) 198 if (pdata != NULL)
200 gpio_free(pdata->reset_gpio); 199 gpio_free(pdata->reset_gpio);
@@ -212,8 +211,6 @@ static int __devexit lms283gf05_remove(struct spi_device *spi)
212 if (pdata != NULL) 211 if (pdata != NULL)
213 gpio_free(pdata->reset_gpio); 212 gpio_free(pdata->reset_gpio);
214 213
215 kfree(st);
216
217 return 0; 214 return 0;
218} 215}
219 216
diff --git a/drivers/video/backlight/ltv350qv.c b/drivers/video/backlight/ltv350qv.c
index 333949ff3265..6c0f1ac0d32a 100644
--- a/drivers/video/backlight/ltv350qv.c
+++ b/drivers/video/backlight/ltv350qv.c
@@ -232,23 +232,20 @@ static int __devinit ltv350qv_probe(struct spi_device *spi)
232 struct lcd_device *ld; 232 struct lcd_device *ld;
233 int ret; 233 int ret;
234 234
235 lcd = kzalloc(sizeof(struct ltv350qv), GFP_KERNEL); 235 lcd = devm_kzalloc(&spi->dev, sizeof(struct ltv350qv), GFP_KERNEL);
236 if (!lcd) 236 if (!lcd)
237 return -ENOMEM; 237 return -ENOMEM;
238 238
239 lcd->spi = spi; 239 lcd->spi = spi;
240 lcd->power = FB_BLANK_POWERDOWN; 240 lcd->power = FB_BLANK_POWERDOWN;
241 lcd->buffer = kzalloc(8, GFP_KERNEL); 241 lcd->buffer = devm_kzalloc(&spi->dev, 8, GFP_KERNEL);
242 if (!lcd->buffer) { 242 if (!lcd->buffer)
243 ret = -ENOMEM; 243 return -ENOMEM;
244 goto out_free_lcd;
245 }
246 244
247 ld = lcd_device_register("ltv350qv", &spi->dev, lcd, &ltv_ops); 245 ld = lcd_device_register("ltv350qv", &spi->dev, lcd, &ltv_ops);
248 if (IS_ERR(ld)) { 246 if (IS_ERR(ld))
249 ret = PTR_ERR(ld); 247 return PTR_ERR(ld);
250 goto out_free_buffer; 248
251 }
252 lcd->ld = ld; 249 lcd->ld = ld;
253 250
254 ret = ltv350qv_power(lcd, FB_BLANK_UNBLANK); 251 ret = ltv350qv_power(lcd, FB_BLANK_UNBLANK);
@@ -261,10 +258,6 @@ static int __devinit ltv350qv_probe(struct spi_device *spi)
261 258
262out_unregister: 259out_unregister:
263 lcd_device_unregister(ld); 260 lcd_device_unregister(ld);
264out_free_buffer:
265 kfree(lcd->buffer);
266out_free_lcd:
267 kfree(lcd);
268 return ret; 261 return ret;
269} 262}
270 263
@@ -274,8 +267,6 @@ static int __devexit ltv350qv_remove(struct spi_device *spi)
274 267
275 ltv350qv_power(lcd, FB_BLANK_POWERDOWN); 268 ltv350qv_power(lcd, FB_BLANK_POWERDOWN);
276 lcd_device_unregister(lcd->ld); 269 lcd_device_unregister(lcd->ld);
277 kfree(lcd->buffer);
278 kfree(lcd);
279 270
280 return 0; 271 return 0;
281} 272}
@@ -310,7 +301,6 @@ static void ltv350qv_shutdown(struct spi_device *spi)
310static struct spi_driver ltv350qv_driver = { 301static struct spi_driver ltv350qv_driver = {
311 .driver = { 302 .driver = {
312 .name = "ltv350qv", 303 .name = "ltv350qv",
313 .bus = &spi_bus_type,
314 .owner = THIS_MODULE, 304 .owner = THIS_MODULE,
315 }, 305 },
316 306
diff --git a/drivers/video/backlight/omap1_bl.c b/drivers/video/backlight/omap1_bl.c
index 0175bfb08a1c..bfdc5fbeaa11 100644
--- a/drivers/video/backlight/omap1_bl.c
+++ b/drivers/video/backlight/omap1_bl.c
@@ -18,6 +18,8 @@
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */ 19 */
20 20
21#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22
21#include <linux/module.h> 23#include <linux/module.h>
22#include <linux/kernel.h> 24#include <linux/kernel.h>
23#include <linux/init.h> 25#include <linux/init.h>
@@ -168,7 +170,7 @@ static int omapbl_probe(struct platform_device *pdev)
168 dev->props.brightness = pdata->default_intensity; 170 dev->props.brightness = pdata->default_intensity;
169 omapbl_update_status(dev); 171 omapbl_update_status(dev);
170 172
171 printk(KERN_INFO "OMAP LCD backlight initialised\n"); 173 pr_info("OMAP LCD backlight initialised\n");
172 174
173 return 0; 175 return 0;
174} 176}
diff --git a/drivers/video/backlight/pcf50633-backlight.c b/drivers/video/backlight/pcf50633-backlight.c
index c65853cb9740..c092159f4383 100644
--- a/drivers/video/backlight/pcf50633-backlight.c
+++ b/drivers/video/backlight/pcf50633-backlight.c
@@ -111,6 +111,7 @@ static int __devinit pcf50633_bl_probe(struct platform_device *pdev)
111 if (!pcf_bl) 111 if (!pcf_bl)
112 return -ENOMEM; 112 return -ENOMEM;
113 113
114 memset(&bl_props, 0, sizeof(bl_props));
114 bl_props.type = BACKLIGHT_RAW; 115 bl_props.type = BACKLIGHT_RAW;
115 bl_props.max_brightness = 0x3f; 116 bl_props.max_brightness = 0x3f;
116 bl_props.power = FB_BLANK_UNBLANK; 117 bl_props.power = FB_BLANK_UNBLANK;
diff --git a/drivers/video/backlight/progear_bl.c b/drivers/video/backlight/progear_bl.c
index 6af183d6465e..69b35f02929e 100644
--- a/drivers/video/backlight/progear_bl.c
+++ b/drivers/video/backlight/progear_bl.c
@@ -15,6 +15,8 @@
15 * 15 *
16 */ 16 */
17 17
18#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
19
18#include <linux/module.h> 20#include <linux/module.h>
19#include <linux/kernel.h> 21#include <linux/kernel.h>
20#include <linux/init.h> 22#include <linux/init.h>
@@ -68,13 +70,13 @@ static int progearbl_probe(struct platform_device *pdev)
68 70
69 pmu_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, NULL); 71 pmu_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, NULL);
70 if (!pmu_dev) { 72 if (!pmu_dev) {
71 printk("ALI M7101 PMU not found.\n"); 73 pr_err("ALI M7101 PMU not found.\n");
72 return -ENODEV; 74 return -ENODEV;
73 } 75 }
74 76
75 sb_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); 77 sb_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL);
76 if (!sb_dev) { 78 if (!sb_dev) {
77 printk("ALI 1533 SB not found.\n"); 79 pr_err("ALI 1533 SB not found.\n");
78 ret = -ENODEV; 80 ret = -ENODEV;
79 goto put_pmu; 81 goto put_pmu;
80 } 82 }
diff --git a/drivers/video/backlight/s6e63m0.c b/drivers/video/backlight/s6e63m0.c
index e264f55b2574..6437ae474cf2 100644
--- a/drivers/video/backlight/s6e63m0.c
+++ b/drivers/video/backlight/s6e63m0.c
@@ -741,7 +741,7 @@ static int __devinit s6e63m0_probe(struct spi_device *spi)
741 struct backlight_device *bd = NULL; 741 struct backlight_device *bd = NULL;
742 struct backlight_properties props; 742 struct backlight_properties props;
743 743
744 lcd = kzalloc(sizeof(struct s6e63m0), GFP_KERNEL); 744 lcd = devm_kzalloc(&spi->dev, sizeof(struct s6e63m0), GFP_KERNEL);
745 if (!lcd) 745 if (!lcd)
746 return -ENOMEM; 746 return -ENOMEM;
747 747
@@ -751,7 +751,7 @@ static int __devinit s6e63m0_probe(struct spi_device *spi)
751 ret = spi_setup(spi); 751 ret = spi_setup(spi);
752 if (ret < 0) { 752 if (ret < 0) {
753 dev_err(&spi->dev, "spi setup failed.\n"); 753 dev_err(&spi->dev, "spi setup failed.\n");
754 goto out_free_lcd; 754 return ret;
755 } 755 }
756 756
757 lcd->spi = spi; 757 lcd->spi = spi;
@@ -760,14 +760,12 @@ static int __devinit s6e63m0_probe(struct spi_device *spi)
760 lcd->lcd_pd = (struct lcd_platform_data *)spi->dev.platform_data; 760 lcd->lcd_pd = (struct lcd_platform_data *)spi->dev.platform_data;
761 if (!lcd->lcd_pd) { 761 if (!lcd->lcd_pd) {
762 dev_err(&spi->dev, "platform data is NULL.\n"); 762 dev_err(&spi->dev, "platform data is NULL.\n");
763 goto out_free_lcd; 763 return -EFAULT;
764 } 764 }
765 765
766 ld = lcd_device_register("s6e63m0", &spi->dev, lcd, &s6e63m0_lcd_ops); 766 ld = lcd_device_register("s6e63m0", &spi->dev, lcd, &s6e63m0_lcd_ops);
767 if (IS_ERR(ld)) { 767 if (IS_ERR(ld))
768 ret = PTR_ERR(ld); 768 return PTR_ERR(ld);
769 goto out_free_lcd;
770 }
771 769
772 lcd->ld = ld; 770 lcd->ld = ld;
773 771
@@ -824,8 +822,6 @@ static int __devinit s6e63m0_probe(struct spi_device *spi)
824 822
825out_lcd_unregister: 823out_lcd_unregister:
826 lcd_device_unregister(ld); 824 lcd_device_unregister(ld);
827out_free_lcd:
828 kfree(lcd);
829 return ret; 825 return ret;
830} 826}
831 827
@@ -838,7 +834,6 @@ static int __devexit s6e63m0_remove(struct spi_device *spi)
838 device_remove_file(&spi->dev, &dev_attr_gamma_mode); 834 device_remove_file(&spi->dev, &dev_attr_gamma_mode);
839 backlight_device_unregister(lcd->bd); 835 backlight_device_unregister(lcd->bd);
840 lcd_device_unregister(lcd->ld); 836 lcd_device_unregister(lcd->ld);
841 kfree(lcd);
842 837
843 return 0; 838 return 0;
844} 839}
@@ -899,7 +894,6 @@ static void s6e63m0_shutdown(struct spi_device *spi)
899static struct spi_driver s6e63m0_driver = { 894static struct spi_driver s6e63m0_driver = {
900 .driver = { 895 .driver = {
901 .name = "s6e63m0", 896 .name = "s6e63m0",
902 .bus = &spi_bus_type,
903 .owner = THIS_MODULE, 897 .owner = THIS_MODULE,
904 }, 898 },
905 .probe = s6e63m0_probe, 899 .probe = s6e63m0_probe,
diff --git a/drivers/video/backlight/tdo24m.c b/drivers/video/backlight/tdo24m.c
index 2368b8e5f89e..02444d042cd5 100644
--- a/drivers/video/backlight/tdo24m.c
+++ b/drivers/video/backlight/tdo24m.c
@@ -349,7 +349,7 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
349 if (err) 349 if (err)
350 return err; 350 return err;
351 351
352 lcd = kzalloc(sizeof(struct tdo24m), GFP_KERNEL); 352 lcd = devm_kzalloc(&spi->dev, sizeof(struct tdo24m), GFP_KERNEL);
353 if (!lcd) 353 if (!lcd)
354 return -ENOMEM; 354 return -ENOMEM;
355 355
@@ -357,11 +357,9 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
357 lcd->power = FB_BLANK_POWERDOWN; 357 lcd->power = FB_BLANK_POWERDOWN;
358 lcd->mode = MODE_VGA; /* default to VGA */ 358 lcd->mode = MODE_VGA; /* default to VGA */
359 359
360 lcd->buf = kmalloc(TDO24M_SPI_BUFF_SIZE, GFP_KERNEL); 360 lcd->buf = devm_kzalloc(&spi->dev, TDO24M_SPI_BUFF_SIZE, GFP_KERNEL);
361 if (lcd->buf == NULL) { 361 if (lcd->buf == NULL)
362 kfree(lcd);
363 return -ENOMEM; 362 return -ENOMEM;
364 }
365 363
366 m = &lcd->msg; 364 m = &lcd->msg;
367 x = &lcd->xfer; 365 x = &lcd->xfer;
@@ -383,15 +381,13 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
383 break; 381 break;
384 default: 382 default:
385 dev_err(&spi->dev, "Unsupported model"); 383 dev_err(&spi->dev, "Unsupported model");
386 goto out_free; 384 return -EINVAL;
387 } 385 }
388 386
389 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev, 387 lcd->lcd_dev = lcd_device_register("tdo24m", &spi->dev,
390 lcd, &tdo24m_ops); 388 lcd, &tdo24m_ops);
391 if (IS_ERR(lcd->lcd_dev)) { 389 if (IS_ERR(lcd->lcd_dev))
392 err = PTR_ERR(lcd->lcd_dev); 390 return PTR_ERR(lcd->lcd_dev);
393 goto out_free;
394 }
395 391
396 dev_set_drvdata(&spi->dev, lcd); 392 dev_set_drvdata(&spi->dev, lcd);
397 err = tdo24m_power(lcd, FB_BLANK_UNBLANK); 393 err = tdo24m_power(lcd, FB_BLANK_UNBLANK);
@@ -402,9 +398,6 @@ static int __devinit tdo24m_probe(struct spi_device *spi)
402 398
403out_unregister: 399out_unregister:
404 lcd_device_unregister(lcd->lcd_dev); 400 lcd_device_unregister(lcd->lcd_dev);
405out_free:
406 kfree(lcd->buf);
407 kfree(lcd);
408 return err; 401 return err;
409} 402}
410 403
@@ -414,8 +407,6 @@ static int __devexit tdo24m_remove(struct spi_device *spi)
414 407
415 tdo24m_power(lcd, FB_BLANK_POWERDOWN); 408 tdo24m_power(lcd, FB_BLANK_POWERDOWN);
416 lcd_device_unregister(lcd->lcd_dev); 409 lcd_device_unregister(lcd->lcd_dev);
417 kfree(lcd->buf);
418 kfree(lcd);
419 410
420 return 0; 411 return 0;
421} 412}
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c
index 2b241abced43..0d54e607e82d 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -82,8 +82,11 @@ static int __devinit tosa_bl_probe(struct i2c_client *client,
82 const struct i2c_device_id *id) 82 const struct i2c_device_id *id)
83{ 83{
84 struct backlight_properties props; 84 struct backlight_properties props;
85 struct tosa_bl_data *data = kzalloc(sizeof(struct tosa_bl_data), GFP_KERNEL); 85 struct tosa_bl_data *data;
86 int ret = 0; 86 int ret = 0;
87
88 data = devm_kzalloc(&client->dev, sizeof(struct tosa_bl_data),
89 GFP_KERNEL);
87 if (!data) 90 if (!data)
88 return -ENOMEM; 91 return -ENOMEM;
89 92
@@ -92,7 +95,7 @@ static int __devinit tosa_bl_probe(struct i2c_client *client,
92 ret = gpio_request(TOSA_GPIO_BL_C20MA, "backlight"); 95 ret = gpio_request(TOSA_GPIO_BL_C20MA, "backlight");
93 if (ret) { 96 if (ret) {
94 dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); 97 dev_dbg(&data->bl->dev, "Unable to request gpio!\n");
95 goto err_gpio_bl; 98 return ret;
96 } 99 }
97 ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); 100 ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0);
98 if (ret) 101 if (ret)
@@ -122,8 +125,6 @@ err_reg:
122 data->bl = NULL; 125 data->bl = NULL;
123err_gpio_dir: 126err_gpio_dir:
124 gpio_free(TOSA_GPIO_BL_C20MA); 127 gpio_free(TOSA_GPIO_BL_C20MA);
125err_gpio_bl:
126 kfree(data);
127 return ret; 128 return ret;
128} 129}
129 130
@@ -136,8 +137,6 @@ static int __devexit tosa_bl_remove(struct i2c_client *client)
136 137
137 gpio_free(TOSA_GPIO_BL_C20MA); 138 gpio_free(TOSA_GPIO_BL_C20MA);
138 139
139 kfree(data);
140
141 return 0; 140 return 0;
142} 141}
143 142
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c
index 2231aec23918..47823b8efff0 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -174,7 +174,8 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
174 int ret; 174 int ret;
175 struct tosa_lcd_data *data; 175 struct tosa_lcd_data *data;
176 176
177 data = kzalloc(sizeof(struct tosa_lcd_data), GFP_KERNEL); 177 data = devm_kzalloc(&spi->dev, sizeof(struct tosa_lcd_data),
178 GFP_KERNEL);
178 if (!data) 179 if (!data)
179 return -ENOMEM; 180 return -ENOMEM;
180 181
@@ -187,7 +188,7 @@ static int __devinit tosa_lcd_probe(struct spi_device *spi)
187 188
188 ret = spi_setup(spi); 189 ret = spi_setup(spi);
189 if (ret < 0) 190 if (ret < 0)
190 goto err_spi; 191 return ret;
191 192
192 data->spi = spi; 193 data->spi = spi;
193 dev_set_drvdata(&spi->dev, data); 194 dev_set_drvdata(&spi->dev, data);
@@ -224,8 +225,6 @@ err_gpio_dir:
224 gpio_free(TOSA_GPIO_TG_ON); 225 gpio_free(TOSA_GPIO_TG_ON);
225err_gpio_tg: 226err_gpio_tg:
226 dev_set_drvdata(&spi->dev, NULL); 227 dev_set_drvdata(&spi->dev, NULL);
227err_spi:
228 kfree(data);
229 return ret; 228 return ret;
230} 229}
231 230
@@ -242,7 +241,6 @@ static int __devexit tosa_lcd_remove(struct spi_device *spi)
242 241
243 gpio_free(TOSA_GPIO_TG_ON); 242 gpio_free(TOSA_GPIO_TG_ON);
244 dev_set_drvdata(&spi->dev, NULL); 243 dev_set_drvdata(&spi->dev, NULL);
245 kfree(data);
246 244
247 return 0; 245 return 0;
248} 246}
diff --git a/drivers/video/backlight/wm831x_bl.c b/drivers/video/backlight/wm831x_bl.c
index 5d365deb5f82..9e5517a3a52b 100644
--- a/drivers/video/backlight/wm831x_bl.c
+++ b/drivers/video/backlight/wm831x_bl.c
@@ -194,6 +194,7 @@ static int wm831x_backlight_probe(struct platform_device *pdev)
194 data->current_brightness = 0; 194 data->current_brightness = 0;
195 data->isink_reg = isink_reg; 195 data->isink_reg = isink_reg;
196 196
197 memset(&props, 0, sizeof(props));
197 props.type = BACKLIGHT_RAW; 198 props.type = BACKLIGHT_RAW;
198 props.max_brightness = max_isel; 199 props.max_brightness = max_isel;
199 bl = backlight_device_register("wm831x", &pdev->dev, data, 200 bl = backlight_device_register("wm831x", &pdev->dev, data,
diff --git a/drivers/video/bfin-lq035q1-fb.c b/drivers/video/bfin-lq035q1-fb.c
index 86922ac84412..353c02fe8a95 100644
--- a/drivers/video/bfin-lq035q1-fb.c
+++ b/drivers/video/bfin-lq035q1-fb.c
@@ -13,6 +13,7 @@
13#include <linux/errno.h> 13#include <linux/errno.h>
14#include <linux/string.h> 14#include <linux/string.h>
15#include <linux/fb.h> 15#include <linux/fb.h>
16#include <linux/gpio.h>
16#include <linux/slab.h> 17#include <linux/slab.h>
17#include <linux/init.h> 18#include <linux/init.h>
18#include <linux/types.h> 19#include <linux/types.h>
diff --git a/drivers/video/bfin_adv7393fb.c b/drivers/video/bfin_adv7393fb.c
index 1a268a294478..33ea874c87d2 100644
--- a/drivers/video/bfin_adv7393fb.c
+++ b/drivers/video/bfin_adv7393fb.c
@@ -414,14 +414,14 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
414 if (ret) { 414 if (ret) {
415 dev_err(&client->dev, "PPI0_FS3 GPIO request failed\n"); 415 dev_err(&client->dev, "PPI0_FS3 GPIO request failed\n");
416 ret = -EBUSY; 416 ret = -EBUSY;
417 goto out_8; 417 goto free_fbdev;
418 } 418 }
419 } 419 }
420 420
421 if (peripheral_request_list(ppi_pins, DRIVER_NAME)) { 421 if (peripheral_request_list(ppi_pins, DRIVER_NAME)) {
422 dev_err(&client->dev, "requesting PPI peripheral failed\n"); 422 dev_err(&client->dev, "requesting PPI peripheral failed\n");
423 ret = -EFAULT; 423 ret = -EFAULT;
424 goto out_8; 424 goto free_gpio;
425 } 425 }
426 426
427 fbdev->fb_mem = 427 fbdev->fb_mem =
@@ -432,7 +432,7 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
432 dev_err(&client->dev, "couldn't allocate dma buffer (%d bytes)\n", 432 dev_err(&client->dev, "couldn't allocate dma buffer (%d bytes)\n",
433 (u32) fbdev->fb_len); 433 (u32) fbdev->fb_len);
434 ret = -ENOMEM; 434 ret = -ENOMEM;
435 goto out_7; 435 goto free_ppi_pins;
436 } 436 }
437 437
438 fbdev->info.screen_base = (void *)fbdev->fb_mem; 438 fbdev->info.screen_base = (void *)fbdev->fb_mem;
@@ -464,27 +464,27 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
464 if (!fbdev->info.pseudo_palette) { 464 if (!fbdev->info.pseudo_palette) {
465 dev_err(&client->dev, "failed to allocate pseudo_palette\n"); 465 dev_err(&client->dev, "failed to allocate pseudo_palette\n");
466 ret = -ENOMEM; 466 ret = -ENOMEM;
467 goto out_6; 467 goto free_fb_mem;
468 } 468 }
469 469
470 if (fb_alloc_cmap(&fbdev->info.cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) < 0) { 470 if (fb_alloc_cmap(&fbdev->info.cmap, BFIN_LCD_NBR_PALETTE_ENTRIES, 0) < 0) {
471 dev_err(&client->dev, "failed to allocate colormap (%d entries)\n", 471 dev_err(&client->dev, "failed to allocate colormap (%d entries)\n",
472 BFIN_LCD_NBR_PALETTE_ENTRIES); 472 BFIN_LCD_NBR_PALETTE_ENTRIES);
473 ret = -EFAULT; 473 ret = -EFAULT;
474 goto out_5; 474 goto free_palette;
475 } 475 }
476 476
477 if (request_dma(CH_PPI, "BF5xx_PPI_DMA") < 0) { 477 if (request_dma(CH_PPI, "BF5xx_PPI_DMA") < 0) {
478 dev_err(&client->dev, "unable to request PPI DMA\n"); 478 dev_err(&client->dev, "unable to request PPI DMA\n");
479 ret = -EFAULT; 479 ret = -EFAULT;
480 goto out_4; 480 goto free_cmap;
481 } 481 }
482 482
483 if (request_irq(IRQ_PPI_ERROR, ppi_irq_error, 0, 483 if (request_irq(IRQ_PPI_ERROR, ppi_irq_error, 0,
484 "PPI ERROR", fbdev) < 0) { 484 "PPI ERROR", fbdev) < 0) {
485 dev_err(&client->dev, "unable to request PPI ERROR IRQ\n"); 485 dev_err(&client->dev, "unable to request PPI ERROR IRQ\n");
486 ret = -EFAULT; 486 ret = -EFAULT;
487 goto out_3; 487 goto free_ch_ppi;
488 } 488 }
489 489
490 fbdev->open = 0; 490 fbdev->open = 0;
@@ -494,14 +494,14 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
494 494
495 if (ret) { 495 if (ret) {
496 dev_err(&client->dev, "i2c attach: init error\n"); 496 dev_err(&client->dev, "i2c attach: init error\n");
497 goto out_1; 497 goto free_irq_ppi;
498 } 498 }
499 499
500 500
501 if (register_framebuffer(&fbdev->info) < 0) { 501 if (register_framebuffer(&fbdev->info) < 0) {
502 dev_err(&client->dev, "unable to register framebuffer\n"); 502 dev_err(&client->dev, "unable to register framebuffer\n");
503 ret = -EFAULT; 503 ret = -EFAULT;
504 goto out_1; 504 goto free_irq_ppi;
505 } 505 }
506 506
507 dev_info(&client->dev, "fb%d: %s frame buffer device\n", 507 dev_info(&client->dev, "fb%d: %s frame buffer device\n",
@@ -512,7 +512,7 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
512 if (!entry) { 512 if (!entry) {
513 dev_err(&client->dev, "unable to create /proc entry\n"); 513 dev_err(&client->dev, "unable to create /proc entry\n");
514 ret = -EFAULT; 514 ret = -EFAULT;
515 goto out_0; 515 goto free_fb;
516 } 516 }
517 517
518 entry->read_proc = adv7393_read_proc; 518 entry->read_proc = adv7393_read_proc;
@@ -521,22 +521,25 @@ static int __devinit bfin_adv7393_fb_probe(struct i2c_client *client,
521 521
522 return 0; 522 return 0;
523 523
524 out_0: 524free_fb:
525 unregister_framebuffer(&fbdev->info); 525 unregister_framebuffer(&fbdev->info);
526 out_1: 526free_irq_ppi:
527 free_irq(IRQ_PPI_ERROR, fbdev); 527 free_irq(IRQ_PPI_ERROR, fbdev);
528 out_3: 528free_ch_ppi:
529 free_dma(CH_PPI); 529 free_dma(CH_PPI);
530 out_4: 530free_cmap:
531 dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem,
532 fbdev->dma_handle);
533 out_5:
534 fb_dealloc_cmap(&fbdev->info.cmap); 531 fb_dealloc_cmap(&fbdev->info.cmap);
535 out_6: 532free_palette:
536 kfree(fbdev->info.pseudo_palette); 533 kfree(fbdev->info.pseudo_palette);
537 out_7: 534free_fb_mem:
535 dma_free_coherent(NULL, fbdev->fb_len, fbdev->fb_mem,
536 fbdev->dma_handle);
537free_ppi_pins:
538 peripheral_free_list(ppi_pins); 538 peripheral_free_list(ppi_pins);
539 out_8: 539free_gpio:
540 if (ANOMALY_05000400)
541 gpio_free(P_IDENT(P_PPI0_FS3));
542free_fbdev:
540 kfree(fbdev); 543 kfree(fbdev);
541 544
542 return ret; 545 return ret;
diff --git a/drivers/video/clps711xfb.c b/drivers/video/clps711xfb.c
index 99b354b8e257..f994c8b8f10a 100644
--- a/drivers/video/clps711xfb.c
+++ b/drivers/video/clps711xfb.c
@@ -33,7 +33,6 @@
33#include <asm/mach-types.h> 33#include <asm/mach-types.h>
34#include <linux/uaccess.h> 34#include <linux/uaccess.h>
35 35
36#include <asm/hardware/clps7111.h>
37#include <mach/syspld.h> 36#include <mach/syspld.h>
38 37
39struct fb_info *cfb; 38struct fb_info *cfb;
diff --git a/drivers/video/cobalt_lcdfb.c b/drivers/video/cobalt_lcdfb.c
index f56699d8122a..eae46f6457e2 100644
--- a/drivers/video/cobalt_lcdfb.c
+++ b/drivers/video/cobalt_lcdfb.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * Cobalt server LCD frame buffer driver. 2 * Cobalt/SEAD3 LCD frame buffer driver.
3 * 3 *
4 * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org> 4 * Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
5 * Copyright (C) 2012 MIPS Technologies, Inc.
5 * 6 *
6 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
@@ -62,6 +63,7 @@
62#define LCD_CUR_POS(x) ((x) & LCD_CUR_POS_MASK) 63#define LCD_CUR_POS(x) ((x) & LCD_CUR_POS_MASK)
63#define LCD_TEXT_POS(x) ((x) | LCD_TEXT_MODE) 64#define LCD_TEXT_POS(x) ((x) | LCD_TEXT_MODE)
64 65
66#ifdef CONFIG_MIPS_COBALT
65static inline void lcd_write_control(struct fb_info *info, u8 control) 67static inline void lcd_write_control(struct fb_info *info, u8 control)
66{ 68{
67 writel((u32)control << 24, info->screen_base); 69 writel((u32)control << 24, info->screen_base);
@@ -81,6 +83,47 @@ static inline u8 lcd_read_data(struct fb_info *info)
81{ 83{
82 return readl(info->screen_base + LCD_DATA_REG_OFFSET) >> 24; 84 return readl(info->screen_base + LCD_DATA_REG_OFFSET) >> 24;
83} 85}
86#else
87
88#define LCD_CTL 0x00
89#define LCD_DATA 0x08
90#define CPLD_STATUS 0x10
91#define CPLD_DATA 0x18
92
93static inline void cpld_wait(struct fb_info *info)
94{
95 do {
96 } while (readl(info->screen_base + CPLD_STATUS) & 1);
97}
98
99static inline void lcd_write_control(struct fb_info *info, u8 control)
100{
101 cpld_wait(info);
102 writel(control, info->screen_base + LCD_CTL);
103}
104
105static inline u8 lcd_read_control(struct fb_info *info)
106{
107 cpld_wait(info);
108 readl(info->screen_base + LCD_CTL);
109 cpld_wait(info);
110 return readl(info->screen_base + CPLD_DATA) & 0xff;
111}
112
113static inline void lcd_write_data(struct fb_info *info, u8 data)
114{
115 cpld_wait(info);
116 writel(data, info->screen_base + LCD_DATA);
117}
118
119static inline u8 lcd_read_data(struct fb_info *info)
120{
121 cpld_wait(info);
122 readl(info->screen_base + LCD_DATA);
123 cpld_wait(info);
124 return readl(info->screen_base + CPLD_DATA) & 0xff;
125}
126#endif
84 127
85static int lcd_busy_wait(struct fb_info *info) 128static int lcd_busy_wait(struct fb_info *info)
86{ 129{
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index 6468a297e341..39571f9e0162 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -22,7 +22,9 @@
22#include <linux/font.h> 22#include <linux/font.h>
23 23
24#include <asm/hardware.h> 24#include <asm/hardware.h>
25#include <asm/page.h>
25#include <asm/parisc-device.h> 26#include <asm/parisc-device.h>
27#include <asm/pdc.h>
26#include <asm/cacheflush.h> 28#include <asm/cacheflush.h>
27#include <asm/grfioctl.h> 29#include <asm/grfioctl.h>
28 30
diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
index 784139aed079..b4a632ada401 100644
--- a/drivers/video/efifb.c
+++ b/drivers/video/efifb.c
@@ -18,6 +18,8 @@
18 18
19static bool request_mem_succeeded = false; 19static bool request_mem_succeeded = false;
20 20
21static struct pci_dev *default_vga;
22
21static struct fb_var_screeninfo efifb_defined __devinitdata = { 23static struct fb_var_screeninfo efifb_defined __devinitdata = {
22 .activate = FB_ACTIVATE_NOW, 24 .activate = FB_ACTIVATE_NOW,
23 .height = -1, 25 .height = -1,
@@ -298,35 +300,72 @@ static struct fb_ops efifb_ops = {
298 .fb_imageblit = cfb_imageblit, 300 .fb_imageblit = cfb_imageblit,
299}; 301};
300 302
303struct pci_dev *vga_default_device(void)
304{
305 return default_vga;
306}
307
308EXPORT_SYMBOL_GPL(vga_default_device);
309
310void vga_set_default_device(struct pci_dev *pdev)
311{
312 default_vga = pdev;
313}
314
301static int __init efifb_setup(char *options) 315static int __init efifb_setup(char *options)
302{ 316{
303 char *this_opt; 317 char *this_opt;
304 int i; 318 int i;
319 struct pci_dev *dev = NULL;
320
321 if (options && *options) {
322 while ((this_opt = strsep(&options, ",")) != NULL) {
323 if (!*this_opt) continue;
324
325 for (i = 0; i < M_UNKNOWN; i++) {
326 if (!strcmp(this_opt, dmi_list[i].optname) &&
327 dmi_list[i].base != 0) {
328 screen_info.lfb_base = dmi_list[i].base;
329 screen_info.lfb_linelength = dmi_list[i].stride;
330 screen_info.lfb_width = dmi_list[i].width;
331 screen_info.lfb_height = dmi_list[i].height;
332 }
333 }
334 if (!strncmp(this_opt, "base:", 5))
335 screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
336 else if (!strncmp(this_opt, "stride:", 7))
337 screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
338 else if (!strncmp(this_opt, "height:", 7))
339 screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
340 else if (!strncmp(this_opt, "width:", 6))
341 screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
342 }
343 }
305 344
306 if (!options || !*options) 345 for_each_pci_dev(dev) {
307 return 0; 346 int i;
308 347
309 while ((this_opt = strsep(&options, ",")) != NULL) { 348 if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
310 if (!*this_opt) continue; 349 continue;
311 350
312 for (i = 0; i < M_UNKNOWN; i++) { 351 for (i=0; i < DEVICE_COUNT_RESOURCE; i++) {
313 if (!strcmp(this_opt, dmi_list[i].optname) && 352 resource_size_t start, end;
314 dmi_list[i].base != 0) { 353
315 screen_info.lfb_base = dmi_list[i].base; 354 if (!(pci_resource_flags(dev, i) & IORESOURCE_MEM))
316 screen_info.lfb_linelength = dmi_list[i].stride; 355 continue;
317 screen_info.lfb_width = dmi_list[i].width; 356
318 screen_info.lfb_height = dmi_list[i].height; 357 start = pci_resource_start(dev, i);
319 } 358 end = pci_resource_end(dev, i);
359
360 if (!start || !end)
361 continue;
362
363 if (screen_info.lfb_base >= start &&
364 (screen_info.lfb_base + screen_info.lfb_size) < end)
365 default_vga = dev;
320 } 366 }
321 if (!strncmp(this_opt, "base:", 5))
322 screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
323 else if (!strncmp(this_opt, "stride:", 7))
324 screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
325 else if (!strncmp(this_opt, "height:", 7))
326 screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
327 else if (!strncmp(this_opt, "width:", 6))
328 screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
329 } 367 }
368
330 return 0; 369 return 0;
331} 370}
332 371
diff --git a/drivers/video/ep93xx-fb.c b/drivers/video/ep93xx-fb.c
index f8babbeee275..345d96230978 100644
--- a/drivers/video/ep93xx-fb.c
+++ b/drivers/video/ep93xx-fb.c
@@ -507,16 +507,16 @@ static int __devinit ep93xxfb_probe(struct platform_device *pdev)
507 507
508 err = fb_alloc_cmap(&info->cmap, 256, 0); 508 err = fb_alloc_cmap(&info->cmap, 256, 0);
509 if (err) 509 if (err)
510 goto failed; 510 goto failed_cmap;
511 511
512 err = ep93xxfb_alloc_videomem(info); 512 err = ep93xxfb_alloc_videomem(info);
513 if (err) 513 if (err)
514 goto failed; 514 goto failed_videomem;
515 515
516 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 516 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
517 if (!res) { 517 if (!res) {
518 err = -ENXIO; 518 err = -ENXIO;
519 goto failed; 519 goto failed_resource;
520 } 520 }
521 521
522 /* 522 /*
@@ -532,7 +532,7 @@ static int __devinit ep93xxfb_probe(struct platform_device *pdev)
532 fbi->mmio_base = ioremap(res->start, resource_size(res)); 532 fbi->mmio_base = ioremap(res->start, resource_size(res));
533 if (!fbi->mmio_base) { 533 if (!fbi->mmio_base) {
534 err = -ENXIO; 534 err = -ENXIO;
535 goto failed; 535 goto failed_resource;
536 } 536 }
537 537
538 strcpy(info->fix.id, pdev->name); 538 strcpy(info->fix.id, pdev->name);
@@ -553,24 +553,24 @@ static int __devinit ep93xxfb_probe(struct platform_device *pdev)
553 if (err == 0) { 553 if (err == 0) {
554 dev_err(info->dev, "No suitable video mode found\n"); 554 dev_err(info->dev, "No suitable video mode found\n");
555 err = -EINVAL; 555 err = -EINVAL;
556 goto failed; 556 goto failed_mode;
557 } 557 }
558 558
559 if (mach_info->setup) { 559 if (mach_info->setup) {
560 err = mach_info->setup(pdev); 560 err = mach_info->setup(pdev);
561 if (err) 561 if (err)
562 return err; 562 goto failed_mode;
563 } 563 }
564 564
565 err = ep93xxfb_check_var(&info->var, info); 565 err = ep93xxfb_check_var(&info->var, info);
566 if (err) 566 if (err)
567 goto failed; 567 goto failed_check;
568 568
569 fbi->clk = clk_get(info->dev, NULL); 569 fbi->clk = clk_get(info->dev, NULL);
570 if (IS_ERR(fbi->clk)) { 570 if (IS_ERR(fbi->clk)) {
571 err = PTR_ERR(fbi->clk); 571 err = PTR_ERR(fbi->clk);
572 fbi->clk = NULL; 572 fbi->clk = NULL;
573 goto failed; 573 goto failed_check;
574 } 574 }
575 575
576 ep93xxfb_set_par(info); 576 ep93xxfb_set_par(info);
@@ -585,15 +585,17 @@ static int __devinit ep93xxfb_probe(struct platform_device *pdev)
585 return 0; 585 return 0;
586 586
587failed: 587failed:
588 if (fbi->clk) 588 clk_put(fbi->clk);
589 clk_put(fbi->clk); 589failed_check:
590 if (fbi->mmio_base)
591 iounmap(fbi->mmio_base);
592 ep93xxfb_dealloc_videomem(info);
593 if (&info->cmap)
594 fb_dealloc_cmap(&info->cmap);
595 if (fbi->mach_info->teardown) 590 if (fbi->mach_info->teardown)
596 fbi->mach_info->teardown(pdev); 591 fbi->mach_info->teardown(pdev);
592failed_mode:
593 iounmap(fbi->mmio_base);
594failed_resource:
595 ep93xxfb_dealloc_videomem(info);
596failed_videomem:
597 fb_dealloc_cmap(&info->cmap);
598failed_cmap:
597 kfree(info); 599 kfree(info);
598 platform_set_drvdata(pdev, NULL); 600 platform_set_drvdata(pdev, NULL);
599 601
diff --git a/drivers/video/exynos/exynos_dp_core.c b/drivers/video/exynos/exynos_dp_core.c
index 2a4481cf260c..a36b2d28280e 100644
--- a/drivers/video/exynos/exynos_dp_core.c
+++ b/drivers/video/exynos/exynos_dp_core.c
@@ -21,14 +21,14 @@
21 21
22#include <video/exynos_dp.h> 22#include <video/exynos_dp.h>
23 23
24#include <plat/cpu.h>
25
26#include "exynos_dp_core.h" 24#include "exynos_dp_core.h"
27 25
28static int exynos_dp_init_dp(struct exynos_dp_device *dp) 26static int exynos_dp_init_dp(struct exynos_dp_device *dp)
29{ 27{
30 exynos_dp_reset(dp); 28 exynos_dp_reset(dp);
31 29
30 exynos_dp_swreset(dp);
31
32 /* SW defined function Normal operation */ 32 /* SW defined function Normal operation */
33 exynos_dp_enable_sw_function(dp); 33 exynos_dp_enable_sw_function(dp);
34 34
@@ -478,7 +478,7 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
478 int lane_count; 478 int lane_count;
479 u8 buf[5]; 479 u8 buf[5];
480 480
481 u8 *adjust_request; 481 u8 adjust_request[2];
482 u8 voltage_swing; 482 u8 voltage_swing;
483 u8 pre_emphasis; 483 u8 pre_emphasis;
484 u8 training_lane; 484 u8 training_lane;
@@ -493,8 +493,8 @@ static int exynos_dp_process_clock_recovery(struct exynos_dp_device *dp)
493 /* set training pattern 2 for EQ */ 493 /* set training pattern 2 for EQ */
494 exynos_dp_set_training_pattern(dp, TRAINING_PTN2); 494 exynos_dp_set_training_pattern(dp, TRAINING_PTN2);
495 495
496 adjust_request = link_status + (DPCD_ADDR_ADJUST_REQUEST_LANE0_1 496 adjust_request[0] = link_status[4];
497 - DPCD_ADDR_LANE0_1_STATUS); 497 adjust_request[1] = link_status[5];
498 498
499 exynos_dp_get_adjust_train(dp, adjust_request); 499 exynos_dp_get_adjust_train(dp, adjust_request);
500 500
@@ -566,7 +566,7 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
566 u8 buf[5]; 566 u8 buf[5];
567 u32 reg; 567 u32 reg;
568 568
569 u8 *adjust_request; 569 u8 adjust_request[2];
570 570
571 udelay(400); 571 udelay(400);
572 572
@@ -575,8 +575,8 @@ static int exynos_dp_process_equalizer_training(struct exynos_dp_device *dp)
575 lane_count = dp->link_train.lane_count; 575 lane_count = dp->link_train.lane_count;
576 576
577 if (exynos_dp_clock_recovery_ok(link_status, lane_count) == 0) { 577 if (exynos_dp_clock_recovery_ok(link_status, lane_count) == 0) {
578 adjust_request = link_status + (DPCD_ADDR_ADJUST_REQUEST_LANE0_1 578 adjust_request[0] = link_status[4];
579 - DPCD_ADDR_LANE0_1_STATUS); 579 adjust_request[1] = link_status[5];
580 580
581 if (exynos_dp_channel_eq_ok(link_status, lane_count) == 0) { 581 if (exynos_dp_channel_eq_ok(link_status, lane_count) == 0) {
582 /* traing pattern Set to Normal */ 582 /* traing pattern Set to Normal */
@@ -770,7 +770,7 @@ static int exynos_dp_config_video(struct exynos_dp_device *dp,
770 return -ETIMEDOUT; 770 return -ETIMEDOUT;
771 } 771 }
772 772
773 mdelay(100); 773 udelay(1);
774 } 774 }
775 775
776 /* Set to use the register calculated M/N video */ 776 /* Set to use the register calculated M/N video */
@@ -804,7 +804,7 @@ static int exynos_dp_config_video(struct exynos_dp_device *dp,
804 return -ETIMEDOUT; 804 return -ETIMEDOUT;
805 } 805 }
806 806
807 mdelay(100); 807 mdelay(1);
808 } 808 }
809 809
810 if (retval != 0) 810 if (retval != 0)
@@ -860,7 +860,8 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
860 return -EINVAL; 860 return -EINVAL;
861 } 861 }
862 862
863 dp = kzalloc(sizeof(struct exynos_dp_device), GFP_KERNEL); 863 dp = devm_kzalloc(&pdev->dev, sizeof(struct exynos_dp_device),
864 GFP_KERNEL);
864 if (!dp) { 865 if (!dp) {
865 dev_err(&pdev->dev, "no memory for device data\n"); 866 dev_err(&pdev->dev, "no memory for device data\n");
866 return -ENOMEM; 867 return -ENOMEM;
@@ -871,8 +872,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
871 dp->clock = clk_get(&pdev->dev, "dp"); 872 dp->clock = clk_get(&pdev->dev, "dp");
872 if (IS_ERR(dp->clock)) { 873 if (IS_ERR(dp->clock)) {
873 dev_err(&pdev->dev, "failed to get clock\n"); 874 dev_err(&pdev->dev, "failed to get clock\n");
874 ret = PTR_ERR(dp->clock); 875 return PTR_ERR(dp->clock);
875 goto err_dp;
876 } 876 }
877 877
878 clk_enable(dp->clock); 878 clk_enable(dp->clock);
@@ -884,35 +884,25 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
884 goto err_clock; 884 goto err_clock;
885 } 885 }
886 886
887 res = request_mem_region(res->start, resource_size(res), 887 dp->reg_base = devm_request_and_ioremap(&pdev->dev, res);
888 dev_name(&pdev->dev));
889 if (!res) {
890 dev_err(&pdev->dev, "failed to request registers region\n");
891 ret = -EINVAL;
892 goto err_clock;
893 }
894
895 dp->res = res;
896
897 dp->reg_base = ioremap(res->start, resource_size(res));
898 if (!dp->reg_base) { 888 if (!dp->reg_base) {
899 dev_err(&pdev->dev, "failed to ioremap\n"); 889 dev_err(&pdev->dev, "failed to ioremap\n");
900 ret = -ENOMEM; 890 ret = -ENOMEM;
901 goto err_req_region; 891 goto err_clock;
902 } 892 }
903 893
904 dp->irq = platform_get_irq(pdev, 0); 894 dp->irq = platform_get_irq(pdev, 0);
905 if (!dp->irq) { 895 if (!dp->irq) {
906 dev_err(&pdev->dev, "failed to get irq\n"); 896 dev_err(&pdev->dev, "failed to get irq\n");
907 ret = -ENODEV; 897 ret = -ENODEV;
908 goto err_ioremap; 898 goto err_clock;
909 } 899 }
910 900
911 ret = request_irq(dp->irq, exynos_dp_irq_handler, 0, 901 ret = devm_request_irq(&pdev->dev, dp->irq, exynos_dp_irq_handler, 0,
912 "exynos-dp", dp); 902 "exynos-dp", dp);
913 if (ret) { 903 if (ret) {
914 dev_err(&pdev->dev, "failed to request irq\n"); 904 dev_err(&pdev->dev, "failed to request irq\n");
915 goto err_ioremap; 905 goto err_clock;
916 } 906 }
917 907
918 dp->video_info = pdata->video_info; 908 dp->video_info = pdata->video_info;
@@ -924,7 +914,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
924 ret = exynos_dp_detect_hpd(dp); 914 ret = exynos_dp_detect_hpd(dp);
925 if (ret) { 915 if (ret) {
926 dev_err(&pdev->dev, "unable to detect hpd\n"); 916 dev_err(&pdev->dev, "unable to detect hpd\n");
927 goto err_irq; 917 goto err_clock;
928 } 918 }
929 919
930 exynos_dp_handle_edid(dp); 920 exynos_dp_handle_edid(dp);
@@ -933,7 +923,7 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
933 dp->video_info->link_rate); 923 dp->video_info->link_rate);
934 if (ret) { 924 if (ret) {
935 dev_err(&pdev->dev, "unable to do link train\n"); 925 dev_err(&pdev->dev, "unable to do link train\n");
936 goto err_irq; 926 goto err_clock;
937 } 927 }
938 928
939 exynos_dp_enable_scramble(dp, 1); 929 exynos_dp_enable_scramble(dp, 1);
@@ -947,23 +937,15 @@ static int __devinit exynos_dp_probe(struct platform_device *pdev)
947 ret = exynos_dp_config_video(dp, dp->video_info); 937 ret = exynos_dp_config_video(dp, dp->video_info);
948 if (ret) { 938 if (ret) {
949 dev_err(&pdev->dev, "unable to config video\n"); 939 dev_err(&pdev->dev, "unable to config video\n");
950 goto err_irq; 940 goto err_clock;
951 } 941 }
952 942
953 platform_set_drvdata(pdev, dp); 943 platform_set_drvdata(pdev, dp);
954 944
955 return 0; 945 return 0;
956 946
957err_irq:
958 free_irq(dp->irq, dp);
959err_ioremap:
960 iounmap(dp->reg_base);
961err_req_region:
962 release_mem_region(res->start, resource_size(res));
963err_clock: 947err_clock:
964 clk_put(dp->clock); 948 clk_put(dp->clock);
965err_dp:
966 kfree(dp);
967 949
968 return ret; 950 return ret;
969} 951}
@@ -976,16 +958,9 @@ static int __devexit exynos_dp_remove(struct platform_device *pdev)
976 if (pdata && pdata->phy_exit) 958 if (pdata && pdata->phy_exit)
977 pdata->phy_exit(); 959 pdata->phy_exit();
978 960
979 free_irq(dp->irq, dp);
980 iounmap(dp->reg_base);
981
982 clk_disable(dp->clock); 961 clk_disable(dp->clock);
983 clk_put(dp->clock); 962 clk_put(dp->clock);
984 963
985 release_mem_region(dp->res->start, resource_size(dp->res));
986
987 kfree(dp);
988
989 return 0; 964 return 0;
990} 965}
991 966
diff --git a/drivers/video/exynos/exynos_dp_core.h b/drivers/video/exynos/exynos_dp_core.h
index 90ceaca0fa24..1e0f998e0c9f 100644
--- a/drivers/video/exynos/exynos_dp_core.h
+++ b/drivers/video/exynos/exynos_dp_core.h
@@ -26,7 +26,6 @@ struct link_train {
26 26
27struct exynos_dp_device { 27struct exynos_dp_device {
28 struct device *dev; 28 struct device *dev;
29 struct resource *res;
30 struct clk *clock; 29 struct clk *clock;
31 unsigned int irq; 30 unsigned int irq;
32 void __iomem *reg_base; 31 void __iomem *reg_base;
@@ -39,8 +38,10 @@ struct exynos_dp_device {
39void exynos_dp_enable_video_mute(struct exynos_dp_device *dp, bool enable); 38void exynos_dp_enable_video_mute(struct exynos_dp_device *dp, bool enable);
40void exynos_dp_stop_video(struct exynos_dp_device *dp); 39void exynos_dp_stop_video(struct exynos_dp_device *dp);
41void exynos_dp_lane_swap(struct exynos_dp_device *dp, bool enable); 40void exynos_dp_lane_swap(struct exynos_dp_device *dp, bool enable);
41void exynos_dp_init_analog_param(struct exynos_dp_device *dp);
42void exynos_dp_init_interrupt(struct exynos_dp_device *dp); 42void exynos_dp_init_interrupt(struct exynos_dp_device *dp);
43void exynos_dp_reset(struct exynos_dp_device *dp); 43void exynos_dp_reset(struct exynos_dp_device *dp);
44void exynos_dp_swreset(struct exynos_dp_device *dp);
44void exynos_dp_config_interrupt(struct exynos_dp_device *dp); 45void exynos_dp_config_interrupt(struct exynos_dp_device *dp);
45u32 exynos_dp_get_pll_lock_status(struct exynos_dp_device *dp); 46u32 exynos_dp_get_pll_lock_status(struct exynos_dp_device *dp);
46void exynos_dp_set_pll_power_down(struct exynos_dp_device *dp, bool enable); 47void exynos_dp_set_pll_power_down(struct exynos_dp_device *dp, bool enable);
diff --git a/drivers/video/exynos/exynos_dp_reg.c b/drivers/video/exynos/exynos_dp_reg.c
index 6548afa0e3d2..6ce76d56c3a1 100644
--- a/drivers/video/exynos/exynos_dp_reg.c
+++ b/drivers/video/exynos/exynos_dp_reg.c
@@ -16,8 +16,6 @@
16 16
17#include <video/exynos_dp.h> 17#include <video/exynos_dp.h>
18 18
19#include <plat/cpu.h>
20
21#include "exynos_dp_core.h" 19#include "exynos_dp_core.h"
22#include "exynos_dp_reg.h" 20#include "exynos_dp_reg.h"
23 21
@@ -65,6 +63,28 @@ void exynos_dp_lane_swap(struct exynos_dp_device *dp, bool enable)
65 writel(reg, dp->reg_base + EXYNOS_DP_LANE_MAP); 63 writel(reg, dp->reg_base + EXYNOS_DP_LANE_MAP);
66} 64}
67 65
66void exynos_dp_init_analog_param(struct exynos_dp_device *dp)
67{
68 u32 reg;
69
70 reg = TX_TERMINAL_CTRL_50_OHM;
71 writel(reg, dp->reg_base + EXYNOS_DP_ANALOG_CTL_1);
72
73 reg = SEL_24M | TX_DVDD_BIT_1_0625V;
74 writel(reg, dp->reg_base + EXYNOS_DP_ANALOG_CTL_2);
75
76 reg = DRIVE_DVDD_BIT_1_0625V | VCO_BIT_600_MICRO;
77 writel(reg, dp->reg_base + EXYNOS_DP_ANALOG_CTL_3);
78
79 reg = PD_RING_OSC | AUX_TERMINAL_CTRL_50_OHM |
80 TX_CUR1_2X | TX_CUR_8_MA;
81 writel(reg, dp->reg_base + EXYNOS_DP_PLL_FILTER_CTL_1);
82
83 reg = CH3_AMP_400_MV | CH2_AMP_400_MV |
84 CH1_AMP_400_MV | CH0_AMP_400_MV;
85 writel(reg, dp->reg_base + EXYNOS_DP_TX_AMP_TUNING_CTL);
86}
87
68void exynos_dp_init_interrupt(struct exynos_dp_device *dp) 88void exynos_dp_init_interrupt(struct exynos_dp_device *dp)
69{ 89{
70 /* Set interrupt pin assertion polarity as high */ 90 /* Set interrupt pin assertion polarity as high */
@@ -89,8 +109,6 @@ void exynos_dp_reset(struct exynos_dp_device *dp)
89{ 109{
90 u32 reg; 110 u32 reg;
91 111
92 writel(RESET_DP_TX, dp->reg_base + EXYNOS_DP_TX_SW_RESET);
93
94 exynos_dp_stop_video(dp); 112 exynos_dp_stop_video(dp);
95 exynos_dp_enable_video_mute(dp, 0); 113 exynos_dp_enable_video_mute(dp, 0);
96 114
@@ -131,9 +149,15 @@ void exynos_dp_reset(struct exynos_dp_device *dp)
131 149
132 writel(0x00000101, dp->reg_base + EXYNOS_DP_SOC_GENERAL_CTL); 150 writel(0x00000101, dp->reg_base + EXYNOS_DP_SOC_GENERAL_CTL);
133 151
152 exynos_dp_init_analog_param(dp);
134 exynos_dp_init_interrupt(dp); 153 exynos_dp_init_interrupt(dp);
135} 154}
136 155
156void exynos_dp_swreset(struct exynos_dp_device *dp)
157{
158 writel(RESET_DP_TX, dp->reg_base + EXYNOS_DP_TX_SW_RESET);
159}
160
137void exynos_dp_config_interrupt(struct exynos_dp_device *dp) 161void exynos_dp_config_interrupt(struct exynos_dp_device *dp)
138{ 162{
139 u32 reg; 163 u32 reg;
@@ -271,6 +295,7 @@ void exynos_dp_set_analog_power_down(struct exynos_dp_device *dp,
271void exynos_dp_init_analog_func(struct exynos_dp_device *dp) 295void exynos_dp_init_analog_func(struct exynos_dp_device *dp)
272{ 296{
273 u32 reg; 297 u32 reg;
298 int timeout_loop = 0;
274 299
275 exynos_dp_set_analog_power_down(dp, POWER_ALL, 0); 300 exynos_dp_set_analog_power_down(dp, POWER_ALL, 0);
276 301
@@ -282,9 +307,19 @@ void exynos_dp_init_analog_func(struct exynos_dp_device *dp)
282 writel(reg, dp->reg_base + EXYNOS_DP_DEBUG_CTL); 307 writel(reg, dp->reg_base + EXYNOS_DP_DEBUG_CTL);
283 308
284 /* Power up PLL */ 309 /* Power up PLL */
285 if (exynos_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) 310 if (exynos_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) {
286 exynos_dp_set_pll_power_down(dp, 0); 311 exynos_dp_set_pll_power_down(dp, 0);
287 312
313 while (exynos_dp_get_pll_lock_status(dp) == PLL_UNLOCKED) {
314 timeout_loop++;
315 if (DP_TIMEOUT_LOOP_COUNT < timeout_loop) {
316 dev_err(dp->dev, "failed to get pll lock status\n");
317 return;
318 }
319 usleep_range(10, 20);
320 }
321 }
322
288 /* Enable Serdes FIFO function and Link symbol clock domain module */ 323 /* Enable Serdes FIFO function and Link symbol clock domain module */
289 reg = readl(dp->reg_base + EXYNOS_DP_FUNC_EN_2); 324 reg = readl(dp->reg_base + EXYNOS_DP_FUNC_EN_2);
290 reg &= ~(SERDES_FIFO_FUNC_EN_N | LS_CLK_DOMAIN_FUNC_EN_N 325 reg &= ~(SERDES_FIFO_FUNC_EN_N | LS_CLK_DOMAIN_FUNC_EN_N
diff --git a/drivers/video/exynos/exynos_dp_reg.h b/drivers/video/exynos/exynos_dp_reg.h
index 42f608e2a43e..125b27cd57ae 100644
--- a/drivers/video/exynos/exynos_dp_reg.h
+++ b/drivers/video/exynos/exynos_dp_reg.h
@@ -24,6 +24,12 @@
24 24
25#define EXYNOS_DP_LANE_MAP 0x35C 25#define EXYNOS_DP_LANE_MAP 0x35C
26 26
27#define EXYNOS_DP_ANALOG_CTL_1 0x370
28#define EXYNOS_DP_ANALOG_CTL_2 0x374
29#define EXYNOS_DP_ANALOG_CTL_3 0x378
30#define EXYNOS_DP_PLL_FILTER_CTL_1 0x37C
31#define EXYNOS_DP_TX_AMP_TUNING_CTL 0x380
32
27#define EXYNOS_DP_AUX_HW_RETRY_CTL 0x390 33#define EXYNOS_DP_AUX_HW_RETRY_CTL 0x390
28 34
29#define EXYNOS_DP_COMMON_INT_STA_1 0x3C4 35#define EXYNOS_DP_COMMON_INT_STA_1 0x3C4
@@ -166,6 +172,29 @@
166#define LANE0_MAP_LOGIC_LANE_2 (0x2 << 0) 172#define LANE0_MAP_LOGIC_LANE_2 (0x2 << 0)
167#define LANE0_MAP_LOGIC_LANE_3 (0x3 << 0) 173#define LANE0_MAP_LOGIC_LANE_3 (0x3 << 0)
168 174
175/* EXYNOS_DP_ANALOG_CTL_1 */
176#define TX_TERMINAL_CTRL_50_OHM (0x1 << 4)
177
178/* EXYNOS_DP_ANALOG_CTL_2 */
179#define SEL_24M (0x1 << 3)
180#define TX_DVDD_BIT_1_0625V (0x4 << 0)
181
182/* EXYNOS_DP_ANALOG_CTL_3 */
183#define DRIVE_DVDD_BIT_1_0625V (0x4 << 5)
184#define VCO_BIT_600_MICRO (0x5 << 0)
185
186/* EXYNOS_DP_PLL_FILTER_CTL_1 */
187#define PD_RING_OSC (0x1 << 6)
188#define AUX_TERMINAL_CTRL_50_OHM (0x2 << 4)
189#define TX_CUR1_2X (0x1 << 2)
190#define TX_CUR_8_MA (0x2 << 0)
191
192/* EXYNOS_DP_TX_AMP_TUNING_CTL */
193#define CH3_AMP_400_MV (0x0 << 24)
194#define CH2_AMP_400_MV (0x0 << 16)
195#define CH1_AMP_400_MV (0x0 << 8)
196#define CH0_AMP_400_MV (0x0 << 0)
197
169/* EXYNOS_DP_AUX_HW_RETRY_CTL */ 198/* EXYNOS_DP_AUX_HW_RETRY_CTL */
170#define AUX_BIT_PERIOD_EXPECTED_DELAY(x) (((x) & 0x7) << 8) 199#define AUX_BIT_PERIOD_EXPECTED_DELAY(x) (((x) & 0x7) << 8)
171#define AUX_HW_RETRY_INTERVAL_MASK (0x3 << 3) 200#define AUX_HW_RETRY_INTERVAL_MASK (0x3 << 3)
diff --git a/drivers/video/exynos/exynos_mipi_dsi.c b/drivers/video/exynos/exynos_mipi_dsi.c
index 557091dc0e97..6c1f5c314a42 100644
--- a/drivers/video/exynos/exynos_mipi_dsi.c
+++ b/drivers/video/exynos/exynos_mipi_dsi.c
@@ -58,7 +58,7 @@ static struct mipi_dsim_platform_data *to_dsim_plat(struct platform_device
58} 58}
59 59
60static struct regulator_bulk_data supplies[] = { 60static struct regulator_bulk_data supplies[] = {
61 { .supply = "vdd10", }, 61 { .supply = "vdd11", },
62 { .supply = "vdd18", }, 62 { .supply = "vdd18", },
63}; 63};
64 64
@@ -102,6 +102,8 @@ static void exynos_mipi_update_cfg(struct mipi_dsim_device *dsim)
102 /* set display timing. */ 102 /* set display timing. */
103 exynos_mipi_dsi_set_display_mode(dsim, dsim->dsim_config); 103 exynos_mipi_dsi_set_display_mode(dsim, dsim->dsim_config);
104 104
105 exynos_mipi_dsi_init_interrupt(dsim);
106
105 /* 107 /*
106 * data from Display controller(FIMD) is transferred in video mode 108 * data from Display controller(FIMD) is transferred in video mode
107 * but in case of command mode, all settigs is updated to registers. 109 * but in case of command mode, all settigs is updated to registers.
@@ -413,27 +415,30 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
413 goto err_platform_get_irq; 415 goto err_platform_get_irq;
414 } 416 }
415 417
418 init_completion(&dsim_wr_comp);
419 init_completion(&dsim_rd_comp);
420 platform_set_drvdata(pdev, dsim);
421
416 ret = request_irq(dsim->irq, exynos_mipi_dsi_interrupt_handler, 422 ret = request_irq(dsim->irq, exynos_mipi_dsi_interrupt_handler,
417 IRQF_SHARED, pdev->name, dsim); 423 IRQF_SHARED, dev_name(&pdev->dev), dsim);
418 if (ret != 0) { 424 if (ret != 0) {
419 dev_err(&pdev->dev, "failed to request dsim irq\n"); 425 dev_err(&pdev->dev, "failed to request dsim irq\n");
420 ret = -EINVAL; 426 ret = -EINVAL;
421 goto err_bind; 427 goto err_bind;
422 } 428 }
423 429
424 init_completion(&dsim_wr_comp); 430 /* enable interrupts */
425 init_completion(&dsim_rd_comp);
426
427 /* enable interrupt */
428 exynos_mipi_dsi_init_interrupt(dsim); 431 exynos_mipi_dsi_init_interrupt(dsim);
429 432
430 /* initialize mipi-dsi client(lcd panel). */ 433 /* initialize mipi-dsi client(lcd panel). */
431 if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->probe) 434 if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->probe)
432 dsim_ddi->dsim_lcd_drv->probe(dsim_ddi->dsim_lcd_dev); 435 dsim_ddi->dsim_lcd_drv->probe(dsim_ddi->dsim_lcd_dev);
433 436
434 /* in case that mipi got enabled at bootloader. */ 437 /* in case mipi-dsi has been enabled by bootloader */
435 if (dsim_pd->enabled) 438 if (dsim_pd->enabled) {
436 goto out; 439 exynos_mipi_regulator_enable(dsim);
440 goto done;
441 }
437 442
438 /* lcd panel power on. */ 443 /* lcd panel power on. */
439 if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->power_on) 444 if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->power_on)
@@ -453,12 +458,11 @@ static int exynos_mipi_dsi_probe(struct platform_device *pdev)
453 458
454 dsim->suspended = false; 459 dsim->suspended = false;
455 460
456out: 461done:
457 platform_set_drvdata(pdev, dsim); 462 platform_set_drvdata(pdev, dsim);
458 463
459 dev_dbg(&pdev->dev, "mipi-dsi driver(%s mode) has been probed.\n", 464 dev_dbg(&pdev->dev, "%s() completed sucessfuly (%s mode)\n", __func__,
460 (dsim_config->e_interface == DSIM_COMMAND) ? 465 dsim_config->e_interface == DSIM_COMMAND ? "CPU" : "RGB");
461 "CPU" : "RGB");
462 466
463 return 0; 467 return 0;
464 468
@@ -515,10 +519,10 @@ static int __devexit exynos_mipi_dsi_remove(struct platform_device *pdev)
515 return 0; 519 return 0;
516} 520}
517 521
518#ifdef CONFIG_PM 522#ifdef CONFIG_PM_SLEEP
519static int exynos_mipi_dsi_suspend(struct platform_device *pdev, 523static int exynos_mipi_dsi_suspend(struct device *dev)
520 pm_message_t state)
521{ 524{
525 struct platform_device *pdev = to_platform_device(dev);
522 struct mipi_dsim_device *dsim = platform_get_drvdata(pdev); 526 struct mipi_dsim_device *dsim = platform_get_drvdata(pdev);
523 struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv; 527 struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv;
524 struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev; 528 struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev;
@@ -544,8 +548,9 @@ static int exynos_mipi_dsi_suspend(struct platform_device *pdev,
544 return 0; 548 return 0;
545} 549}
546 550
547static int exynos_mipi_dsi_resume(struct platform_device *pdev) 551static int exynos_mipi_dsi_resume(struct device *dev)
548{ 552{
553 struct platform_device *pdev = to_platform_device(dev);
549 struct mipi_dsim_device *dsim = platform_get_drvdata(pdev); 554 struct mipi_dsim_device *dsim = platform_get_drvdata(pdev);
550 struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv; 555 struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv;
551 struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev; 556 struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev;
@@ -577,19 +582,19 @@ static int exynos_mipi_dsi_resume(struct platform_device *pdev)
577 582
578 return 0; 583 return 0;
579} 584}
580#else
581#define exynos_mipi_dsi_suspend NULL
582#define exynos_mipi_dsi_resume NULL
583#endif 585#endif
584 586
587static const struct dev_pm_ops exynos_mipi_dsi_pm_ops = {
588 SET_SYSTEM_SLEEP_PM_OPS(exynos_mipi_dsi_suspend, exynos_mipi_dsi_resume)
589};
590
585static struct platform_driver exynos_mipi_dsi_driver = { 591static struct platform_driver exynos_mipi_dsi_driver = {
586 .probe = exynos_mipi_dsi_probe, 592 .probe = exynos_mipi_dsi_probe,
587 .remove = __devexit_p(exynos_mipi_dsi_remove), 593 .remove = __devexit_p(exynos_mipi_dsi_remove),
588 .suspend = exynos_mipi_dsi_suspend,
589 .resume = exynos_mipi_dsi_resume,
590 .driver = { 594 .driver = {
591 .name = "exynos-mipi-dsim", 595 .name = "exynos-mipi-dsim",
592 .owner = THIS_MODULE, 596 .owner = THIS_MODULE,
597 .pm = &exynos_mipi_dsi_pm_ops,
593 }, 598 },
594}; 599};
595 600
diff --git a/drivers/video/exynos/exynos_mipi_dsi_common.c b/drivers/video/exynos/exynos_mipi_dsi_common.c
index 14909c1d3832..47b533a183be 100644
--- a/drivers/video/exynos/exynos_mipi_dsi_common.c
+++ b/drivers/video/exynos/exynos_mipi_dsi_common.c
@@ -76,33 +76,25 @@ static unsigned int dpll_table[15] = {
76 76
77irqreturn_t exynos_mipi_dsi_interrupt_handler(int irq, void *dev_id) 77irqreturn_t exynos_mipi_dsi_interrupt_handler(int irq, void *dev_id)
78{ 78{
79 unsigned int intsrc = 0; 79 struct mipi_dsim_device *dsim = dev_id;
80 unsigned int intmsk = 0; 80 unsigned int intsrc, intmsk;
81 struct mipi_dsim_device *dsim = NULL; 81
82 82 if (dsim == NULL) {
83 dsim = dev_id; 83 dev_err(dsim->dev, "%s: wrong parameter\n", __func__);
84 if (!dsim) { 84 return IRQ_NONE;
85 dev_dbg(dsim->dev, KERN_ERR "%s:error: wrong parameter\n",
86 __func__);
87 return IRQ_HANDLED;
88 } 85 }
89 86
90 intsrc = exynos_mipi_dsi_read_interrupt(dsim); 87 intsrc = exynos_mipi_dsi_read_interrupt(dsim);
91 intmsk = exynos_mipi_dsi_read_interrupt_mask(dsim); 88 intmsk = exynos_mipi_dsi_read_interrupt_mask(dsim);
89 intmsk = ~intmsk & intsrc;
92 90
93 intmsk = ~(intmsk) & intsrc; 91 if (intsrc & INTMSK_RX_DONE) {
94
95 switch (intmsk) {
96 case INTMSK_RX_DONE:
97 complete(&dsim_rd_comp); 92 complete(&dsim_rd_comp);
98 dev_dbg(dsim->dev, "MIPI INTMSK_RX_DONE\n"); 93 dev_dbg(dsim->dev, "MIPI INTMSK_RX_DONE\n");
99 break; 94 }
100 case INTMSK_FIFO_EMPTY: 95 if (intsrc & INTMSK_FIFO_EMPTY) {
101 complete(&dsim_wr_comp); 96 complete(&dsim_wr_comp);
102 dev_dbg(dsim->dev, "MIPI INTMSK_FIFO_EMPTY\n"); 97 dev_dbg(dsim->dev, "MIPI INTMSK_FIFO_EMPTY\n");
103 break;
104 default:
105 break;
106 } 98 }
107 99
108 exynos_mipi_dsi_clear_interrupt(dsim, intmsk); 100 exynos_mipi_dsi_clear_interrupt(dsim, intmsk);
@@ -738,11 +730,11 @@ int exynos_mipi_dsi_set_display_mode(struct mipi_dsim_device *dsim,
738 if (dsim_config->auto_vertical_cnt == 0) { 730 if (dsim_config->auto_vertical_cnt == 0) {
739 exynos_mipi_dsi_set_main_disp_vporch(dsim, 731 exynos_mipi_dsi_set_main_disp_vporch(dsim,
740 dsim_config->cmd_allow, 732 dsim_config->cmd_allow,
741 timing->upper_margin, 733 timing->lower_margin,
742 timing->lower_margin); 734 timing->upper_margin);
743 exynos_mipi_dsi_set_main_disp_hporch(dsim, 735 exynos_mipi_dsi_set_main_disp_hporch(dsim,
744 timing->left_margin, 736 timing->right_margin,
745 timing->right_margin); 737 timing->left_margin);
746 exynos_mipi_dsi_set_main_disp_sync_area(dsim, 738 exynos_mipi_dsi_set_main_disp_sync_area(dsim,
747 timing->vsync_len, 739 timing->vsync_len,
748 timing->hsync_len); 740 timing->hsync_len);
diff --git a/drivers/video/exynos/s6e8ax0.c b/drivers/video/exynos/s6e8ax0.c
index 4aa9ac6218bf..05d080b63bc0 100644
--- a/drivers/video/exynos/s6e8ax0.c
+++ b/drivers/video/exynos/s6e8ax0.c
@@ -293,9 +293,20 @@ static void s6e8ax0_panel_cond(struct s6e8ax0 *lcd)
293 0x6e, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08, 0x23, 0x23, 0xc0, 293 0x6e, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08, 0x23, 0x23, 0xc0,
294 0xc8, 0x08, 0x48, 0xc1, 0x00, 0xc1, 0xff, 0xff, 0xc8 294 0xc8, 0x08, 0x48, 0xc1, 0x00, 0xc1, 0xff, 0xff, 0xc8
295 }; 295 };
296 static const unsigned char data_to_send_panel_reverse[] = {
297 0xf8, 0x19, 0x35, 0x00, 0x00, 0x00, 0x93, 0x00, 0x3c, 0x7d,
298 0x08, 0x27, 0x7d, 0x3f, 0x00, 0x00, 0x00, 0x20, 0x04, 0x08,
299 0x6e, 0x00, 0x00, 0x00, 0x02, 0x08, 0x08, 0x23, 0x23, 0xc0,
300 0xc1, 0x01, 0x41, 0xc1, 0x00, 0xc1, 0xf6, 0xf6, 0xc1
301 };
296 302
297 ops->cmd_write(lcd_to_master(lcd), MIPI_DSI_DCS_LONG_WRITE, 303 if (lcd->dsim_dev->panel_reverse)
298 data_to_send, ARRAY_SIZE(data_to_send)); 304 ops->cmd_write(lcd_to_master(lcd), MIPI_DSI_DCS_LONG_WRITE,
305 data_to_send_panel_reverse,
306 ARRAY_SIZE(data_to_send_panel_reverse));
307 else
308 ops->cmd_write(lcd_to_master(lcd), MIPI_DSI_DCS_LONG_WRITE,
309 data_to_send, ARRAY_SIZE(data_to_send));
299} 310}
300 311
301static void s6e8ax0_display_cond(struct s6e8ax0 *lcd) 312static void s6e8ax0_display_cond(struct s6e8ax0 *lcd)
diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
index c27e153d8882..1ddeb11659d4 100644
--- a/drivers/video/fb_defio.c
+++ b/drivers/video/fb_defio.c
@@ -23,7 +23,7 @@
23#include <linux/rmap.h> 23#include <linux/rmap.h>
24#include <linux/pagemap.h> 24#include <linux/pagemap.h>
25 25
26struct page *fb_deferred_io_page(struct fb_info *info, unsigned long offs) 26static struct page *fb_deferred_io_page(struct fb_info *info, unsigned long offs)
27{ 27{
28 void *screen_base = (void __force *) info->screen_base; 28 void *screen_base = (void __force *) info->screen_base;
29 struct page *page; 29 struct page *page;
@@ -107,6 +107,10 @@ static int fb_deferred_io_mkwrite(struct vm_area_struct *vma,
107 /* protect against the workqueue changing the page list */ 107 /* protect against the workqueue changing the page list */
108 mutex_lock(&fbdefio->lock); 108 mutex_lock(&fbdefio->lock);
109 109
110 /* first write in this cycle, notify the driver */
111 if (fbdefio->first_io && list_empty(&fbdefio->pagelist))
112 fbdefio->first_io(info);
113
110 /* 114 /*
111 * We want the page to remain locked from ->page_mkwrite until 115 * We want the page to remain locked from ->page_mkwrite until
112 * the PTE is marked dirty to avoid page_mkclean() being called 116 * the PTE is marked dirty to avoid page_mkclean() being called
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
index c6ce416ab587..0dff12a1daef 100644
--- a/drivers/video/fbmem.c
+++ b/drivers/video/fbmem.c
@@ -1046,20 +1046,29 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
1046int 1046int
1047fb_blank(struct fb_info *info, int blank) 1047fb_blank(struct fb_info *info, int blank)
1048{ 1048{
1049 int ret = -EINVAL; 1049 struct fb_event event;
1050 int ret = -EINVAL, early_ret;
1050 1051
1051 if (blank > FB_BLANK_POWERDOWN) 1052 if (blank > FB_BLANK_POWERDOWN)
1052 blank = FB_BLANK_POWERDOWN; 1053 blank = FB_BLANK_POWERDOWN;
1053 1054
1055 event.info = info;
1056 event.data = &blank;
1057
1058 early_ret = fb_notifier_call_chain(FB_EARLY_EVENT_BLANK, &event);
1059
1054 if (info->fbops->fb_blank) 1060 if (info->fbops->fb_blank)
1055 ret = info->fbops->fb_blank(blank, info); 1061 ret = info->fbops->fb_blank(blank, info);
1056 1062
1057 if (!ret) { 1063 if (!ret)
1058 struct fb_event event;
1059
1060 event.info = info;
1061 event.data = &blank;
1062 fb_notifier_call_chain(FB_EVENT_BLANK, &event); 1064 fb_notifier_call_chain(FB_EVENT_BLANK, &event);
1065 else {
1066 /*
1067 * if fb_blank is failed then revert effects of
1068 * the early blank event.
1069 */
1070 if (!early_ret)
1071 fb_notifier_call_chain(FB_R_EARLY_EVENT_BLANK, &event);
1063 } 1072 }
1064 1073
1065 return ret; 1074 return ret;
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c
index 67afa9c2289d..a55e3669d135 100644
--- a/drivers/video/fbsysfs.c
+++ b/drivers/video/fbsysfs.c
@@ -80,6 +80,8 @@ EXPORT_SYMBOL(framebuffer_alloc);
80 */ 80 */
81void framebuffer_release(struct fb_info *info) 81void framebuffer_release(struct fb_info *info)
82{ 82{
83 if (!info)
84 return;
83 kfree(info->apertures); 85 kfree(info->apertures);
84 kfree(info); 86 kfree(info);
85} 87}
diff --git a/drivers/video/fsl-diu-fb.c b/drivers/video/fsl-diu-fb.c
index 6af3f16754f0..458c00664ade 100644
--- a/drivers/video/fsl-diu-fb.c
+++ b/drivers/video/fsl-diu-fb.c
@@ -834,7 +834,6 @@ static void update_lcdc(struct fb_info *info)
834 diu_ops.set_pixel_clock(var->pixclock); 834 diu_ops.set_pixel_clock(var->pixclock);
835 835
836 out_be32(&hw->syn_pol, 0); /* SYNC SIGNALS POLARITY */ 836 out_be32(&hw->syn_pol, 0); /* SYNC SIGNALS POLARITY */
837 out_be32(&hw->thresholds, 0x00037800); /* The Thresholds */
838 out_be32(&hw->int_status, 0); /* INTERRUPT STATUS */ 837 out_be32(&hw->int_status, 0); /* INTERRUPT STATUS */
839 out_be32(&hw->plut, 0x01F5F666); 838 out_be32(&hw->plut, 0x01F5F666);
840 839
diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c
index f135dbead07d..caad3689b4e6 100644
--- a/drivers/video/imxfb.c
+++ b/drivers/video/imxfb.c
@@ -131,7 +131,9 @@ struct imxfb_rgb {
131struct imxfb_info { 131struct imxfb_info {
132 struct platform_device *pdev; 132 struct platform_device *pdev;
133 void __iomem *regs; 133 void __iomem *regs;
134 struct clk *clk; 134 struct clk *clk_ipg;
135 struct clk *clk_ahb;
136 struct clk *clk_per;
135 137
136 /* 138 /*
137 * These are the addresses we mapped 139 * These are the addresses we mapped
@@ -340,7 +342,7 @@ static int imxfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
340 342
341 pr_debug("var->bits_per_pixel=%d\n", var->bits_per_pixel); 343 pr_debug("var->bits_per_pixel=%d\n", var->bits_per_pixel);
342 344
343 lcd_clk = clk_get_rate(fbi->clk); 345 lcd_clk = clk_get_rate(fbi->clk_per);
344 346
345 tmp = var->pixclock * (unsigned long long)lcd_clk; 347 tmp = var->pixclock * (unsigned long long)lcd_clk;
346 348
@@ -455,11 +457,17 @@ static int imxfb_bl_update_status(struct backlight_device *bl)
455 457
456 fbi->pwmr = (fbi->pwmr & ~0xFF) | brightness; 458 fbi->pwmr = (fbi->pwmr & ~0xFF) | brightness;
457 459
458 if (bl->props.fb_blank != FB_BLANK_UNBLANK) 460 if (bl->props.fb_blank != FB_BLANK_UNBLANK) {
459 clk_enable(fbi->clk); 461 clk_prepare_enable(fbi->clk_ipg);
462 clk_prepare_enable(fbi->clk_ahb);
463 clk_prepare_enable(fbi->clk_per);
464 }
460 writel(fbi->pwmr, fbi->regs + LCDC_PWMR); 465 writel(fbi->pwmr, fbi->regs + LCDC_PWMR);
461 if (bl->props.fb_blank != FB_BLANK_UNBLANK) 466 if (bl->props.fb_blank != FB_BLANK_UNBLANK) {
462 clk_disable(fbi->clk); 467 clk_disable_unprepare(fbi->clk_per);
468 clk_disable_unprepare(fbi->clk_ahb);
469 clk_disable_unprepare(fbi->clk_ipg);
470 }
463 471
464 return 0; 472 return 0;
465} 473}
@@ -522,7 +530,9 @@ static void imxfb_enable_controller(struct imxfb_info *fbi)
522 */ 530 */
523 writel(RMCR_LCDC_EN_MX1, fbi->regs + LCDC_RMCR); 531 writel(RMCR_LCDC_EN_MX1, fbi->regs + LCDC_RMCR);
524 532
525 clk_enable(fbi->clk); 533 clk_prepare_enable(fbi->clk_ipg);
534 clk_prepare_enable(fbi->clk_ahb);
535 clk_prepare_enable(fbi->clk_per);
526 536
527 if (fbi->backlight_power) 537 if (fbi->backlight_power)
528 fbi->backlight_power(1); 538 fbi->backlight_power(1);
@@ -539,7 +549,9 @@ static void imxfb_disable_controller(struct imxfb_info *fbi)
539 if (fbi->lcd_power) 549 if (fbi->lcd_power)
540 fbi->lcd_power(0); 550 fbi->lcd_power(0);
541 551
542 clk_disable(fbi->clk); 552 clk_disable_unprepare(fbi->clk_per);
553 clk_disable_unprepare(fbi->clk_ipg);
554 clk_disable_unprepare(fbi->clk_ahb);
543 555
544 writel(0, fbi->regs + LCDC_RMCR); 556 writel(0, fbi->regs + LCDC_RMCR);
545} 557}
@@ -770,10 +782,21 @@ static int __init imxfb_probe(struct platform_device *pdev)
770 goto failed_req; 782 goto failed_req;
771 } 783 }
772 784
773 fbi->clk = clk_get(&pdev->dev, NULL); 785 fbi->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
774 if (IS_ERR(fbi->clk)) { 786 if (IS_ERR(fbi->clk_ipg)) {
775 ret = PTR_ERR(fbi->clk); 787 ret = PTR_ERR(fbi->clk_ipg);
776 dev_err(&pdev->dev, "unable to get clock: %d\n", ret); 788 goto failed_getclock;
789 }
790
791 fbi->clk_ahb = devm_clk_get(&pdev->dev, "ahb");
792 if (IS_ERR(fbi->clk_ahb)) {
793 ret = PTR_ERR(fbi->clk_ahb);
794 goto failed_getclock;
795 }
796
797 fbi->clk_per = devm_clk_get(&pdev->dev, "per");
798 if (IS_ERR(fbi->clk_per)) {
799 ret = PTR_ERR(fbi->clk_per);
777 goto failed_getclock; 800 goto failed_getclock;
778 } 801 }
779 802
@@ -858,7 +881,6 @@ failed_platform_init:
858failed_map: 881failed_map:
859 iounmap(fbi->regs); 882 iounmap(fbi->regs);
860failed_ioremap: 883failed_ioremap:
861 clk_put(fbi->clk);
862failed_getclock: 884failed_getclock:
863 release_mem_region(res->start, resource_size(res)); 885 release_mem_region(res->start, resource_size(res));
864failed_req: 886failed_req:
@@ -895,8 +917,6 @@ static int __devexit imxfb_remove(struct platform_device *pdev)
895 917
896 iounmap(fbi->regs); 918 iounmap(fbi->regs);
897 release_mem_region(res->start, resource_size(res)); 919 release_mem_region(res->start, resource_size(res));
898 clk_disable(fbi->clk);
899 clk_put(fbi->clk);
900 920
901 platform_set_drvdata(pdev, NULL); 921 platform_set_drvdata(pdev, NULL);
902 922
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c
index 02fd2263610c..bdcbfbae2777 100644
--- a/drivers/video/intelfb/intelfbdrv.c
+++ b/drivers/video/intelfb/intelfbdrv.c
@@ -680,6 +680,7 @@ static int __devinit intelfb_pci_register(struct pci_dev *pdev,
680 + dinfo->fb.size); 680 + dinfo->fb.size);
681 if (!dinfo->aperture.virtual) { 681 if (!dinfo->aperture.virtual) {
682 ERR_MSG("Cannot remap FB region.\n"); 682 ERR_MSG("Cannot remap FB region.\n");
683 agp_backend_release(bridge);
683 cleanup(dinfo); 684 cleanup(dinfo);
684 return -ENODEV; 685 return -ENODEV;
685 } 686 }
@@ -689,6 +690,7 @@ static int __devinit intelfb_pci_register(struct pci_dev *pdev,
689 INTEL_REG_SIZE); 690 INTEL_REG_SIZE);
690 if (!dinfo->mmio_base) { 691 if (!dinfo->mmio_base) {
691 ERR_MSG("Cannot remap MMIO region.\n"); 692 ERR_MSG("Cannot remap MMIO region.\n");
693 agp_backend_release(bridge);
692 cleanup(dinfo); 694 cleanup(dinfo);
693 return -ENODEV; 695 return -ENODEV;
694 } 696 }
diff --git a/drivers/video/matrox/matroxfb_maven.c b/drivers/video/matrox/matroxfb_maven.c
index 31b8f67477b7..217678e0b983 100644
--- a/drivers/video/matrox/matroxfb_maven.c
+++ b/drivers/video/matrox/matroxfb_maven.c
@@ -1243,6 +1243,7 @@ static int maven_probe(struct i2c_client *client,
1243 1243
1244 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_WORD_DATA | 1244 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_WORD_DATA |
1245 I2C_FUNC_SMBUS_BYTE_DATA | 1245 I2C_FUNC_SMBUS_BYTE_DATA |
1246 I2C_FUNC_NOSTART |
1246 I2C_FUNC_PROTOCOL_MANGLING)) 1247 I2C_FUNC_PROTOCOL_MANGLING))
1247 goto ERROR0; 1248 goto ERROR0;
1248 if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) { 1249 if (!(data = kzalloc(sizeof(*data), GFP_KERNEL))) {
diff --git a/drivers/video/mb862xx/mb862xx-i2c.c b/drivers/video/mb862xx/mb862xx-i2c.c
index 273769bb8deb..c87e17afb3e2 100644
--- a/drivers/video/mb862xx/mb862xx-i2c.c
+++ b/drivers/video/mb862xx/mb862xx-i2c.c
@@ -68,7 +68,7 @@ static int mb862xx_i2c_read_byte(struct i2c_adapter *adap, u8 *byte, int last)
68 return 1; 68 return 1;
69} 69}
70 70
71void mb862xx_i2c_stop(struct i2c_adapter *adap) 71static void mb862xx_i2c_stop(struct i2c_adapter *adap)
72{ 72{
73 struct mb862xxfb_par *par = adap->algo_data; 73 struct mb862xxfb_par *par = adap->algo_data;
74 74
diff --git a/drivers/video/mb862xx/mb862xxfbdrv.c b/drivers/video/mb862xx/mb862xxfbdrv.c
index 11a7a333701d..00ce1f34b496 100644
--- a/drivers/video/mb862xx/mb862xxfbdrv.c
+++ b/drivers/video/mb862xx/mb862xxfbdrv.c
@@ -579,7 +579,7 @@ static ssize_t mb862xxfb_show_dispregs(struct device *dev,
579 579
580static DEVICE_ATTR(dispregs, 0444, mb862xxfb_show_dispregs, NULL); 580static DEVICE_ATTR(dispregs, 0444, mb862xxfb_show_dispregs, NULL);
581 581
582irqreturn_t mb862xx_intr(int irq, void *dev_id) 582static irqreturn_t mb862xx_intr(int irq, void *dev_id)
583{ 583{
584 struct mb862xxfb_par *par = (struct mb862xxfb_par *) dev_id; 584 struct mb862xxfb_par *par = (struct mb862xxfb_par *) dev_id;
585 unsigned long reg_ist, mask; 585 unsigned long reg_ist, mask;
diff --git a/drivers/video/mbx/mbxfb.c b/drivers/video/mbx/mbxfb.c
index 55bf6196b7a0..ab0a8e527333 100644
--- a/drivers/video/mbx/mbxfb.c
+++ b/drivers/video/mbx/mbxfb.c
@@ -950,7 +950,7 @@ static int __devinit mbxfb_probe(struct platform_device *dev)
950 950
951 mfbi->fb_virt_addr = ioremap_nocache(mfbi->fb_phys_addr, 951 mfbi->fb_virt_addr = ioremap_nocache(mfbi->fb_phys_addr,
952 res_size(mfbi->fb_req)); 952 res_size(mfbi->fb_req));
953 if (!mfbi->reg_virt_addr) { 953 if (!mfbi->fb_virt_addr) {
954 dev_err(&dev->dev, "failed to ioremap frame buffer\n"); 954 dev_err(&dev->dev, "failed to ioremap frame buffer\n");
955 ret = -EINVAL; 955 ret = -EINVAL;
956 goto err4; 956 goto err4;
diff --git a/drivers/video/mxsfb.c b/drivers/video/mxsfb.c
index 4a89f889852d..abbe691047bd 100644
--- a/drivers/video/mxsfb.c
+++ b/drivers/video/mxsfb.c
@@ -45,6 +45,7 @@
45#include <linux/clk.h> 45#include <linux/clk.h>
46#include <linux/dma-mapping.h> 46#include <linux/dma-mapping.h>
47#include <linux/io.h> 47#include <linux/io.h>
48#include <linux/pinctrl/consumer.h>
48#include <mach/mxsfb.h> 49#include <mach/mxsfb.h>
49 50
50#define REG_SET 4 51#define REG_SET 4
@@ -756,6 +757,7 @@ static int __devinit mxsfb_probe(struct platform_device *pdev)
756 struct mxsfb_info *host; 757 struct mxsfb_info *host;
757 struct fb_info *fb_info; 758 struct fb_info *fb_info;
758 struct fb_modelist *modelist; 759 struct fb_modelist *modelist;
760 struct pinctrl *pinctrl;
759 int i, ret; 761 int i, ret;
760 762
761 if (!pdata) { 763 if (!pdata) {
@@ -793,6 +795,12 @@ static int __devinit mxsfb_probe(struct platform_device *pdev)
793 795
794 host->devdata = &mxsfb_devdata[pdev->id_entry->driver_data]; 796 host->devdata = &mxsfb_devdata[pdev->id_entry->driver_data];
795 797
798 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
799 if (IS_ERR(pinctrl)) {
800 ret = PTR_ERR(pinctrl);
801 goto error_getpin;
802 }
803
796 host->clk = clk_get(&host->pdev->dev, NULL); 804 host->clk = clk_get(&host->pdev->dev, NULL);
797 if (IS_ERR(host->clk)) { 805 if (IS_ERR(host->clk)) {
798 ret = PTR_ERR(host->clk); 806 ret = PTR_ERR(host->clk);
@@ -848,6 +856,7 @@ error_init_fb:
848error_pseudo_pallette: 856error_pseudo_pallette:
849 clk_put(host->clk); 857 clk_put(host->clk);
850error_getclock: 858error_getclock:
859error_getpin:
851 iounmap(host->base); 860 iounmap(host->base);
852error_ioremap: 861error_ioremap:
853 framebuffer_release(fb_info); 862 framebuffer_release(fb_info);
@@ -880,6 +889,18 @@ static int __devexit mxsfb_remove(struct platform_device *pdev)
880 return 0; 889 return 0;
881} 890}
882 891
892static void mxsfb_shutdown(struct platform_device *pdev)
893{
894 struct fb_info *fb_info = platform_get_drvdata(pdev);
895 struct mxsfb_info *host = to_imxfb_host(fb_info);
896
897 /*
898 * Force stop the LCD controller as keeping it running during reboot
899 * might interfere with the BootROM's boot mode pads sampling.
900 */
901 writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR);
902}
903
883static struct platform_device_id mxsfb_devtype[] = { 904static struct platform_device_id mxsfb_devtype[] = {
884 { 905 {
885 .name = "imx23-fb", 906 .name = "imx23-fb",
@@ -896,6 +917,7 @@ MODULE_DEVICE_TABLE(platform, mxsfb_devtype);
896static struct platform_driver mxsfb_driver = { 917static struct platform_driver mxsfb_driver = {
897 .probe = mxsfb_probe, 918 .probe = mxsfb_probe,
898 .remove = __devexit_p(mxsfb_remove), 919 .remove = __devexit_p(mxsfb_remove),
920 .shutdown = mxsfb_shutdown,
899 .id_table = mxsfb_devtype, 921 .id_table = mxsfb_devtype,
900 .driver = { 922 .driver = {
901 .name = DRIVER_NAME, 923 .name = DRIVER_NAME,
diff --git a/drivers/video/omap2/displays/panel-acx565akm.c b/drivers/video/omap2/displays/panel-acx565akm.c
index c98f2c16f744..ad741c3d1ae1 100644
--- a/drivers/video/omap2/displays/panel-acx565akm.c
+++ b/drivers/video/omap2/displays/panel-acx565akm.c
@@ -532,6 +532,7 @@ static int acx_panel_probe(struct omap_dss_device *dssdev)
532 532
533 /*------- Backlight control --------*/ 533 /*------- Backlight control --------*/
534 534
535 memset(&props, 0, sizeof(props));
535 props.fb_blank = FB_BLANK_UNBLANK; 536 props.fb_blank = FB_BLANK_UNBLANK;
536 props.power = FB_BLANK_UNBLANK; 537 props.power = FB_BLANK_UNBLANK;
537 props.type = BACKLIGHT_RAW; 538 props.type = BACKLIGHT_RAW;
diff --git a/drivers/video/pxa3xx-gcu.c b/drivers/video/pxa3xx-gcu.c
index 1d71c08a818f..0b4ae0cebeda 100644
--- a/drivers/video/pxa3xx-gcu.c
+++ b/drivers/video/pxa3xx-gcu.c
@@ -316,12 +316,9 @@ pxa3xx_gcu_wait_idle(struct pxa3xx_gcu_priv *priv)
316 ret = wait_event_interruptible_timeout(priv->wait_idle, 316 ret = wait_event_interruptible_timeout(priv->wait_idle,
317 !priv->shared->hw_running, HZ*4); 317 !priv->shared->hw_running, HZ*4);
318 318
319 if (ret < 0) 319 if (ret != 0)
320 break; 320 break;
321 321
322 if (ret > 0)
323 continue;
324
325 if (gc_readl(priv, REG_GCRBEXHR) == rbexhr && 322 if (gc_readl(priv, REG_GCRBEXHR) == rbexhr &&
326 priv->shared->num_interrupts == num) { 323 priv->shared->num_interrupts == num) {
327 QERROR("TIMEOUT"); 324 QERROR("TIMEOUT");
diff --git a/drivers/video/s3c-fb.c b/drivers/video/s3c-fb.c
index f3105160bf98..5f9d8e69029e 100644
--- a/drivers/video/s3c-fb.c
+++ b/drivers/video/s3c-fb.c
@@ -47,7 +47,7 @@
47#ifdef CONFIG_FB_S3C_DEBUG_REGWRITE 47#ifdef CONFIG_FB_S3C_DEBUG_REGWRITE
48#undef writel 48#undef writel
49#define writel(v, r) do { \ 49#define writel(v, r) do { \
50 printk(KERN_DEBUG "%s: %08x => %p\n", __func__, (unsigned int)v, r); \ 50 pr_debug("%s: %08x => %p\n", __func__, (unsigned int)v, r); \
51 __raw_writel(v, r); \ 51 __raw_writel(v, r); \
52} while (0) 52} while (0)
53#endif /* FB_S3C_DEBUG_REGWRITE */ 53#endif /* FB_S3C_DEBUG_REGWRITE */
@@ -495,7 +495,6 @@ static int s3c_fb_set_par(struct fb_info *info)
495 u32 alpha = 0; 495 u32 alpha = 0;
496 u32 data; 496 u32 data;
497 u32 pagewidth; 497 u32 pagewidth;
498 int clkdiv;
499 498
500 dev_dbg(sfb->dev, "setting framebuffer parameters\n"); 499 dev_dbg(sfb->dev, "setting framebuffer parameters\n");
501 500
@@ -532,48 +531,9 @@ static int s3c_fb_set_par(struct fb_info *info)
532 /* disable the window whilst we update it */ 531 /* disable the window whilst we update it */
533 writel(0, regs + WINCON(win_no)); 532 writel(0, regs + WINCON(win_no));
534 533
535 /* use platform specified window as the basis for the lcd timings */ 534 if (!sfb->output_on)
536
537 if (win_no == sfb->pdata->default_win) {
538 clkdiv = s3c_fb_calc_pixclk(sfb, var->pixclock);
539
540 data = sfb->pdata->vidcon0;
541 data &= ~(VIDCON0_CLKVAL_F_MASK | VIDCON0_CLKDIR);
542
543 if (clkdiv > 1)
544 data |= VIDCON0_CLKVAL_F(clkdiv-1) | VIDCON0_CLKDIR;
545 else
546 data &= ~VIDCON0_CLKDIR; /* 1:1 clock */
547
548 /* write the timing data to the panel */
549
550 if (sfb->variant.is_2443)
551 data |= (1 << 5);
552
553 writel(data, regs + VIDCON0);
554
555 s3c_fb_enable(sfb, 1); 535 s3c_fb_enable(sfb, 1);
556 536
557 data = VIDTCON0_VBPD(var->upper_margin - 1) |
558 VIDTCON0_VFPD(var->lower_margin - 1) |
559 VIDTCON0_VSPW(var->vsync_len - 1);
560
561 writel(data, regs + sfb->variant.vidtcon);
562
563 data = VIDTCON1_HBPD(var->left_margin - 1) |
564 VIDTCON1_HFPD(var->right_margin - 1) |
565 VIDTCON1_HSPW(var->hsync_len - 1);
566
567 /* VIDTCON1 */
568 writel(data, regs + sfb->variant.vidtcon + 4);
569
570 data = VIDTCON2_LINEVAL(var->yres - 1) |
571 VIDTCON2_HOZVAL(var->xres - 1) |
572 VIDTCON2_LINEVAL_E(var->yres - 1) |
573 VIDTCON2_HOZVAL_E(var->xres - 1);
574 writel(data, regs + sfb->variant.vidtcon + 8);
575 }
576
577 /* write the buffer address */ 537 /* write the buffer address */
578 538
579 /* start and end registers stride is 8 */ 539 /* start and end registers stride is 8 */
@@ -839,6 +799,7 @@ static int s3c_fb_blank(int blank_mode, struct fb_info *info)
839 struct s3c_fb *sfb = win->parent; 799 struct s3c_fb *sfb = win->parent;
840 unsigned int index = win->index; 800 unsigned int index = win->index;
841 u32 wincon; 801 u32 wincon;
802 u32 output_on = sfb->output_on;
842 803
843 dev_dbg(sfb->dev, "blank mode %d\n", blank_mode); 804 dev_dbg(sfb->dev, "blank mode %d\n", blank_mode);
844 805
@@ -877,34 +838,18 @@ static int s3c_fb_blank(int blank_mode, struct fb_info *info)
877 838
878 shadow_protect_win(win, 1); 839 shadow_protect_win(win, 1);
879 writel(wincon, sfb->regs + sfb->variant.wincon + (index * 4)); 840 writel(wincon, sfb->regs + sfb->variant.wincon + (index * 4));
880 shadow_protect_win(win, 0);
881 841
882 /* Check the enabled state to see if we need to be running the 842 /* Check the enabled state to see if we need to be running the
883 * main LCD interface, as if there are no active windows then 843 * main LCD interface, as if there are no active windows then
884 * it is highly likely that we also do not need to output 844 * it is highly likely that we also do not need to output
885 * anything. 845 * anything.
886 */ 846 */
887 847 s3c_fb_enable(sfb, sfb->enabled ? 1 : 0);
888 /* We could do something like the following code, but the current 848 shadow_protect_win(win, 0);
889 * system of using framebuffer events means that we cannot make
890 * the distinction between just window 0 being inactive and all
891 * the windows being down.
892 *
893 * s3c_fb_enable(sfb, sfb->enabled ? 1 : 0);
894 */
895
896 /* we're stuck with this until we can do something about overriding
897 * the power control using the blanking event for a single fb.
898 */
899 if (index == sfb->pdata->default_win) {
900 shadow_protect_win(win, 1);
901 s3c_fb_enable(sfb, blank_mode != FB_BLANK_POWERDOWN ? 1 : 0);
902 shadow_protect_win(win, 0);
903 }
904 849
905 pm_runtime_put_sync(sfb->dev); 850 pm_runtime_put_sync(sfb->dev);
906 851
907 return 0; 852 return output_on == sfb->output_on;
908} 853}
909 854
910/** 855/**
@@ -1111,7 +1056,7 @@ static struct fb_ops s3c_fb_ops = {
1111 * 1056 *
1112 * Calculate the pixel clock when none has been given through platform data. 1057 * Calculate the pixel clock when none has been given through platform data.
1113 */ 1058 */
1114static void __devinit s3c_fb_missing_pixclock(struct fb_videomode *mode) 1059static void s3c_fb_missing_pixclock(struct fb_videomode *mode)
1115{ 1060{
1116 u64 pixclk = 1000000000000ULL; 1061 u64 pixclk = 1000000000000ULL;
1117 u32 div; 1062 u32 div;
@@ -1144,11 +1089,11 @@ static int __devinit s3c_fb_alloc_memory(struct s3c_fb *sfb,
1144 1089
1145 dev_dbg(sfb->dev, "allocating memory for display\n"); 1090 dev_dbg(sfb->dev, "allocating memory for display\n");
1146 1091
1147 real_size = windata->win_mode.xres * windata->win_mode.yres; 1092 real_size = windata->xres * windata->yres;
1148 virt_size = windata->virtual_x * windata->virtual_y; 1093 virt_size = windata->virtual_x * windata->virtual_y;
1149 1094
1150 dev_dbg(sfb->dev, "real_size=%u (%u.%u), virt_size=%u (%u.%u)\n", 1095 dev_dbg(sfb->dev, "real_size=%u (%u.%u), virt_size=%u (%u.%u)\n",
1151 real_size, windata->win_mode.xres, windata->win_mode.yres, 1096 real_size, windata->xres, windata->yres,
1152 virt_size, windata->virtual_x, windata->virtual_y); 1097 virt_size, windata->virtual_x, windata->virtual_y);
1153 1098
1154 size = (real_size > virt_size) ? real_size : virt_size; 1099 size = (real_size > virt_size) ? real_size : virt_size;
@@ -1230,7 +1175,7 @@ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
1230 struct s3c_fb_win **res) 1175 struct s3c_fb_win **res)
1231{ 1176{
1232 struct fb_var_screeninfo *var; 1177 struct fb_var_screeninfo *var;
1233 struct fb_videomode *initmode; 1178 struct fb_videomode initmode;
1234 struct s3c_fb_pd_win *windata; 1179 struct s3c_fb_pd_win *windata;
1235 struct s3c_fb_win *win; 1180 struct s3c_fb_win *win;
1236 struct fb_info *fbinfo; 1181 struct fb_info *fbinfo;
@@ -1251,11 +1196,11 @@ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
1251 } 1196 }
1252 1197
1253 windata = sfb->pdata->win[win_no]; 1198 windata = sfb->pdata->win[win_no];
1254 initmode = &windata->win_mode; 1199 initmode = *sfb->pdata->vtiming;
1255 1200
1256 WARN_ON(windata->max_bpp == 0); 1201 WARN_ON(windata->max_bpp == 0);
1257 WARN_ON(windata->win_mode.xres == 0); 1202 WARN_ON(windata->xres == 0);
1258 WARN_ON(windata->win_mode.yres == 0); 1203 WARN_ON(windata->yres == 0);
1259 1204
1260 win = fbinfo->par; 1205 win = fbinfo->par;
1261 *res = win; 1206 *res = win;
@@ -1294,7 +1239,9 @@ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
1294 } 1239 }
1295 1240
1296 /* setup the initial video mode from the window */ 1241 /* setup the initial video mode from the window */
1297 fb_videomode_to_var(&fbinfo->var, initmode); 1242 initmode.xres = windata->xres;
1243 initmode.yres = windata->yres;
1244 fb_videomode_to_var(&fbinfo->var, &initmode);
1298 1245
1299 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS; 1246 fbinfo->fix.type = FB_TYPE_PACKED_PIXELS;
1300 fbinfo->fix.accel = FB_ACCEL_NONE; 1247 fbinfo->fix.accel = FB_ACCEL_NONE;
@@ -1339,6 +1286,53 @@ static int __devinit s3c_fb_probe_win(struct s3c_fb *sfb, unsigned int win_no,
1339} 1286}
1340 1287
1341/** 1288/**
1289 * s3c_fb_set_rgb_timing() - set video timing for rgb interface.
1290 * @sfb: The base resources for the hardware.
1291 *
1292 * Set horizontal and vertical lcd rgb interface timing.
1293 */
1294static void s3c_fb_set_rgb_timing(struct s3c_fb *sfb)
1295{
1296 struct fb_videomode *vmode = sfb->pdata->vtiming;
1297 void __iomem *regs = sfb->regs;
1298 int clkdiv;
1299 u32 data;
1300
1301 if (!vmode->pixclock)
1302 s3c_fb_missing_pixclock(vmode);
1303
1304 clkdiv = s3c_fb_calc_pixclk(sfb, vmode->pixclock);
1305
1306 data = sfb->pdata->vidcon0;
1307 data &= ~(VIDCON0_CLKVAL_F_MASK | VIDCON0_CLKDIR);
1308
1309 if (clkdiv > 1)
1310 data |= VIDCON0_CLKVAL_F(clkdiv-1) | VIDCON0_CLKDIR;
1311 else
1312 data &= ~VIDCON0_CLKDIR; /* 1:1 clock */
1313
1314 if (sfb->variant.is_2443)
1315 data |= (1 << 5);
1316 writel(data, regs + VIDCON0);
1317
1318 data = VIDTCON0_VBPD(vmode->upper_margin - 1) |
1319 VIDTCON0_VFPD(vmode->lower_margin - 1) |
1320 VIDTCON0_VSPW(vmode->vsync_len - 1);
1321 writel(data, regs + sfb->variant.vidtcon);
1322
1323 data = VIDTCON1_HBPD(vmode->left_margin - 1) |
1324 VIDTCON1_HFPD(vmode->right_margin - 1) |
1325 VIDTCON1_HSPW(vmode->hsync_len - 1);
1326 writel(data, regs + sfb->variant.vidtcon + 4);
1327
1328 data = VIDTCON2_LINEVAL(vmode->yres - 1) |
1329 VIDTCON2_HOZVAL(vmode->xres - 1) |
1330 VIDTCON2_LINEVAL_E(vmode->yres - 1) |
1331 VIDTCON2_HOZVAL_E(vmode->xres - 1);
1332 writel(data, regs + sfb->variant.vidtcon + 8);
1333}
1334
1335/**
1342 * s3c_fb_clear_win() - clear hardware window registers. 1336 * s3c_fb_clear_win() - clear hardware window registers.
1343 * @sfb: The base resources for the hardware. 1337 * @sfb: The base resources for the hardware.
1344 * @win: The window to process. 1338 * @win: The window to process.
@@ -1481,15 +1475,14 @@ static int __devinit s3c_fb_probe(struct platform_device *pdev)
1481 writel(0xffffff, regs + WKEYCON1); 1475 writel(0xffffff, regs + WKEYCON1);
1482 } 1476 }
1483 1477
1478 s3c_fb_set_rgb_timing(sfb);
1479
1484 /* we have the register setup, start allocating framebuffers */ 1480 /* we have the register setup, start allocating framebuffers */
1485 1481
1486 for (win = 0; win < fbdrv->variant.nr_windows; win++) { 1482 for (win = 0; win < fbdrv->variant.nr_windows; win++) {
1487 if (!pd->win[win]) 1483 if (!pd->win[win])
1488 continue; 1484 continue;
1489 1485
1490 if (!pd->win[win]->win_mode.pixclock)
1491 s3c_fb_missing_pixclock(&pd->win[win]->win_mode);
1492
1493 ret = s3c_fb_probe_win(sfb, win, fbdrv->win[win], 1486 ret = s3c_fb_probe_win(sfb, win, fbdrv->win[win],
1494 &sfb->windows[win]); 1487 &sfb->windows[win]);
1495 if (ret < 0) { 1488 if (ret < 0) {
@@ -1564,6 +1557,8 @@ static int s3c_fb_suspend(struct device *dev)
1564 struct s3c_fb_win *win; 1557 struct s3c_fb_win *win;
1565 int win_no; 1558 int win_no;
1566 1559
1560 pm_runtime_get_sync(sfb->dev);
1561
1567 for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) { 1562 for (win_no = S3C_FB_MAX_WIN - 1; win_no >= 0; win_no--) {
1568 win = sfb->windows[win_no]; 1563 win = sfb->windows[win_no];
1569 if (!win) 1564 if (!win)
@@ -1577,6 +1572,9 @@ static int s3c_fb_suspend(struct device *dev)
1577 clk_disable(sfb->lcd_clk); 1572 clk_disable(sfb->lcd_clk);
1578 1573
1579 clk_disable(sfb->bus_clk); 1574 clk_disable(sfb->bus_clk);
1575
1576 pm_runtime_put_sync(sfb->dev);
1577
1580 return 0; 1578 return 0;
1581} 1579}
1582 1580
@@ -1589,6 +1587,8 @@ static int s3c_fb_resume(struct device *dev)
1589 int win_no; 1587 int win_no;
1590 u32 reg; 1588 u32 reg;
1591 1589
1590 pm_runtime_get_sync(sfb->dev);
1591
1592 clk_enable(sfb->bus_clk); 1592 clk_enable(sfb->bus_clk);
1593 1593
1594 if (!sfb->variant.has_clksel) 1594 if (!sfb->variant.has_clksel)
@@ -1623,6 +1623,8 @@ static int s3c_fb_resume(struct device *dev)
1623 shadow_protect_win(win, 0); 1623 shadow_protect_win(win, 0);
1624 } 1624 }
1625 1625
1626 s3c_fb_set_rgb_timing(sfb);
1627
1626 /* restore framebuffers */ 1628 /* restore framebuffers */
1627 for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) { 1629 for (win_no = 0; win_no < S3C_FB_MAX_WIN; win_no++) {
1628 win = sfb->windows[win_no]; 1630 win = sfb->windows[win_no];
@@ -1633,6 +1635,8 @@ static int s3c_fb_resume(struct device *dev)
1633 s3c_fb_set_par(win->fbinfo); 1635 s3c_fb_set_par(win->fbinfo);
1634 } 1636 }
1635 1637
1638 pm_runtime_put_sync(sfb->dev);
1639
1636 return 0; 1640 return 0;
1637} 1641}
1638#endif 1642#endif
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c
index eafb19da2c07..930e550e752a 100644
--- a/drivers/video/sh_mobile_hdmi.c
+++ b/drivers/video/sh_mobile_hdmi.c
@@ -31,6 +31,7 @@
31 31
32#include "sh_mobile_lcdcfb.h" 32#include "sh_mobile_lcdcfb.h"
33 33
34/* HDMI Core Control Register (HTOP0) */
34#define HDMI_SYSTEM_CTRL 0x00 /* System control */ 35#define HDMI_SYSTEM_CTRL 0x00 /* System control */
35#define HDMI_L_R_DATA_SWAP_CTRL_RPKT 0x01 /* L/R data swap control, 36#define HDMI_L_R_DATA_SWAP_CTRL_RPKT 0x01 /* L/R data swap control,
36 bits 19..16 of 20-bit N for Audio Clock Regeneration packet */ 37 bits 19..16 of 20-bit N for Audio Clock Regeneration packet */
@@ -201,6 +202,68 @@
201#define HDMI_REVISION_ID 0xF1 /* Revision ID */ 202#define HDMI_REVISION_ID 0xF1 /* Revision ID */
202#define HDMI_TEST_MODE 0xFE /* Test mode */ 203#define HDMI_TEST_MODE 0xFE /* Test mode */
203 204
205/* HDMI Control Register (HTOP1) */
206#define HDMI_HTOP1_TEST_MODE 0x0000 /* Test mode */
207#define HDMI_HTOP1_VIDEO_INPUT 0x0008 /* VideoInput */
208#define HDMI_HTOP1_CORE_RSTN 0x000C /* CoreResetn */
209#define HDMI_HTOP1_PLLBW 0x0018 /* PLLBW */
210#define HDMI_HTOP1_CLK_TO_PHY 0x001C /* Clk to Phy */
211#define HDMI_HTOP1_VIDEO_INPUT2 0x0020 /* VideoInput2 */
212#define HDMI_HTOP1_TISEMP0_1 0x0024 /* tisemp0-1 */
213#define HDMI_HTOP1_TISEMP2_C 0x0028 /* tisemp2-c */
214#define HDMI_HTOP1_TISIDRV 0x002C /* tisidrv */
215#define HDMI_HTOP1_TISEN 0x0034 /* tisen */
216#define HDMI_HTOP1_TISDREN 0x0038 /* tisdren */
217#define HDMI_HTOP1_CISRANGE 0x003C /* cisrange */
218#define HDMI_HTOP1_ENABLE_SELECTOR 0x0040 /* Enable Selector */
219#define HDMI_HTOP1_MACRO_RESET 0x0044 /* Macro reset */
220#define HDMI_HTOP1_PLL_CALIBRATION 0x0048 /* PLL calibration */
221#define HDMI_HTOP1_RE_CALIBRATION 0x004C /* Re-calibration */
222#define HDMI_HTOP1_CURRENT 0x0050 /* Current */
223#define HDMI_HTOP1_PLL_LOCK_DETECT 0x0054 /* PLL lock detect */
224#define HDMI_HTOP1_PHY_TEST_MODE 0x0058 /* PHY Test Mode */
225#define HDMI_HTOP1_CLK_SET 0x0080 /* Clock Set */
226#define HDMI_HTOP1_DDC_FAIL_SAFE 0x0084 /* DDC fail safe */
227#define HDMI_HTOP1_PRBS 0x0088 /* PRBS */
228#define HDMI_HTOP1_EDID_AINC_CONTROL 0x008C /* EDID ainc Control */
229#define HDMI_HTOP1_HTOP_DCL_MODE 0x00FC /* Deep Coloer Mode */
230#define HDMI_HTOP1_HTOP_DCL_FRC_COEF0 0x0100 /* Deep Color:FRC COEF0 */
231#define HDMI_HTOP1_HTOP_DCL_FRC_COEF1 0x0104 /* Deep Color:FRC COEF1 */
232#define HDMI_HTOP1_HTOP_DCL_FRC_COEF2 0x0108 /* Deep Color:FRC COEF2 */
233#define HDMI_HTOP1_HTOP_DCL_FRC_COEF3 0x010C /* Deep Color:FRC COEF3 */
234#define HDMI_HTOP1_HTOP_DCL_FRC_COEF0_C 0x0110 /* Deep Color:FRC COEF0C */
235#define HDMI_HTOP1_HTOP_DCL_FRC_COEF1_C 0x0114 /* Deep Color:FRC COEF1C */
236#define HDMI_HTOP1_HTOP_DCL_FRC_COEF2_C 0x0118 /* Deep Color:FRC COEF2C */
237#define HDMI_HTOP1_HTOP_DCL_FRC_COEF3_C 0x011C /* Deep Color:FRC COEF3C */
238#define HDMI_HTOP1_HTOP_DCL_FRC_MODE 0x0120 /* Deep Color:FRC Mode */
239#define HDMI_HTOP1_HTOP_DCL_RECT_START1 0x0124 /* Deep Color:Rect Start1 */
240#define HDMI_HTOP1_HTOP_DCL_RECT_SIZE1 0x0128 /* Deep Color:Rect Size1 */
241#define HDMI_HTOP1_HTOP_DCL_RECT_START2 0x012C /* Deep Color:Rect Start2 */
242#define HDMI_HTOP1_HTOP_DCL_RECT_SIZE2 0x0130 /* Deep Color:Rect Size2 */
243#define HDMI_HTOP1_HTOP_DCL_RECT_START3 0x0134 /* Deep Color:Rect Start3 */
244#define HDMI_HTOP1_HTOP_DCL_RECT_SIZE3 0x0138 /* Deep Color:Rect Size3 */
245#define HDMI_HTOP1_HTOP_DCL_RECT_START4 0x013C /* Deep Color:Rect Start4 */
246#define HDMI_HTOP1_HTOP_DCL_RECT_SIZE4 0x0140 /* Deep Color:Rect Size4 */
247#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_1 0x0144 /* Deep Color:Fil Para Y1_1 */
248#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_2 0x0148 /* Deep Color:Fil Para Y1_2 */
249#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_1 0x014C /* Deep Color:Fil Para CB1_1 */
250#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_2 0x0150 /* Deep Color:Fil Para CB1_2 */
251#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_1 0x0154 /* Deep Color:Fil Para CR1_1 */
252#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_2 0x0158 /* Deep Color:Fil Para CR1_2 */
253#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_1 0x015C /* Deep Color:Fil Para Y2_1 */
254#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_2 0x0160 /* Deep Color:Fil Para Y2_2 */
255#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_1 0x0164 /* Deep Color:Fil Para CB2_1 */
256#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_2 0x0168 /* Deep Color:Fil Para CB2_2 */
257#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_1 0x016C /* Deep Color:Fil Para CR2_1 */
258#define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_2 0x0170 /* Deep Color:Fil Para CR2_2 */
259#define HDMI_HTOP1_HTOP_DCL_COR_PARA_Y1 0x0174 /* Deep Color:Cor Para Y1 */
260#define HDMI_HTOP1_HTOP_DCL_COR_PARA_CB1 0x0178 /* Deep Color:Cor Para CB1 */
261#define HDMI_HTOP1_HTOP_DCL_COR_PARA_CR1 0x017C /* Deep Color:Cor Para CR1 */
262#define HDMI_HTOP1_HTOP_DCL_COR_PARA_Y2 0x0180 /* Deep Color:Cor Para Y2 */
263#define HDMI_HTOP1_HTOP_DCL_COR_PARA_CB2 0x0184 /* Deep Color:Cor Para CB2 */
264#define HDMI_HTOP1_HTOP_DCL_COR_PARA_CR2 0x0188 /* Deep Color:Cor Para CR2 */
265#define HDMI_HTOP1_EDID_DATA_READ 0x0200 /* EDID Data Read 128Byte:0x03FC */
266
204enum hotplug_state { 267enum hotplug_state {
205 HDMI_HOTPLUG_DISCONNECTED, 268 HDMI_HOTPLUG_DISCONNECTED,
206 HDMI_HOTPLUG_CONNECTED, 269 HDMI_HOTPLUG_CONNECTED,
@@ -211,6 +274,7 @@ struct sh_hdmi {
211 struct sh_mobile_lcdc_entity entity; 274 struct sh_mobile_lcdc_entity entity;
212 275
213 void __iomem *base; 276 void __iomem *base;
277 void __iomem *htop1;
214 enum hotplug_state hp_state; /* hot-plug status */ 278 enum hotplug_state hp_state; /* hot-plug status */
215 u8 preprogrammed_vic; /* use a pre-programmed VIC or 279 u8 preprogrammed_vic; /* use a pre-programmed VIC or
216 the external mode */ 280 the external mode */
@@ -222,20 +286,66 @@ struct sh_hdmi {
222 struct delayed_work edid_work; 286 struct delayed_work edid_work;
223 struct fb_videomode mode; 287 struct fb_videomode mode;
224 struct fb_monspecs monspec; 288 struct fb_monspecs monspec;
289
290 /* register access functions */
291 void (*write)(struct sh_hdmi *hdmi, u8 data, u8 reg);
292 u8 (*read)(struct sh_hdmi *hdmi, u8 reg);
225}; 293};
226 294
227#define entity_to_sh_hdmi(e) container_of(e, struct sh_hdmi, entity) 295#define entity_to_sh_hdmi(e) container_of(e, struct sh_hdmi, entity)
228 296
229static void hdmi_write(struct sh_hdmi *hdmi, u8 data, u8 reg) 297static void __hdmi_write8(struct sh_hdmi *hdmi, u8 data, u8 reg)
230{ 298{
231 iowrite8(data, hdmi->base + reg); 299 iowrite8(data, hdmi->base + reg);
232} 300}
233 301
234static u8 hdmi_read(struct sh_hdmi *hdmi, u8 reg) 302static u8 __hdmi_read8(struct sh_hdmi *hdmi, u8 reg)
235{ 303{
236 return ioread8(hdmi->base + reg); 304 return ioread8(hdmi->base + reg);
237} 305}
238 306
307static void __hdmi_write32(struct sh_hdmi *hdmi, u8 data, u8 reg)
308{
309 iowrite32((u32)data, hdmi->base + (reg * 4));
310 udelay(100);
311}
312
313static u8 __hdmi_read32(struct sh_hdmi *hdmi, u8 reg)
314{
315 return (u8)ioread32(hdmi->base + (reg * 4));
316}
317
318static void hdmi_write(struct sh_hdmi *hdmi, u8 data, u8 reg)
319{
320 hdmi->write(hdmi, data, reg);
321}
322
323static u8 hdmi_read(struct sh_hdmi *hdmi, u8 reg)
324{
325 return hdmi->read(hdmi, reg);
326}
327
328static void hdmi_bit_set(struct sh_hdmi *hdmi, u8 mask, u8 data, u8 reg)
329{
330 u8 val = hdmi_read(hdmi, reg);
331
332 val &= ~mask;
333 val |= (data & mask);
334
335 hdmi_write(hdmi, val, reg);
336}
337
338static void hdmi_htop1_write(struct sh_hdmi *hdmi, u32 data, u32 reg)
339{
340 iowrite32(data, hdmi->htop1 + reg);
341 udelay(100);
342}
343
344static u32 hdmi_htop1_read(struct sh_hdmi *hdmi, u32 reg)
345{
346 return ioread32(hdmi->htop1 + reg);
347}
348
239/* 349/*
240 * HDMI sound 350 * HDMI sound
241 */ 351 */
@@ -693,11 +803,11 @@ static void sh_hdmi_configure(struct sh_hdmi *hdmi)
693 msleep(10); 803 msleep(10);
694 804
695 /* PS mode b->d, reset PLLA and PLLB */ 805 /* PS mode b->d, reset PLLA and PLLB */
696 hdmi_write(hdmi, 0x4C, HDMI_SYSTEM_CTRL); 806 hdmi_bit_set(hdmi, 0xFC, 0x4C, HDMI_SYSTEM_CTRL);
697 807
698 udelay(10); 808 udelay(10);
699 809
700 hdmi_write(hdmi, 0x40, HDMI_SYSTEM_CTRL); 810 hdmi_bit_set(hdmi, 0xFC, 0x40, HDMI_SYSTEM_CTRL);
701} 811}
702 812
703static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi, 813static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi,
@@ -746,7 +856,9 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate,
746 /* Read EDID */ 856 /* Read EDID */
747 dev_dbg(hdmi->dev, "Read back EDID code:"); 857 dev_dbg(hdmi->dev, "Read back EDID code:");
748 for (i = 0; i < 128; i++) { 858 for (i = 0; i < 128; i++) {
749 edid[i] = hdmi_read(hdmi, HDMI_EDID_KSV_FIFO_ACCESS_WINDOW); 859 edid[i] = (hdmi->htop1) ?
860 (u8)hdmi_htop1_read(hdmi, HDMI_HTOP1_EDID_DATA_READ + (i * 4)) :
861 hdmi_read(hdmi, HDMI_EDID_KSV_FIFO_ACCESS_WINDOW);
750#ifdef DEBUG 862#ifdef DEBUG
751 if ((i % 16) == 0) { 863 if ((i % 16) == 0) {
752 printk(KERN_CONT "\n"); 864 printk(KERN_CONT "\n");
@@ -917,13 +1029,13 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id)
917 u8 status1, status2, mask1, mask2; 1029 u8 status1, status2, mask1, mask2;
918 1030
919 /* mode_b and PLLA and PLLB reset */ 1031 /* mode_b and PLLA and PLLB reset */
920 hdmi_write(hdmi, 0x2C, HDMI_SYSTEM_CTRL); 1032 hdmi_bit_set(hdmi, 0xFC, 0x2C, HDMI_SYSTEM_CTRL);
921 1033
922 /* How long shall reset be held? */ 1034 /* How long shall reset be held? */
923 udelay(10); 1035 udelay(10);
924 1036
925 /* mode_b and PLLA and PLLB reset release */ 1037 /* mode_b and PLLA and PLLB reset release */
926 hdmi_write(hdmi, 0x20, HDMI_SYSTEM_CTRL); 1038 hdmi_bit_set(hdmi, 0xFC, 0x20, HDMI_SYSTEM_CTRL);
927 1039
928 status1 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_1); 1040 status1 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_1);
929 status2 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_2); 1041 status2 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_2);
@@ -1001,7 +1113,7 @@ static int sh_hdmi_display_on(struct sh_mobile_lcdc_entity *entity)
1001 */ 1113 */
1002 if (hdmi->hp_state == HDMI_HOTPLUG_EDID_DONE) { 1114 if (hdmi->hp_state == HDMI_HOTPLUG_EDID_DONE) {
1003 /* PS mode d->e. All functions are active */ 1115 /* PS mode d->e. All functions are active */
1004 hdmi_write(hdmi, 0x80, HDMI_SYSTEM_CTRL); 1116 hdmi_bit_set(hdmi, 0xFC, 0x80, HDMI_SYSTEM_CTRL);
1005 dev_dbg(hdmi->dev, "HDMI running\n"); 1117 dev_dbg(hdmi->dev, "HDMI running\n");
1006 } 1118 }
1007 1119
@@ -1016,7 +1128,7 @@ static void sh_hdmi_display_off(struct sh_mobile_lcdc_entity *entity)
1016 1128
1017 dev_dbg(hdmi->dev, "%s(%p)\n", __func__, hdmi); 1129 dev_dbg(hdmi->dev, "%s(%p)\n", __func__, hdmi);
1018 /* PS mode e->a */ 1130 /* PS mode e->a */
1019 hdmi_write(hdmi, 0x10, HDMI_SYSTEM_CTRL); 1131 hdmi_bit_set(hdmi, 0xFC, 0x10, HDMI_SYSTEM_CTRL);
1020} 1132}
1021 1133
1022static const struct sh_mobile_lcdc_entity_ops sh_hdmi_ops = { 1134static const struct sh_mobile_lcdc_entity_ops sh_hdmi_ops = {
@@ -1110,10 +1222,58 @@ out:
1110 dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, hdmi); 1222 dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, hdmi);
1111} 1223}
1112 1224
1225static void sh_hdmi_htop1_init(struct sh_hdmi *hdmi)
1226{
1227 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_MODE);
1228 hdmi_htop1_write(hdmi, 0x0000000b, 0x0010);
1229 hdmi_htop1_write(hdmi, 0x00006710, HDMI_HTOP1_HTOP_DCL_FRC_MODE);
1230 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_1);
1231 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_2);
1232 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_1);
1233 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_2);
1234 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_1);
1235 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_2);
1236 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_1);
1237 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_2);
1238 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_1);
1239 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_2);
1240 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_1);
1241 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_2);
1242 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_Y1);
1243 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CB1);
1244 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CR1);
1245 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_Y2);
1246 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CB2);
1247 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CR2);
1248 hdmi_htop1_write(hdmi, 0x00000008, HDMI_HTOP1_CURRENT);
1249 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_TISEMP0_1);
1250 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_TISEMP2_C);
1251 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_PHY_TEST_MODE);
1252 hdmi_htop1_write(hdmi, 0x00000081, HDMI_HTOP1_TISIDRV);
1253 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_PLLBW);
1254 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISEN);
1255 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISDREN);
1256 hdmi_htop1_write(hdmi, 0x00000003, HDMI_HTOP1_ENABLE_SELECTOR);
1257 hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_MACRO_RESET);
1258 hdmi_htop1_write(hdmi, 0x00000016, HDMI_HTOP1_CISRANGE);
1259 msleep(100);
1260 hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_ENABLE_SELECTOR);
1261 msleep(100);
1262 hdmi_htop1_write(hdmi, 0x00000003, HDMI_HTOP1_ENABLE_SELECTOR);
1263 hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_MACRO_RESET);
1264 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISEN);
1265 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISDREN);
1266 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_VIDEO_INPUT);
1267 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_CLK_TO_PHY);
1268 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_VIDEO_INPUT2);
1269 hdmi_htop1_write(hdmi, 0x0000000a, HDMI_HTOP1_CLK_SET);
1270}
1271
1113static int __init sh_hdmi_probe(struct platform_device *pdev) 1272static int __init sh_hdmi_probe(struct platform_device *pdev)
1114{ 1273{
1115 struct sh_mobile_hdmi_info *pdata = pdev->dev.platform_data; 1274 struct sh_mobile_hdmi_info *pdata = pdev->dev.platform_data;
1116 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1275 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1276 struct resource *htop1_res;
1117 int irq = platform_get_irq(pdev, 0), ret; 1277 int irq = platform_get_irq(pdev, 0), ret;
1118 struct sh_hdmi *hdmi; 1278 struct sh_hdmi *hdmi;
1119 long rate; 1279 long rate;
@@ -1121,6 +1281,15 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1121 if (!res || !pdata || irq < 0) 1281 if (!res || !pdata || irq < 0)
1122 return -ENODEV; 1282 return -ENODEV;
1123 1283
1284 htop1_res = NULL;
1285 if (pdata->flags & HDMI_HAS_HTOP1) {
1286 htop1_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
1287 if (!htop1_res) {
1288 dev_err(&pdev->dev, "htop1 needs register base\n");
1289 return -EINVAL;
1290 }
1291 }
1292
1124 hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); 1293 hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL);
1125 if (!hdmi) { 1294 if (!hdmi) {
1126 dev_err(&pdev->dev, "Cannot allocate device data\n"); 1295 dev_err(&pdev->dev, "Cannot allocate device data\n");
@@ -1138,6 +1307,15 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1138 goto egetclk; 1307 goto egetclk;
1139 } 1308 }
1140 1309
1310 /* select register access functions */
1311 if (pdata->flags & HDMI_32BIT_REG) {
1312 hdmi->write = __hdmi_write32;
1313 hdmi->read = __hdmi_read32;
1314 } else {
1315 hdmi->write = __hdmi_write8;
1316 hdmi->read = __hdmi_read8;
1317 }
1318
1141 /* An arbitrary relaxed pixclock just to get things started: from standard 480p */ 1319 /* An arbitrary relaxed pixclock just to get things started: from standard 480p */
1142 rate = clk_round_rate(hdmi->hdmi_clk, PICOS2KHZ(37037)); 1320 rate = clk_round_rate(hdmi->hdmi_clk, PICOS2KHZ(37037));
1143 if (rate > 0) 1321 if (rate > 0)
@@ -1176,6 +1354,24 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1176 pm_runtime_enable(&pdev->dev); 1354 pm_runtime_enable(&pdev->dev);
1177 pm_runtime_get_sync(&pdev->dev); 1355 pm_runtime_get_sync(&pdev->dev);
1178 1356
1357 /* init interrupt polarity */
1358 if (pdata->flags & HDMI_OUTPUT_PUSH_PULL)
1359 hdmi_bit_set(hdmi, 0x02, 0x02, HDMI_SYSTEM_CTRL);
1360
1361 if (pdata->flags & HDMI_OUTPUT_POLARITY_HI)
1362 hdmi_bit_set(hdmi, 0x01, 0x01, HDMI_SYSTEM_CTRL);
1363
1364 /* enable htop1 register if needed */
1365 if (htop1_res) {
1366 hdmi->htop1 = ioremap(htop1_res->start, resource_size(htop1_res));
1367 if (!hdmi->htop1) {
1368 dev_err(&pdev->dev, "control register region already claimed\n");
1369 ret = -ENOMEM;
1370 goto emap_htop1;
1371 }
1372 sh_hdmi_htop1_init(hdmi);
1373 }
1374
1179 /* Product and revision IDs are 0 in sh-mobile version */ 1375 /* Product and revision IDs are 0 in sh-mobile version */
1180 dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n", 1376 dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n",
1181 hdmi_read(hdmi, HDMI_PRODUCT_ID), hdmi_read(hdmi, HDMI_REVISION_ID)); 1377 hdmi_read(hdmi, HDMI_PRODUCT_ID), hdmi_read(hdmi, HDMI_REVISION_ID));
@@ -1199,6 +1395,9 @@ static int __init sh_hdmi_probe(struct platform_device *pdev)
1199ecodec: 1395ecodec:
1200 free_irq(irq, hdmi); 1396 free_irq(irq, hdmi);
1201ereqirq: 1397ereqirq:
1398 if (hdmi->htop1)
1399 iounmap(hdmi->htop1);
1400emap_htop1:
1202 pm_runtime_put(&pdev->dev); 1401 pm_runtime_put(&pdev->dev);
1203 pm_runtime_disable(&pdev->dev); 1402 pm_runtime_disable(&pdev->dev);
1204 iounmap(hdmi->base); 1403 iounmap(hdmi->base);
@@ -1230,6 +1429,8 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev)
1230 pm_runtime_disable(&pdev->dev); 1429 pm_runtime_disable(&pdev->dev);
1231 clk_disable(hdmi->hdmi_clk); 1430 clk_disable(hdmi->hdmi_clk);
1232 clk_put(hdmi->hdmi_clk); 1431 clk_put(hdmi->hdmi_clk);
1432 if (hdmi->htop1)
1433 iounmap(hdmi->htop1);
1233 iounmap(hdmi->base); 1434 iounmap(hdmi->base);
1234 release_mem_region(res->start, resource_size(res)); 1435 release_mem_region(res->start, resource_size(res));
1235 kfree(hdmi); 1436 kfree(hdmi);
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 7a0b301587f6..e672698bd820 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -758,7 +758,7 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
758 } 758 }
759 759
760 lcdc_write_chan(ch, LDDFR, tmp); 760 lcdc_write_chan(ch, LDDFR, tmp);
761 lcdc_write_chan(ch, LDMLSR, ch->pitch); 761 lcdc_write_chan(ch, LDMLSR, ch->line_size);
762 lcdc_write_chan(ch, LDSA1R, ch->base_addr_y); 762 lcdc_write_chan(ch, LDSA1R, ch->base_addr_y);
763 if (ch->format->yuv) 763 if (ch->format->yuv)
764 lcdc_write_chan(ch, LDSA2R, ch->base_addr_c); 764 lcdc_write_chan(ch, LDSA2R, ch->base_addr_c);
@@ -847,6 +847,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
847 847
848 ch->base_addr_y = ch->dma_handle; 848 ch->base_addr_y = ch->dma_handle;
849 ch->base_addr_c = ch->base_addr_y + ch->xres * ch->yres_virtual; 849 ch->base_addr_c = ch->base_addr_y + ch->xres * ch->yres_virtual;
850 ch->line_size = ch->pitch;
850 851
851 /* Enable MERAM if possible. */ 852 /* Enable MERAM if possible. */
852 if (mdev == NULL || mdev->ops == NULL || 853 if (mdev == NULL || mdev->ops == NULL ||
@@ -882,7 +883,7 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
882 883
883 meram = mdev->ops->meram_register(mdev, ch->cfg->meram_cfg, 884 meram = mdev->ops->meram_register(mdev, ch->cfg->meram_cfg,
884 ch->pitch, ch->yres, pixelformat, 885 ch->pitch, ch->yres, pixelformat,
885 &ch->pitch); 886 &ch->line_size);
886 if (!IS_ERR(meram)) { 887 if (!IS_ERR(meram)) {
887 mdev->ops->meram_update(mdev, meram, 888 mdev->ops->meram_update(mdev, meram,
888 ch->base_addr_y, ch->base_addr_c, 889 ch->base_addr_y, ch->base_addr_c,
diff --git a/drivers/video/sh_mobile_lcdcfb.h b/drivers/video/sh_mobile_lcdcfb.h
index da1c26e78a57..5c3bddd2cb72 100644
--- a/drivers/video/sh_mobile_lcdcfb.h
+++ b/drivers/video/sh_mobile_lcdcfb.h
@@ -84,6 +84,7 @@ struct sh_mobile_lcdc_chan {
84 84
85 unsigned long base_addr_y; 85 unsigned long base_addr_y;
86 unsigned long base_addr_c; 86 unsigned long base_addr_c;
87 unsigned int line_size;
87 88
88 int (*notify)(struct sh_mobile_lcdc_chan *ch, 89 int (*notify)(struct sh_mobile_lcdc_chan *ch,
89 enum sh_mobile_lcdc_entity_event event, 90 enum sh_mobile_lcdc_entity_event event,
diff --git a/drivers/video/sis/init.h b/drivers/video/sis/init.h
index aff73842d877..85d6738b6c64 100644
--- a/drivers/video/sis/init.h
+++ b/drivers/video/sis/init.h
@@ -105,51 +105,6 @@ static const unsigned short ModeIndex_1920x1440[] = {0x68, 0x69, 0x00, 0x6b};
105static const unsigned short ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00}; 105static const unsigned short ModeIndex_300_2048x1536[]= {0x6c, 0x6d, 0x00, 0x00};
106static const unsigned short ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e}; 106static const unsigned short ModeIndex_310_2048x1536[]= {0x6c, 0x6d, 0x00, 0x6e};
107 107
108static const unsigned short SiS_DRAMType[17][5]={
109 {0x0C,0x0A,0x02,0x40,0x39},
110 {0x0D,0x0A,0x01,0x40,0x48},
111 {0x0C,0x09,0x02,0x20,0x35},
112 {0x0D,0x09,0x01,0x20,0x44},
113 {0x0C,0x08,0x02,0x10,0x31},
114 {0x0D,0x08,0x01,0x10,0x40},
115 {0x0C,0x0A,0x01,0x20,0x34},
116 {0x0C,0x09,0x01,0x08,0x32},
117 {0x0B,0x08,0x02,0x08,0x21},
118 {0x0C,0x08,0x01,0x08,0x30},
119 {0x0A,0x08,0x02,0x04,0x11},
120 {0x0B,0x0A,0x01,0x10,0x28},
121 {0x09,0x08,0x02,0x02,0x01},
122 {0x0B,0x09,0x01,0x08,0x24},
123 {0x0B,0x08,0x01,0x04,0x20},
124 {0x0A,0x08,0x01,0x02,0x10},
125 {0x09,0x08,0x01,0x01,0x00}
126};
127
128static const unsigned short SiS_SDRDRAM_TYPE[13][5] =
129{
130 { 2,12, 9,64,0x35},
131 { 1,13, 9,64,0x44},
132 { 2,12, 8,32,0x31},
133 { 2,11, 9,32,0x25},
134 { 1,12, 9,32,0x34},
135 { 1,13, 8,32,0x40},
136 { 2,11, 8,16,0x21},
137 { 1,12, 8,16,0x30},
138 { 1,11, 9,16,0x24},
139 { 1,11, 8, 8,0x20},
140 { 2, 9, 8, 4,0x01},
141 { 1,10, 8, 4,0x10},
142 { 1, 9, 8, 2,0x00}
143};
144
145static const unsigned short SiS_DDRDRAM_TYPE[4][5] =
146{
147 { 2,12, 9,64,0x35},
148 { 2,12, 8,32,0x31},
149 { 2,11, 8,16,0x21},
150 { 2, 9, 8, 4,0x01}
151};
152
153static const unsigned char SiS_MDA_DAC[] = 108static const unsigned char SiS_MDA_DAC[] =
154{ 109{
155 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 110 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c
index 078ca2167d6f..a7a48db64ce2 100644
--- a/drivers/video/sis/sis_main.c
+++ b/drivers/video/sis/sis_main.c
@@ -4222,6 +4222,26 @@ sisfb_post_300_buswidth(struct sis_video_info *ivideo)
4222 return 1; /* 32bit */ 4222 return 1; /* 32bit */
4223} 4223}
4224 4224
4225static const unsigned short __devinitconst SiS_DRAMType[17][5] = {
4226 {0x0C,0x0A,0x02,0x40,0x39},
4227 {0x0D,0x0A,0x01,0x40,0x48},
4228 {0x0C,0x09,0x02,0x20,0x35},
4229 {0x0D,0x09,0x01,0x20,0x44},
4230 {0x0C,0x08,0x02,0x10,0x31},
4231 {0x0D,0x08,0x01,0x10,0x40},
4232 {0x0C,0x0A,0x01,0x20,0x34},
4233 {0x0C,0x09,0x01,0x08,0x32},
4234 {0x0B,0x08,0x02,0x08,0x21},
4235 {0x0C,0x08,0x01,0x08,0x30},
4236 {0x0A,0x08,0x02,0x04,0x11},
4237 {0x0B,0x0A,0x01,0x10,0x28},
4238 {0x09,0x08,0x02,0x02,0x01},
4239 {0x0B,0x09,0x01,0x08,0x24},
4240 {0x0B,0x08,0x01,0x04,0x20},
4241 {0x0A,0x08,0x01,0x02,0x10},
4242 {0x09,0x08,0x01,0x01,0x00}
4243};
4244
4225static int __devinit 4245static int __devinit
4226sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration, int buswidth, 4246sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration, int buswidth,
4227 int PseudoRankCapacity, int PseudoAdrPinCount, 4247 int PseudoRankCapacity, int PseudoAdrPinCount,
@@ -4231,27 +4251,8 @@ sisfb_post_300_rwtest(struct sis_video_info *ivideo, int iteration, int buswidth
4231 unsigned short sr14; 4251 unsigned short sr14;
4232 unsigned int k, RankCapacity, PageCapacity, BankNumHigh, BankNumMid; 4252 unsigned int k, RankCapacity, PageCapacity, BankNumHigh, BankNumMid;
4233 unsigned int PhysicalAdrOtherPage, PhysicalAdrHigh, PhysicalAdrHalfPage; 4253 unsigned int PhysicalAdrOtherPage, PhysicalAdrHigh, PhysicalAdrHalfPage;
4234 static const unsigned short SiS_DRAMType[17][5] = {
4235 {0x0C,0x0A,0x02,0x40,0x39},
4236 {0x0D,0x0A,0x01,0x40,0x48},
4237 {0x0C,0x09,0x02,0x20,0x35},
4238 {0x0D,0x09,0x01,0x20,0x44},
4239 {0x0C,0x08,0x02,0x10,0x31},
4240 {0x0D,0x08,0x01,0x10,0x40},
4241 {0x0C,0x0A,0x01,0x20,0x34},
4242 {0x0C,0x09,0x01,0x08,0x32},
4243 {0x0B,0x08,0x02,0x08,0x21},
4244 {0x0C,0x08,0x01,0x08,0x30},
4245 {0x0A,0x08,0x02,0x04,0x11},
4246 {0x0B,0x0A,0x01,0x10,0x28},
4247 {0x09,0x08,0x02,0x02,0x01},
4248 {0x0B,0x09,0x01,0x08,0x24},
4249 {0x0B,0x08,0x01,0x04,0x20},
4250 {0x0A,0x08,0x01,0x02,0x10},
4251 {0x09,0x08,0x01,0x01,0x00}
4252 };
4253 4254
4254 for(k = 0; k <= 16; k++) { 4255 for(k = 0; k < ARRAY_SIZE(SiS_DRAMType); k++) {
4255 4256
4256 RankCapacity = buswidth * SiS_DRAMType[k][3]; 4257 RankCapacity = buswidth * SiS_DRAMType[k][3];
4257 4258
diff --git a/drivers/video/skeletonfb.c b/drivers/video/skeletonfb.c
index 30f7a815a62b..5b6abc6de84b 100644
--- a/drivers/video/skeletonfb.c
+++ b/drivers/video/skeletonfb.c
@@ -1036,6 +1036,6 @@ static void __exit xxxfb_exit(void)
1036 */ 1036 */
1037 1037
1038module_init(xxxfb_init); 1038module_init(xxxfb_init);
1039module_exit(xxxfb_remove); 1039module_exit(xxxfb_exit);
1040 1040
1041MODULE_LICENSE("GPL"); 1041MODULE_LICENSE("GPL");
diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
index ccbfef5e828f..af3ef27ad36c 100644
--- a/drivers/video/smscufx.c
+++ b/drivers/video/smscufx.c
@@ -846,7 +846,7 @@ static void ufx_raw_rect(struct ufx_data *dev, u16 *cmd, int x, int y,
846 } 846 }
847} 847}
848 848
849int ufx_handle_damage(struct ufx_data *dev, int x, int y, 849static int ufx_handle_damage(struct ufx_data *dev, int x, int y,
850 int width, int height) 850 int width, int height)
851{ 851{
852 size_t packed_line_len = ALIGN((width * 2), 4); 852 size_t packed_line_len = ALIGN((width * 2), 4);
@@ -1083,7 +1083,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
1083 1083
1084 struct fb_deferred_io *fbdefio; 1084 struct fb_deferred_io *fbdefio;
1085 1085
1086 fbdefio = kmalloc(sizeof(struct fb_deferred_io), GFP_KERNEL); 1086 fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
1087 1087
1088 if (fbdefio) { 1088 if (fbdefio) {
1089 fbdefio->delay = UFX_DEFIO_WRITE_DELAY; 1089 fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
index a159b63e18b9..8af64148294b 100644
--- a/drivers/video/udlfb.c
+++ b/drivers/video/udlfb.c
@@ -893,7 +893,7 @@ static int dlfb_ops_open(struct fb_info *info, int user)
893 893
894 struct fb_deferred_io *fbdefio; 894 struct fb_deferred_io *fbdefio;
895 895
896 fbdefio = kmalloc(sizeof(struct fb_deferred_io), GFP_KERNEL); 896 fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
897 897
898 if (fbdefio) { 898 if (fbdefio) {
899 fbdefio->delay = DL_DEFIO_WRITE_DELAY; 899 fbdefio->delay = DL_DEFIO_WRITE_DELAY;
@@ -1594,7 +1594,7 @@ static int dlfb_usb_probe(struct usb_interface *interface,
1594 1594
1595 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1595 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
1596 if (dev == NULL) { 1596 if (dev == NULL) {
1597 err("dlfb_usb_probe: failed alloc of dev struct\n"); 1597 dev_err(&interface->dev, "dlfb_usb_probe: failed alloc of dev struct\n");
1598 goto error; 1598 goto error;
1599 } 1599 }
1600 1600
diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
index 26e83d7fdd6f..b0e2a4261afe 100644
--- a/drivers/video/uvesafb.c
+++ b/drivers/video/uvesafb.c
@@ -73,7 +73,7 @@ static void uvesafb_cn_callback(struct cn_msg *msg, struct netlink_skb_parms *ns
73 struct uvesafb_task *utask; 73 struct uvesafb_task *utask;
74 struct uvesafb_ktask *task; 74 struct uvesafb_ktask *task;
75 75
76 if (!cap_raised(current_cap(), CAP_SYS_ADMIN)) 76 if (!capable(CAP_SYS_ADMIN))
77 return; 77 return;
78 78
79 if (msg->seq >= UVESAFB_TASKS_MAX) 79 if (msg->seq >= UVESAFB_TASKS_MAX)
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index 0c8837565bc7..c80e770e1800 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -1276,17 +1276,12 @@ static int viafb_dfph_proc_open(struct inode *inode, struct file *file)
1276static ssize_t viafb_dfph_proc_write(struct file *file, 1276static ssize_t viafb_dfph_proc_write(struct file *file,
1277 const char __user *buffer, size_t count, loff_t *pos) 1277 const char __user *buffer, size_t count, loff_t *pos)
1278{ 1278{
1279 char buf[20]; 1279 int err;
1280 u8 reg_val = 0; 1280 u8 reg_val;
1281 unsigned long length; 1281 err = kstrtou8_from_user(buffer, count, 0, &reg_val);
1282 if (count < 1) 1282 if (err)
1283 return -EINVAL; 1283 return err;
1284 length = count > 20 ? 20 : count; 1284
1285 if (copy_from_user(&buf[0], buffer, length))
1286 return -EFAULT;
1287 buf[length - 1] = '\0'; /*Ensure end string */
1288 if (kstrtou8(buf, 0, &reg_val) < 0)
1289 return -EINVAL;
1290 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f); 1285 viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f);
1291 return count; 1286 return count;
1292} 1287}
@@ -1316,17 +1311,12 @@ static int viafb_dfpl_proc_open(struct inode *inode, struct file *file)
1316static ssize_t viafb_dfpl_proc_write(struct file *file, 1311static ssize_t viafb_dfpl_proc_write(struct file *file,
1317 const char __user *buffer, size_t count, loff_t *pos) 1312 const char __user *buffer, size_t count, loff_t *pos)
1318{ 1313{
1319 char buf[20]; 1314 int err;
1320 u8 reg_val = 0; 1315 u8 reg_val;
1321 unsigned long length; 1316 err = kstrtou8_from_user(buffer, count, 0, &reg_val);
1322 if (count < 1) 1317 if (err)
1323 return -EINVAL; 1318 return err;
1324 length = count > 20 ? 20 : count; 1319
1325 if (copy_from_user(&buf[0], buffer, length))
1326 return -EFAULT;
1327 buf[length - 1] = '\0'; /*Ensure end string */
1328 if (kstrtou8(buf, 0, &reg_val) < 0)
1329 return -EINVAL;
1330 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f); 1320 viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f);
1331 return count; 1321 return count;
1332} 1322}
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index cb4529c40d74..b7f5173ff9e9 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -365,7 +365,7 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
365 struct fb_info *fb_info; 365 struct fb_info *fb_info;
366 int fb_size; 366 int fb_size;
367 int val; 367 int val;
368 int ret; 368 int ret = 0;
369 369
370 info = kzalloc(sizeof(*info), GFP_KERNEL); 370 info = kzalloc(sizeof(*info), GFP_KERNEL);
371 if (info == NULL) { 371 if (info == NULL) {
@@ -458,26 +458,31 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
458 xenfb_init_shared_page(info, fb_info); 458 xenfb_init_shared_page(info, fb_info);
459 459
460 ret = xenfb_connect_backend(dev, info); 460 ret = xenfb_connect_backend(dev, info);
461 if (ret < 0) 461 if (ret < 0) {
462 goto error; 462 xenbus_dev_fatal(dev, ret, "xenfb_connect_backend");
463 goto error_fb;
464 }
463 465
464 ret = register_framebuffer(fb_info); 466 ret = register_framebuffer(fb_info);
465 if (ret) { 467 if (ret) {
466 fb_deferred_io_cleanup(fb_info);
467 fb_dealloc_cmap(&fb_info->cmap);
468 framebuffer_release(fb_info);
469 xenbus_dev_fatal(dev, ret, "register_framebuffer"); 468 xenbus_dev_fatal(dev, ret, "register_framebuffer");
470 goto error; 469 goto error_fb;
471 } 470 }
472 info->fb_info = fb_info; 471 info->fb_info = fb_info;
473 472
474 xenfb_make_preferred_console(); 473 xenfb_make_preferred_console();
475 return 0; 474 return 0;
476 475
477 error_nomem: 476error_fb:
478 ret = -ENOMEM; 477 fb_deferred_io_cleanup(fb_info);
479 xenbus_dev_fatal(dev, ret, "allocating device memory"); 478 fb_dealloc_cmap(&fb_info->cmap);
480 error: 479 framebuffer_release(fb_info);
480error_nomem:
481 if (!ret) {
482 ret = -ENOMEM;
483 xenbus_dev_fatal(dev, ret, "allocating device memory");
484 }
485error:
481 xenfb_remove(dev); 486 xenfb_remove(dev);
482 return ret; 487 return ret;
483} 488}