diff options
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/Kconfig | 32 | ||||
-rw-r--r-- | drivers/video/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/backlight/Kconfig | 37 | ||||
-rw-r--r-- | drivers/video/backlight/Makefile | 4 | ||||
-rw-r--r-- | drivers/video/backlight/corgi_lcd.c | 4 | ||||
-rw-r--r-- | drivers/video/backlight/da903x.c | 201 | ||||
-rw-r--r-- | drivers/video/backlight/hp680_bl.c | 2 | ||||
-rw-r--r-- | drivers/video/backlight/kb3886_bl.c | 204 | ||||
-rw-r--r-- | drivers/video/backlight/tosa_bl.c | 198 | ||||
-rw-r--r-- | drivers/video/backlight/tosa_lcd.c | 280 | ||||
-rw-r--r-- | drivers/video/cirrusfb.c | 2 | ||||
-rw-r--r-- | drivers/video/console/fbcon.c | 2 | ||||
-rw-r--r-- | drivers/video/fbmem.c | 207 | ||||
-rw-r--r-- | drivers/video/imacfb.c | 0 | ||||
-rw-r--r-- | drivers/video/mb862xx/Makefile | 5 | ||||
-rw-r--r-- | drivers/video/mb862xx/mb862xx_reg.h | 138 | ||||
-rw-r--r-- | drivers/video/mb862xx/mb862xxfb.c | 1061 | ||||
-rw-r--r-- | drivers/video/mb862xx/mb862xxfb.h | 83 | ||||
-rw-r--r-- | drivers/video/sh_mobile_lcdcfb.c | 14 | ||||
-rw-r--r-- | drivers/video/via/global.h | 3 |
20 files changed, 2387 insertions, 91 deletions
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 0f13448c6f7..3f3ce13fef4 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -2083,6 +2083,38 @@ config FB_METRONOME | |||
2083 | controller. The pre-release name for this device was 8track | 2083 | controller. The pre-release name for this device was 8track |
2084 | and could also have been called by some vendors as PVI-nnnn. | 2084 | and could also have been called by some vendors as PVI-nnnn. |
2085 | 2085 | ||
2086 | config FB_MB862XX | ||
2087 | tristate "Fujitsu MB862xx GDC support" | ||
2088 | depends on FB | ||
2089 | select FB_CFB_FILLRECT | ||
2090 | select FB_CFB_COPYAREA | ||
2091 | select FB_CFB_IMAGEBLIT | ||
2092 | ---help--- | ||
2093 | Frame buffer driver for Fujitsu Carmine/Coral-P(A)/Lime controllers. | ||
2094 | |||
2095 | config FB_MB862XX_PCI_GDC | ||
2096 | bool "Carmine/Coral-P(A) GDC" | ||
2097 | depends on PCI && FB_MB862XX | ||
2098 | ---help--- | ||
2099 | This enables framebuffer support for Fujitsu Carmine/Coral-P(A) | ||
2100 | PCI graphics controller devices. | ||
2101 | |||
2102 | config FB_MB862XX_LIME | ||
2103 | bool "Lime GDC" | ||
2104 | depends on FB_MB862XX | ||
2105 | depends on OF && !FB_MB862XX_PCI_GDC | ||
2106 | select FB_FOREIGN_ENDIAN | ||
2107 | select FB_LITTLE_ENDIAN | ||
2108 | ---help--- | ||
2109 | Framebuffer support for Fujitsu Lime GDC on host CPU bus. | ||
2110 | |||
2111 | config FB_PRE_INIT_FB | ||
2112 | bool "Don't reinitialize, use bootloader's GDC/Display configuration" | ||
2113 | depends on FB_MB862XX_LIME | ||
2114 | ---help--- | ||
2115 | Select this option if display contents should be inherited as set by | ||
2116 | the bootloader. | ||
2117 | |||
2086 | source "drivers/video/omap/Kconfig" | 2118 | source "drivers/video/omap/Kconfig" |
2087 | 2119 | ||
2088 | source "drivers/video/backlight/Kconfig" | 2120 | source "drivers/video/backlight/Kconfig" |
diff --git a/drivers/video/Makefile b/drivers/video/Makefile index 248bddc8d0b..e39e33e797d 100644 --- a/drivers/video/Makefile +++ b/drivers/video/Makefile | |||
@@ -122,6 +122,7 @@ obj-$(CONFIG_FB_SH_MOBILE_LCDC) += sh_mobile_lcdcfb.o | |||
122 | obj-$(CONFIG_FB_OMAP) += omap/ | 122 | obj-$(CONFIG_FB_OMAP) += omap/ |
123 | obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o | 123 | obj-$(CONFIG_XEN_FBDEV_FRONTEND) += xen-fbfront.o |
124 | obj-$(CONFIG_FB_CARMINE) += carminefb.o | 124 | obj-$(CONFIG_FB_CARMINE) += carminefb.o |
125 | obj-$(CONFIG_FB_MB862XX) += mb862xx/ | ||
125 | 126 | ||
126 | # Platform or fallback drivers go here | 127 | # Platform or fallback drivers go here |
127 | obj-$(CONFIG_FB_UVESA) += uvesafb.o | 128 | obj-$(CONFIG_FB_UVESA) += uvesafb.o |
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index c72a1356295..4a4dd9adc32 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig | |||
@@ -75,6 +75,15 @@ config LCD_PLATFORM | |||
75 | This driver provides a platform-device registered LCD power | 75 | This driver provides a platform-device registered LCD power |
76 | control interface. | 76 | control interface. |
77 | 77 | ||
78 | config LCD_TOSA | ||
79 | tristate "Sharp SL-6000 LCD Driver" | ||
80 | depends on LCD_CLASS_DEVICE && SPI | ||
81 | depends on MACH_TOSA | ||
82 | default n | ||
83 | help | ||
84 | If you have an Sharp SL-6000 Zaurus say Y to enable a driver | ||
85 | for its LCD. | ||
86 | |||
78 | # | 87 | # |
79 | # Backlight | 88 | # Backlight |
80 | # | 89 | # |
@@ -115,7 +124,7 @@ config BACKLIGHT_ATMEL_PWM | |||
115 | called atmel-pwm-bl. | 124 | called atmel-pwm-bl. |
116 | 125 | ||
117 | config BACKLIGHT_CORGI | 126 | config BACKLIGHT_CORGI |
118 | tristate "Generic (aka Sharp Corgi) Backlight Driver" | 127 | tristate "Generic (aka Sharp Corgi) Backlight Driver (DEPRECATED)" |
119 | depends on BACKLIGHT_CLASS_DEVICE | 128 | depends on BACKLIGHT_CLASS_DEVICE |
120 | default n | 129 | default n |
121 | help | 130 | help |
@@ -123,6 +132,9 @@ config BACKLIGHT_CORGI | |||
123 | known as the Corgi backlight driver. If you have a Sharp Zaurus | 132 | known as the Corgi backlight driver. If you have a Sharp Zaurus |
124 | SL-C7xx, SL-Cxx00 or SL-6000x say y. Most users can say n. | 133 | SL-C7xx, SL-Cxx00 or SL-6000x say y. Most users can say n. |
125 | 134 | ||
135 | Note: this driver is marked as deprecated, try enable SPI and | ||
136 | use the new corgi_lcd driver with integrated backlight control | ||
137 | |||
126 | config BACKLIGHT_LOCOMO | 138 | config BACKLIGHT_LOCOMO |
127 | tristate "Sharp LOCOMO LCD/Backlight Driver" | 139 | tristate "Sharp LOCOMO LCD/Backlight Driver" |
128 | depends on BACKLIGHT_CLASS_DEVICE && SHARP_LOCOMO | 140 | depends on BACKLIGHT_CLASS_DEVICE && SHARP_LOCOMO |
@@ -171,6 +183,13 @@ config BACKLIGHT_PWM | |||
171 | If you have a LCD backlight adjustable by PWM, say Y to enable | 183 | If you have a LCD backlight adjustable by PWM, say Y to enable |
172 | this driver. | 184 | this driver. |
173 | 185 | ||
186 | config BACKLIGHT_DA903X | ||
187 | tristate "Backlight Driver for DA9030/DA9034 using WLED" | ||
188 | depends on BACKLIGHT_CLASS_DEVICE && PMIC_DA903X | ||
189 | help | ||
190 | If you have a LCD backlight connected to the WLED output of DA9030 | ||
191 | or DA9034 WLED output, say Y here to enable this driver. | ||
192 | |||
174 | config BACKLIGHT_MBP_NVIDIA | 193 | config BACKLIGHT_MBP_NVIDIA |
175 | tristate "MacBook Pro Nvidia Backlight Driver" | 194 | tristate "MacBook Pro Nvidia Backlight Driver" |
176 | depends on BACKLIGHT_CLASS_DEVICE && X86 | 195 | depends on BACKLIGHT_CLASS_DEVICE && X86 |
@@ -179,3 +198,19 @@ config BACKLIGHT_MBP_NVIDIA | |||
179 | If you have an Apple Macbook Pro with Nvidia graphics hardware say Y | 198 | If you have an Apple Macbook Pro with Nvidia graphics hardware say Y |
180 | to enable a driver for its backlight | 199 | to enable a driver for its backlight |
181 | 200 | ||
201 | config BACKLIGHT_TOSA | ||
202 | tristate "Sharp SL-6000 Backlight Driver" | ||
203 | depends on BACKLIGHT_CLASS_DEVICE && I2C | ||
204 | depends on MACH_TOSA && LCD_TOSA | ||
205 | default n | ||
206 | help | ||
207 | If you have an Sharp SL-6000 Zaurus say Y to enable a driver | ||
208 | for its backlight | ||
209 | |||
210 | config BACKLIGHT_SAHARA | ||
211 | tristate "Tabletkiosk Sahara Touch-iT Backlight Driver" | ||
212 | depends on BACKLIGHT_CLASS_DEVICE && X86 | ||
213 | default n | ||
214 | help | ||
215 | If you have a Tabletkiosk Sahara Touch-iT, say y to enable the | ||
216 | backlight driver. | ||
diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 3ec551eb472..103427de670 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile | |||
@@ -7,6 +7,7 @@ obj-$(CONFIG_LCD_ILI9320) += ili9320.o | |||
7 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o | 7 | obj-$(CONFIG_LCD_PLATFORM) += platform_lcd.o |
8 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o | 8 | obj-$(CONFIG_LCD_VGG2432A4) += vgg2432a4.o |
9 | obj-$(CONFIG_LCD_TDO24M) += tdo24m.o | 9 | obj-$(CONFIG_LCD_TDO24M) += tdo24m.o |
10 | obj-$(CONFIG_LCD_TOSA) += tosa_lcd.o | ||
10 | 11 | ||
11 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o | 12 | obj-$(CONFIG_BACKLIGHT_CLASS_DEVICE) += backlight.o |
12 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o | 13 | obj-$(CONFIG_BACKLIGHT_ATMEL_PWM) += atmel-pwm-bl.o |
@@ -17,5 +18,8 @@ obj-$(CONFIG_BACKLIGHT_OMAP1) += omap1_bl.o | |||
17 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o | 18 | obj-$(CONFIG_BACKLIGHT_PROGEAR) += progear_bl.o |
18 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o | 19 | obj-$(CONFIG_BACKLIGHT_CARILLO_RANCH) += cr_bllcd.o |
19 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o | 20 | obj-$(CONFIG_BACKLIGHT_PWM) += pwm_bl.o |
21 | obj-$(CONFIG_BACKLIGHT_DA903X) += da903x.o | ||
20 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o | 22 | obj-$(CONFIG_BACKLIGHT_MBP_NVIDIA) += mbp_nvidia_bl.o |
23 | obj-$(CONFIG_BACKLIGHT_TOSA) += tosa_bl.o | ||
24 | obj-$(CONFIG_BACKLIGHT_SAHARA) += kb3886_bl.o | ||
21 | 25 | ||
diff --git a/drivers/video/backlight/corgi_lcd.c b/drivers/video/backlight/corgi_lcd.c index 2afd47eefe7..f8a4bb20f41 100644 --- a/drivers/video/backlight/corgi_lcd.c +++ b/drivers/video/backlight/corgi_lcd.c | |||
@@ -439,7 +439,7 @@ static int corgi_bl_update_status(struct backlight_device *bd) | |||
439 | return corgi_bl_set_intensity(lcd, intensity); | 439 | return corgi_bl_set_intensity(lcd, intensity); |
440 | } | 440 | } |
441 | 441 | ||
442 | void corgibl_limit_intensity(int limit) | 442 | void corgi_lcd_limit_intensity(int limit) |
443 | { | 443 | { |
444 | if (limit) | 444 | if (limit) |
445 | corgibl_flags |= CORGIBL_BATTLOW; | 445 | corgibl_flags |= CORGIBL_BATTLOW; |
@@ -448,7 +448,7 @@ void corgibl_limit_intensity(int limit) | |||
448 | 448 | ||
449 | backlight_update_status(the_corgi_lcd->bl_dev); | 449 | backlight_update_status(the_corgi_lcd->bl_dev); |
450 | } | 450 | } |
451 | EXPORT_SYMBOL(corgibl_limit_intensity); | 451 | EXPORT_SYMBOL(corgi_lcd_limit_intensity); |
452 | 452 | ||
453 | static struct backlight_ops corgi_bl_ops = { | 453 | static struct backlight_ops corgi_bl_ops = { |
454 | .get_brightness = corgi_bl_get_intensity, | 454 | .get_brightness = corgi_bl_get_intensity, |
diff --git a/drivers/video/backlight/da903x.c b/drivers/video/backlight/da903x.c new file mode 100644 index 00000000000..242c3825016 --- /dev/null +++ b/drivers/video/backlight/da903x.c | |||
@@ -0,0 +1,201 @@ | |||
1 | /* | ||
2 | * Backlight driver for Dialog Semiconductor DA9030/DA9034 | ||
3 | * | ||
4 | * Copyright (C) 2008 Compulab, Ltd. | ||
5 | * Mike Rapoport <mike@compulab.co.il> | ||
6 | * | ||
7 | * Copyright (C) 2006-2008 Marvell International Ltd. | ||
8 | * Eric Miao <eric.miao@marvell.com> | ||
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 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/fb.h> | ||
19 | #include <linux/backlight.h> | ||
20 | #include <linux/mfd/da903x.h> | ||
21 | |||
22 | #define DA9030_WLED_CONTROL 0x25 | ||
23 | #define DA9030_WLED_CP_EN (1 << 6) | ||
24 | #define DA9030_WLED_TRIM(x) ((x) & 0x7) | ||
25 | |||
26 | #define DA9034_WLED_CONTROL1 0x3C | ||
27 | #define DA9034_WLED_CONTROL2 0x3D | ||
28 | |||
29 | #define DA9034_WLED_BOOST_EN (1 << 5) | ||
30 | |||
31 | #define DA9030_MAX_BRIGHTNESS 7 | ||
32 | #define DA9034_MAX_BRIGHTNESS 0x7f | ||
33 | |||
34 | struct da903x_backlight_data { | ||
35 | struct device *da903x_dev; | ||
36 | int id; | ||
37 | int current_brightness; | ||
38 | }; | ||
39 | |||
40 | static int da903x_backlight_set(struct backlight_device *bl, int brightness) | ||
41 | { | ||
42 | struct da903x_backlight_data *data = bl_get_data(bl); | ||
43 | struct device *dev = data->da903x_dev; | ||
44 | uint8_t val; | ||
45 | int ret = 0; | ||
46 | |||
47 | switch (data->id) { | ||
48 | case DA9034_ID_WLED: | ||
49 | ret = da903x_update(dev, DA9034_WLED_CONTROL1, | ||
50 | brightness, 0x7f); | ||
51 | if (ret) | ||
52 | return ret; | ||
53 | |||
54 | if (data->current_brightness && brightness == 0) | ||
55 | ret = da903x_clr_bits(dev, | ||
56 | DA9034_WLED_CONTROL2, | ||
57 | DA9034_WLED_BOOST_EN); | ||
58 | |||
59 | if (data->current_brightness == 0 && brightness) | ||
60 | ret = da903x_set_bits(dev, | ||
61 | DA9034_WLED_CONTROL2, | ||
62 | DA9034_WLED_BOOST_EN); | ||
63 | break; | ||
64 | case DA9030_ID_WLED: | ||
65 | val = DA9030_WLED_TRIM(brightness); | ||
66 | val |= brightness ? DA9030_WLED_CP_EN : 0; | ||
67 | ret = da903x_write(dev, DA9030_WLED_CONTROL, val); | ||
68 | break; | ||
69 | } | ||
70 | |||
71 | if (ret) | ||
72 | return ret; | ||
73 | |||
74 | data->current_brightness = brightness; | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static int da903x_backlight_update_status(struct backlight_device *bl) | ||
79 | { | ||
80 | int brightness = bl->props.brightness; | ||
81 | |||
82 | if (bl->props.power != FB_BLANK_UNBLANK) | ||
83 | brightness = 0; | ||
84 | |||
85 | if (bl->props.fb_blank != FB_BLANK_UNBLANK) | ||
86 | brightness = 0; | ||
87 | |||
88 | return da903x_backlight_set(bl, brightness); | ||
89 | } | ||
90 | |||
91 | static int da903x_backlight_get_brightness(struct backlight_device *bl) | ||
92 | { | ||
93 | struct da903x_backlight_data *data = bl_get_data(bl); | ||
94 | return data->current_brightness; | ||
95 | } | ||
96 | |||
97 | static struct backlight_ops da903x_backlight_ops = { | ||
98 | .update_status = da903x_backlight_update_status, | ||
99 | .get_brightness = da903x_backlight_get_brightness, | ||
100 | }; | ||
101 | |||
102 | static int da903x_backlight_probe(struct platform_device *pdev) | ||
103 | { | ||
104 | struct da903x_backlight_data *data; | ||
105 | struct backlight_device *bl; | ||
106 | int max_brightness; | ||
107 | |||
108 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
109 | if (data == NULL) | ||
110 | return -ENOMEM; | ||
111 | |||
112 | switch (pdev->id) { | ||
113 | case DA9030_ID_WLED: | ||
114 | max_brightness = DA9030_MAX_BRIGHTNESS; | ||
115 | break; | ||
116 | case DA9034_ID_WLED: | ||
117 | max_brightness = DA9034_MAX_BRIGHTNESS; | ||
118 | break; | ||
119 | default: | ||
120 | dev_err(&pdev->dev, "invalid backlight device ID(%d)\n", | ||
121 | pdev->id); | ||
122 | return -EINVAL; | ||
123 | } | ||
124 | |||
125 | data->id = pdev->id; | ||
126 | data->da903x_dev = pdev->dev.parent; | ||
127 | data->current_brightness = 0; | ||
128 | |||
129 | bl = backlight_device_register(pdev->name, data->da903x_dev, | ||
130 | data, &da903x_backlight_ops); | ||
131 | if (IS_ERR(bl)) { | ||
132 | dev_err(&pdev->dev, "failed to register backlight\n"); | ||
133 | return PTR_ERR(bl); | ||
134 | } | ||
135 | |||
136 | bl->props.max_brightness = max_brightness; | ||
137 | bl->props.brightness = max_brightness; | ||
138 | |||
139 | platform_set_drvdata(pdev, bl); | ||
140 | backlight_update_status(bl); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static int da903x_backlight_remove(struct platform_device *pdev) | ||
145 | { | ||
146 | struct backlight_device *bl = platform_get_drvdata(pdev); | ||
147 | struct da903x_backlight_data *data = bl_get_data(bl); | ||
148 | |||
149 | backlight_device_unregister(bl); | ||
150 | kfree(data); | ||
151 | return 0; | ||
152 | } | ||
153 | |||
154 | #ifdef CONFIG_PM | ||
155 | static int da903x_backlight_suspend(struct platform_device *pdev, | ||
156 | pm_message_t state) | ||
157 | { | ||
158 | struct backlight_device *bl = platform_get_drvdata(pdev); | ||
159 | return da903x_backlight_set(bl, 0); | ||
160 | } | ||
161 | |||
162 | static int da903x_backlight_resume(struct platform_device *pdev) | ||
163 | { | ||
164 | struct backlight_device *bl = platform_get_drvdata(pdev); | ||
165 | |||
166 | backlight_update_status(bl); | ||
167 | return 0; | ||
168 | } | ||
169 | #else | ||
170 | #define da903x_backlight_suspend NULL | ||
171 | #define da903x_backlight_resume NULL | ||
172 | #endif | ||
173 | |||
174 | static struct platform_driver da903x_backlight_driver = { | ||
175 | .driver = { | ||
176 | .name = "da903x-backlight", | ||
177 | .owner = THIS_MODULE, | ||
178 | }, | ||
179 | .probe = da903x_backlight_probe, | ||
180 | .remove = da903x_backlight_remove, | ||
181 | .suspend = da903x_backlight_suspend, | ||
182 | .resume = da903x_backlight_resume, | ||
183 | }; | ||
184 | |||
185 | static int __init da903x_backlight_init(void) | ||
186 | { | ||
187 | return platform_driver_register(&da903x_backlight_driver); | ||
188 | } | ||
189 | module_init(da903x_backlight_init); | ||
190 | |||
191 | static void __exit da903x_backlight_exit(void) | ||
192 | { | ||
193 | platform_driver_unregister(&da903x_backlight_driver); | ||
194 | } | ||
195 | module_exit(da903x_backlight_exit); | ||
196 | |||
197 | MODULE_DESCRIPTION("Backlight Driver for Dialog Semiconductor DA9030/DA9034"); | ||
198 | MODULE_AUTHOR("Eric Miao <eric.miao@marvell.com>" | ||
199 | "Mike Rapoport <mike@compulab.co.il>"); | ||
200 | MODULE_LICENSE("GPL"); | ||
201 | MODULE_ALIAS("platform:da903x-backlight"); | ||
diff --git a/drivers/video/backlight/hp680_bl.c b/drivers/video/backlight/hp680_bl.c index 6fa0b9d5559..d4cfed0b26d 100644 --- a/drivers/video/backlight/hp680_bl.c +++ b/drivers/video/backlight/hp680_bl.c | |||
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/backlight.h> | 19 | #include <linux/backlight.h> |
20 | 20 | ||
21 | #include <cpu/dac.h> | 21 | #include <cpu/dac.h> |
22 | #include <asm/hp6xx.h> | 22 | #include <mach/hp6xx.h> |
23 | #include <asm/hd64461.h> | 23 | #include <asm/hd64461.h> |
24 | 24 | ||
25 | #define HP680_MAX_INTENSITY 255 | 25 | #define HP680_MAX_INTENSITY 255 |
diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c new file mode 100644 index 00000000000..a38fda1742d --- /dev/null +++ b/drivers/video/backlight/kb3886_bl.c | |||
@@ -0,0 +1,204 @@ | |||
1 | /* | ||
2 | * Backlight Driver for the KB3886 Backlight | ||
3 | * | ||
4 | * Copyright (c) 2007-2008 Claudio Nieder | ||
5 | * | ||
6 | * Based on corgi_bl.c by Richard Purdie and kb3886 driver by Robert Woerle | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #include <linux/module.h> | ||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/init.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/mutex.h> | ||
19 | #include <linux/fb.h> | ||
20 | #include <linux/backlight.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/dmi.h> | ||
23 | |||
24 | #define KB3886_PARENT 0x64 | ||
25 | #define KB3886_IO 0x60 | ||
26 | #define KB3886_ADC_DAC_PWM 0xC4 | ||
27 | #define KB3886_PWM0_WRITE 0x81 | ||
28 | #define KB3886_PWM0_READ 0x41 | ||
29 | |||
30 | static DEFINE_MUTEX(bl_mutex); | ||
31 | |||
32 | static void kb3886_bl_set_intensity(int intensity) | ||
33 | { | ||
34 | mutex_lock(&bl_mutex); | ||
35 | intensity = intensity&0xff; | ||
36 | outb(KB3886_ADC_DAC_PWM, KB3886_PARENT); | ||
37 | msleep(10); | ||
38 | outb(KB3886_PWM0_WRITE, KB3886_IO); | ||
39 | msleep(10); | ||
40 | outb(intensity, KB3886_IO); | ||
41 | mutex_unlock(&bl_mutex); | ||
42 | } | ||
43 | |||
44 | struct kb3886bl_machinfo { | ||
45 | int max_intensity; | ||
46 | int default_intensity; | ||
47 | int limit_mask; | ||
48 | void (*set_bl_intensity)(int intensity); | ||
49 | }; | ||
50 | |||
51 | static struct kb3886bl_machinfo kb3886_bl_machinfo = { | ||
52 | .max_intensity = 0xff, | ||
53 | .default_intensity = 0xa0, | ||
54 | .limit_mask = 0x7f, | ||
55 | .set_bl_intensity = kb3886_bl_set_intensity, | ||
56 | }; | ||
57 | |||
58 | static struct platform_device kb3886bl_device = { | ||
59 | .name = "kb3886-bl", | ||
60 | .dev = { | ||
61 | .platform_data = &kb3886_bl_machinfo, | ||
62 | }, | ||
63 | .id = -1, | ||
64 | }; | ||
65 | |||
66 | static struct platform_device *devices[] __initdata = { | ||
67 | &kb3886bl_device, | ||
68 | }; | ||
69 | |||
70 | /* | ||
71 | * Back to driver | ||
72 | */ | ||
73 | |||
74 | static int kb3886bl_intensity; | ||
75 | static struct backlight_device *kb3886_backlight_device; | ||
76 | static struct kb3886bl_machinfo *bl_machinfo; | ||
77 | |||
78 | static unsigned long kb3886bl_flags; | ||
79 | #define KB3886BL_SUSPENDED 0x01 | ||
80 | |||
81 | static struct dmi_system_id __initdata kb3886bl_device_table[] = { | ||
82 | { | ||
83 | .ident = "Sahara Touch-iT", | ||
84 | .matches = { | ||
85 | DMI_MATCH(DMI_SYS_VENDOR, "SDV"), | ||
86 | DMI_MATCH(DMI_PRODUCT_NAME, "iTouch T201"), | ||
87 | }, | ||
88 | }, | ||
89 | { } | ||
90 | }; | ||
91 | |||
92 | static int kb3886bl_send_intensity(struct backlight_device *bd) | ||
93 | { | ||
94 | int intensity = bd->props.brightness; | ||
95 | |||
96 | if (bd->props.power != FB_BLANK_UNBLANK) | ||
97 | intensity = 0; | ||
98 | if (bd->props.fb_blank != FB_BLANK_UNBLANK) | ||
99 | intensity = 0; | ||
100 | if (kb3886bl_flags & KB3886BL_SUSPENDED) | ||
101 | intensity = 0; | ||
102 | |||
103 | bl_machinfo->set_bl_intensity(intensity); | ||
104 | |||
105 | kb3886bl_intensity = intensity; | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | #ifdef CONFIG_PM | ||
110 | static int kb3886bl_suspend(struct platform_device *pdev, pm_message_t state) | ||
111 | { | ||
112 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
113 | |||
114 | kb3886bl_flags |= KB3886BL_SUSPENDED; | ||
115 | backlight_update_status(bd); | ||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | static int kb3886bl_resume(struct platform_device *pdev) | ||
120 | { | ||
121 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
122 | |||
123 | kb3886bl_flags &= ~KB3886BL_SUSPENDED; | ||
124 | backlight_update_status(bd); | ||
125 | return 0; | ||
126 | } | ||
127 | #else | ||
128 | #define kb3886bl_suspend NULL | ||
129 | #define kb3886bl_resume NULL | ||
130 | #endif | ||
131 | |||
132 | static int kb3886bl_get_intensity(struct backlight_device *bd) | ||
133 | { | ||
134 | return kb3886bl_intensity; | ||
135 | } | ||
136 | |||
137 | static struct backlight_ops kb3886bl_ops = { | ||
138 | .get_brightness = kb3886bl_get_intensity, | ||
139 | .update_status = kb3886bl_send_intensity, | ||
140 | }; | ||
141 | |||
142 | static int kb3886bl_probe(struct platform_device *pdev) | ||
143 | { | ||
144 | struct kb3886bl_machinfo *machinfo = pdev->dev.platform_data; | ||
145 | |||
146 | bl_machinfo = machinfo; | ||
147 | if (!machinfo->limit_mask) | ||
148 | machinfo->limit_mask = -1; | ||
149 | |||
150 | kb3886_backlight_device = backlight_device_register("kb3886-bl", | ||
151 | &pdev->dev, NULL, &kb3886bl_ops); | ||
152 | if (IS_ERR(kb3886_backlight_device)) | ||
153 | return PTR_ERR(kb3886_backlight_device); | ||
154 | |||
155 | platform_set_drvdata(pdev, kb3886_backlight_device); | ||
156 | |||
157 | kb3886_backlight_device->props.max_brightness = machinfo->max_intensity; | ||
158 | kb3886_backlight_device->props.power = FB_BLANK_UNBLANK; | ||
159 | kb3886_backlight_device->props.brightness = machinfo->default_intensity; | ||
160 | backlight_update_status(kb3886_backlight_device); | ||
161 | |||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | static int kb3886bl_remove(struct platform_device *pdev) | ||
166 | { | ||
167 | struct backlight_device *bd = platform_get_drvdata(pdev); | ||
168 | |||
169 | backlight_device_unregister(bd); | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static struct platform_driver kb3886bl_driver = { | ||
175 | .probe = kb3886bl_probe, | ||
176 | .remove = kb3886bl_remove, | ||
177 | .suspend = kb3886bl_suspend, | ||
178 | .resume = kb3886bl_resume, | ||
179 | .driver = { | ||
180 | .name = "kb3886-bl", | ||
181 | }, | ||
182 | }; | ||
183 | |||
184 | static int __init kb3886_init(void) | ||
185 | { | ||
186 | if (!dmi_check_system(kb3886bl_device_table)) | ||
187 | return -ENODEV; | ||
188 | |||
189 | platform_add_devices(devices, ARRAY_SIZE(devices)); | ||
190 | return platform_driver_register(&kb3886bl_driver); | ||
191 | } | ||
192 | |||
193 | static void __exit kb3886_exit(void) | ||
194 | { | ||
195 | platform_driver_unregister(&kb3886bl_driver); | ||
196 | } | ||
197 | |||
198 | module_init(kb3886_init); | ||
199 | module_exit(kb3886_exit); | ||
200 | |||
201 | MODULE_AUTHOR("Claudio Nieder <private@claudio.ch>"); | ||
202 | MODULE_DESCRIPTION("Tabletkiosk Sahara Touch-iT Backlight Driver"); | ||
203 | MODULE_LICENSE("GPL"); | ||
204 | MODULE_ALIAS("dmi:*:svnSDV:pniTouchT201:*"); | ||
diff --git a/drivers/video/backlight/tosa_bl.c b/drivers/video/backlight/tosa_bl.c new file mode 100644 index 00000000000..43edbada12d --- /dev/null +++ b/drivers/video/backlight/tosa_bl.c | |||
@@ -0,0 +1,198 @@ | |||
1 | /* | ||
2 | * LCD / Backlight control code for Sharp SL-6000x (tosa) | ||
3 | * | ||
4 | * Copyright (c) 2005 Dirk Opfer | ||
5 | * Copyright (c) 2007,2008 Dmitry Baryshkov | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/spi/spi.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/fb.h> | ||
20 | #include <linux/backlight.h> | ||
21 | |||
22 | #include <asm/mach/sharpsl_param.h> | ||
23 | |||
24 | #include <mach/tosa.h> | ||
25 | |||
26 | #define COMADJ_DEFAULT 97 | ||
27 | |||
28 | #define DAC_CH1 0 | ||
29 | #define DAC_CH2 1 | ||
30 | |||
31 | struct tosa_bl_data { | ||
32 | struct i2c_client *i2c; | ||
33 | struct backlight_device *bl; | ||
34 | |||
35 | int comadj; | ||
36 | }; | ||
37 | |||
38 | static void tosa_bl_set_backlight(struct tosa_bl_data *data, int brightness) | ||
39 | { | ||
40 | struct spi_device *spi = data->i2c->dev.platform_data; | ||
41 | |||
42 | i2c_smbus_write_byte_data(data->i2c, DAC_CH1, data->comadj); | ||
43 | |||
44 | /* SetBacklightDuty */ | ||
45 | i2c_smbus_write_byte_data(data->i2c, DAC_CH2, (u8)(brightness & 0xff)); | ||
46 | |||
47 | /* SetBacklightVR */ | ||
48 | gpio_set_value(TOSA_GPIO_BL_C20MA, brightness & 0x100); | ||
49 | |||
50 | tosa_bl_enable(spi, brightness); | ||
51 | } | ||
52 | |||
53 | static int tosa_bl_update_status(struct backlight_device *dev) | ||
54 | { | ||
55 | struct backlight_properties *props = &dev->props; | ||
56 | struct tosa_bl_data *data = dev_get_drvdata(&dev->dev); | ||
57 | int power = max(props->power, props->fb_blank); | ||
58 | int brightness = props->brightness; | ||
59 | |||
60 | if (power) | ||
61 | brightness = 0; | ||
62 | |||
63 | tosa_bl_set_backlight(data, brightness); | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | static int tosa_bl_get_brightness(struct backlight_device *dev) | ||
69 | { | ||
70 | struct backlight_properties *props = &dev->props; | ||
71 | |||
72 | return props->brightness; | ||
73 | } | ||
74 | |||
75 | static struct backlight_ops bl_ops = { | ||
76 | .get_brightness = tosa_bl_get_brightness, | ||
77 | .update_status = tosa_bl_update_status, | ||
78 | }; | ||
79 | |||
80 | static int __devinit tosa_bl_probe(struct i2c_client *client, | ||
81 | const struct i2c_device_id *id) | ||
82 | { | ||
83 | struct tosa_bl_data *data = kzalloc(sizeof(struct tosa_bl_data), GFP_KERNEL); | ||
84 | int ret = 0; | ||
85 | if (!data) | ||
86 | return -ENOMEM; | ||
87 | |||
88 | data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : sharpsl_param.comadj; | ||
89 | |||
90 | ret = gpio_request(TOSA_GPIO_BL_C20MA, "backlight"); | ||
91 | if (ret) { | ||
92 | dev_dbg(&data->bl->dev, "Unable to request gpio!\n"); | ||
93 | goto err_gpio_bl; | ||
94 | } | ||
95 | ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0); | ||
96 | if (ret) | ||
97 | goto err_gpio_dir; | ||
98 | |||
99 | i2c_set_clientdata(client, data); | ||
100 | data->i2c = client; | ||
101 | |||
102 | data->bl = backlight_device_register("tosa-bl", &client->dev, | ||
103 | data, &bl_ops); | ||
104 | if (IS_ERR(data->bl)) { | ||
105 | ret = PTR_ERR(data->bl); | ||
106 | goto err_reg; | ||
107 | } | ||
108 | |||
109 | data->bl->props.brightness = 69; | ||
110 | data->bl->props.max_brightness = 512 - 1; | ||
111 | data->bl->props.power = FB_BLANK_UNBLANK; | ||
112 | |||
113 | backlight_update_status(data->bl); | ||
114 | |||
115 | return 0; | ||
116 | |||
117 | err_reg: | ||
118 | data->bl = NULL; | ||
119 | i2c_set_clientdata(client, NULL); | ||
120 | err_gpio_dir: | ||
121 | gpio_free(TOSA_GPIO_BL_C20MA); | ||
122 | err_gpio_bl: | ||
123 | kfree(data); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | static int __devexit tosa_bl_remove(struct i2c_client *client) | ||
128 | { | ||
129 | struct tosa_bl_data *data = i2c_get_clientdata(client); | ||
130 | |||
131 | backlight_device_unregister(data->bl); | ||
132 | data->bl = NULL; | ||
133 | i2c_set_clientdata(client, NULL); | ||
134 | |||
135 | gpio_free(TOSA_GPIO_BL_C20MA); | ||
136 | |||
137 | kfree(data); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | #ifdef CONFIG_PM | ||
143 | static int tosa_bl_suspend(struct i2c_client *client, pm_message_t pm) | ||
144 | { | ||
145 | struct tosa_bl_data *data = i2c_get_clientdata(client); | ||
146 | |||
147 | tosa_bl_set_backlight(data, 0); | ||
148 | |||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static int tosa_bl_resume(struct i2c_client *client) | ||
153 | { | ||
154 | struct tosa_bl_data *data = i2c_get_clientdata(client); | ||
155 | |||
156 | backlight_update_status(data->bl); | ||
157 | return 0; | ||
158 | } | ||
159 | #else | ||
160 | #define tosa_bl_suspend NULL | ||
161 | #define tosa_bl_resume NULL | ||
162 | #endif | ||
163 | |||
164 | static const struct i2c_device_id tosa_bl_id[] = { | ||
165 | { "tosa-bl", 0 }, | ||
166 | { }, | ||
167 | }; | ||
168 | |||
169 | |||
170 | static struct i2c_driver tosa_bl_driver = { | ||
171 | .driver = { | ||
172 | .name = "tosa-bl", | ||
173 | .owner = THIS_MODULE, | ||
174 | }, | ||
175 | .probe = tosa_bl_probe, | ||
176 | .remove = __devexit_p(tosa_bl_remove), | ||
177 | .suspend = tosa_bl_suspend, | ||
178 | .resume = tosa_bl_resume, | ||
179 | .id_table = tosa_bl_id, | ||
180 | }; | ||
181 | |||
182 | static int __init tosa_bl_init(void) | ||
183 | { | ||
184 | return i2c_add_driver(&tosa_bl_driver); | ||
185 | } | ||
186 | |||
187 | static void __exit tosa_bl_exit(void) | ||
188 | { | ||
189 | i2c_del_driver(&tosa_bl_driver); | ||
190 | } | ||
191 | |||
192 | module_init(tosa_bl_init); | ||
193 | module_exit(tosa_bl_exit); | ||
194 | |||
195 | MODULE_AUTHOR("Dmitry Baryshkov"); | ||
196 | MODULE_LICENSE("GPL v2"); | ||
197 | MODULE_DESCRIPTION("LCD/Backlight control for Sharp SL-6000 PDA"); | ||
198 | |||
diff --git a/drivers/video/backlight/tosa_lcd.c b/drivers/video/backlight/tosa_lcd.c new file mode 100644 index 00000000000..57a26649f1a --- /dev/null +++ b/drivers/video/backlight/tosa_lcd.c | |||
@@ -0,0 +1,280 @@ | |||
1 | /* | ||
2 | * LCD / Backlight control code for Sharp SL-6000x (tosa) | ||
3 | * | ||
4 | * Copyright (c) 2005 Dirk Opfer | ||
5 | * Copyright (c) 2007,2008 Dmitry Baryshkov | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/spi/spi.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/delay.h> | ||
20 | #include <linux/lcd.h> | ||
21 | #include <linux/fb.h> | ||
22 | |||
23 | #include <asm/mach/sharpsl_param.h> | ||
24 | |||
25 | #include <mach/tosa.h> | ||
26 | |||
27 | #define POWER_IS_ON(pwr) ((pwr) <= FB_BLANK_NORMAL) | ||
28 | |||
29 | #define TG_REG0_VQV 0x0001 | ||
30 | #define TG_REG0_COLOR 0x0002 | ||
31 | #define TG_REG0_UD 0x0004 | ||
32 | #define TG_REG0_LR 0x0008 | ||
33 | |||
34 | #define DAC_BASE 0x4e | ||
35 | |||
36 | struct tosa_lcd_data { | ||
37 | struct spi_device *spi; | ||
38 | struct lcd_device *lcd; | ||
39 | struct i2c_client *i2c; | ||
40 | |||
41 | int lcd_power; | ||
42 | }; | ||
43 | |||
44 | static int tosa_tg_send(struct spi_device *spi, int adrs, uint8_t data) | ||
45 | { | ||
46 | u8 buf[1]; | ||
47 | struct spi_message msg; | ||
48 | struct spi_transfer xfer = { | ||
49 | .len = 1, | ||
50 | .cs_change = 1, | ||
51 | .tx_buf = buf, | ||
52 | }; | ||
53 | |||
54 | buf[0] = ((adrs & 0x07) << 5) | (data & 0x1f); | ||
55 | spi_message_init(&msg); | ||
56 | spi_message_add_tail(&xfer, &msg); | ||
57 | |||
58 | return spi_sync(spi, &msg); | ||
59 | } | ||
60 | |||
61 | int tosa_bl_enable(struct spi_device *spi, int enable) | ||
62 | { | ||
63 | /* bl_enable GP04=1 otherwise GP04=0*/ | ||
64 | return tosa_tg_send(spi, TG_GPODR2, enable? 0x01 : 0x00); | ||
65 | } | ||
66 | EXPORT_SYMBOL(tosa_bl_enable); | ||
67 | |||
68 | static void tosa_lcd_tg_init(struct tosa_lcd_data *data) | ||
69 | { | ||
70 | /* TG on */ | ||
71 | gpio_set_value(TOSA_GPIO_TG_ON, 0); | ||
72 | |||
73 | mdelay(60); | ||
74 | |||
75 | /* delayed 0clk TCTL signal for VGA */ | ||
76 | tosa_tg_send(data->spi, TG_TPOSCTL, 0x00); | ||
77 | /* GPOS0=powercontrol, GPOS1=GPIO, GPOS2=TCTL */ | ||
78 | tosa_tg_send(data->spi, TG_GPOSR, 0x02); | ||
79 | } | ||
80 | |||
81 | static void tosa_lcd_tg_on(struct tosa_lcd_data *data) | ||
82 | { | ||
83 | struct spi_device *spi = data->spi; | ||
84 | const int value = TG_REG0_COLOR | TG_REG0_UD | TG_REG0_LR; | ||
85 | tosa_tg_send(spi, TG_PNLCTL, value | TG_REG0_VQV); /* this depends on mode */ | ||
86 | |||
87 | /* TG LCD pannel power up */ | ||
88 | tosa_tg_send(spi, TG_PINICTL,0x4); | ||
89 | mdelay(50); | ||
90 | |||
91 | /* TG LCD GVSS */ | ||
92 | tosa_tg_send(spi, TG_PINICTL,0x0); | ||
93 | |||
94 | if (!data->i2c) { | ||
95 | /* after the pannel is powered up the first time, we can access the i2c bus */ | ||
96 | /* so probe for the DAC */ | ||
97 | struct i2c_adapter *adap = i2c_get_adapter(0); | ||
98 | struct i2c_board_info info = { | ||
99 | .type = "tosa-bl", | ||
100 | .addr = DAC_BASE, | ||
101 | .platform_data = data->spi, | ||
102 | }; | ||
103 | data->i2c = i2c_new_device(adap, &info); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | static void tosa_lcd_tg_off(struct tosa_lcd_data *data) | ||
108 | { | ||
109 | struct spi_device *spi = data->spi; | ||
110 | |||
111 | /* TG LCD VHSA off */ | ||
112 | tosa_tg_send(spi, TG_PINICTL,0x4); | ||
113 | mdelay(50); | ||
114 | |||
115 | /* TG LCD signal off */ | ||
116 | tosa_tg_send(spi, TG_PINICTL,0x6); | ||
117 | mdelay(50); | ||
118 | |||
119 | /* TG Off */ | ||
120 | gpio_set_value(TOSA_GPIO_TG_ON, 1); | ||
121 | mdelay(100); | ||
122 | } | ||
123 | |||
124 | int tosa_lcd_set_power(struct lcd_device *lcd, int power) | ||
125 | { | ||
126 | struct tosa_lcd_data *data = lcd_get_data(lcd); | ||
127 | |||
128 | if (POWER_IS_ON(power) && !POWER_IS_ON(data->lcd_power)) | ||
129 | tosa_lcd_tg_on(data); | ||
130 | |||
131 | if (!POWER_IS_ON(power) && POWER_IS_ON(data->lcd_power)) | ||
132 | tosa_lcd_tg_off(data); | ||
133 | |||
134 | data->lcd_power = power; | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static int tosa_lcd_get_power(struct lcd_device *lcd) | ||
139 | { | ||
140 | struct tosa_lcd_data *data = lcd_get_data(lcd); | ||
141 | |||
142 | return data->lcd_power; | ||
143 | } | ||
144 | |||
145 | static struct lcd_ops tosa_lcd_ops = { | ||
146 | .set_power = tosa_lcd_set_power, | ||
147 | .get_power = tosa_lcd_get_power, | ||
148 | }; | ||
149 | |||
150 | static int __devinit tosa_lcd_probe(struct spi_device *spi) | ||
151 | { | ||
152 | int ret; | ||
153 | struct tosa_lcd_data *data; | ||
154 | |||
155 | data = kzalloc(sizeof(struct tosa_lcd_data), GFP_KERNEL); | ||
156 | if (!data) | ||
157 | return -ENOMEM; | ||
158 | |||
159 | /* | ||
160 | * bits_per_word cannot be configured in platform data | ||
161 | */ | ||
162 | spi->bits_per_word = 8; | ||
163 | |||
164 | ret = spi_setup(spi); | ||
165 | if (ret < 0) | ||
166 | goto err_spi; | ||
167 | |||
168 | data->spi = spi; | ||
169 | dev_set_drvdata(&spi->dev, data); | ||
170 | |||
171 | ret = gpio_request(TOSA_GPIO_TG_ON, "tg #pwr"); | ||
172 | if (ret < 0) | ||
173 | goto err_gpio_tg; | ||
174 | |||
175 | mdelay(60); | ||
176 | |||
177 | ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0); | ||
178 | if (ret < 0) | ||
179 | goto err_gpio_dir; | ||
180 | |||
181 | mdelay(60); | ||
182 | tosa_lcd_tg_init(data); | ||
183 | |||
184 | tosa_lcd_tg_on(data); | ||
185 | |||
186 | data->lcd = lcd_device_register("tosa-lcd", &spi->dev, data, | ||
187 | &tosa_lcd_ops); | ||
188 | |||
189 | if (IS_ERR(data->lcd)) { | ||
190 | ret = PTR_ERR(data->lcd); | ||
191 | data->lcd = NULL; | ||
192 | goto err_register; | ||
193 | } | ||
194 | |||
195 | return 0; | ||
196 | |||
197 | err_register: | ||
198 | tosa_lcd_tg_off(data); | ||
199 | err_gpio_dir: | ||
200 | gpio_free(TOSA_GPIO_TG_ON); | ||
201 | err_gpio_tg: | ||
202 | dev_set_drvdata(&spi->dev, NULL); | ||
203 | err_spi: | ||
204 | kfree(data); | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | static int __devexit tosa_lcd_remove(struct spi_device *spi) | ||
209 | { | ||
210 | struct tosa_lcd_data *data = dev_get_drvdata(&spi->dev); | ||
211 | |||
212 | lcd_device_unregister(data->lcd); | ||
213 | |||
214 | if (data->i2c) | ||
215 | i2c_unregister_device(data->i2c); | ||
216 | |||
217 | tosa_lcd_tg_off(data); | ||
218 | |||
219 | gpio_free(TOSA_GPIO_TG_ON); | ||
220 | dev_set_drvdata(&spi->dev, NULL); | ||
221 | kfree(data); | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | #ifdef CONFIG_PM | ||
227 | static int tosa_lcd_suspend(struct spi_device *spi, pm_message_t state) | ||
228 | { | ||
229 | struct tosa_lcd_data *data = dev_get_drvdata(&spi->dev); | ||
230 | |||
231 | tosa_lcd_tg_off(data); | ||
232 | |||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static int tosa_lcd_resume(struct spi_device *spi) | ||
237 | { | ||
238 | struct tosa_lcd_data *data = dev_get_drvdata(&spi->dev); | ||
239 | |||
240 | tosa_lcd_tg_init(data); | ||
241 | if (POWER_IS_ON(data->lcd_power)) | ||
242 | tosa_lcd_tg_on(data); | ||
243 | else | ||
244 | tosa_lcd_tg_off(data); | ||
245 | |||
246 | return 0; | ||
247 | } | ||
248 | #else | ||
249 | #define tosa_lcd_suspend NULL | ||
250 | #define tosa_lcd_reume NULL | ||
251 | #endif | ||
252 | |||
253 | static struct spi_driver tosa_lcd_driver = { | ||
254 | .driver = { | ||
255 | .name = "tosa-lcd", | ||
256 | .owner = THIS_MODULE, | ||
257 | }, | ||
258 | .probe = tosa_lcd_probe, | ||
259 | .remove = __devexit_p(tosa_lcd_remove), | ||
260 | .suspend = tosa_lcd_suspend, | ||
261 | .resume = tosa_lcd_resume, | ||
262 | }; | ||
263 | |||
264 | static int __init tosa_lcd_init(void) | ||
265 | { | ||
266 | return spi_register_driver(&tosa_lcd_driver); | ||
267 | } | ||
268 | |||
269 | static void __exit tosa_lcd_exit(void) | ||
270 | { | ||
271 | spi_unregister_driver(&tosa_lcd_driver); | ||
272 | } | ||
273 | |||
274 | module_init(tosa_lcd_init); | ||
275 | module_exit(tosa_lcd_exit); | ||
276 | |||
277 | MODULE_AUTHOR("Dmitry Baryshkov"); | ||
278 | MODULE_LICENSE("GPL v2"); | ||
279 | MODULE_DESCRIPTION("LCD/Backlight control for Sharp SL-6000 PDA"); | ||
280 | |||
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c index 048b139f0e5..8a8760230bc 100644 --- a/drivers/video/cirrusfb.c +++ b/drivers/video/cirrusfb.c | |||
@@ -2049,7 +2049,7 @@ static void cirrusfb_pci_unmap(struct fb_info *info) | |||
2049 | #endif /* CONFIG_PCI */ | 2049 | #endif /* CONFIG_PCI */ |
2050 | 2050 | ||
2051 | #ifdef CONFIG_ZORRO | 2051 | #ifdef CONFIG_ZORRO |
2052 | static void __devexit cirrusfb_zorro_unmap(struct fb_info *info) | 2052 | static void cirrusfb_zorro_unmap(struct fb_info *info) |
2053 | { | 2053 | { |
2054 | struct cirrusfb_info *cinfo = info->par; | 2054 | struct cirrusfb_info *cinfo = info->par; |
2055 | struct zorro_dev *zdev = to_zorro_dev(info->device); | 2055 | struct zorro_dev *zdev = to_zorro_dev(info->device); |
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c index 64b3d30027b..b92947d62ad 100644 --- a/drivers/video/console/fbcon.c +++ b/drivers/video/console/fbcon.c | |||
@@ -2118,7 +2118,7 @@ static void fbcon_bmove_rec(struct vc_data *vc, struct display *p, int sy, int s | |||
2118 | height, width); | 2118 | height, width); |
2119 | } | 2119 | } |
2120 | 2120 | ||
2121 | static __inline__ void updatescrollmode(struct display *p, | 2121 | static void updatescrollmode(struct display *p, |
2122 | struct fb_info *info, | 2122 | struct fb_info *info, |
2123 | struct vc_data *vc) | 2123 | struct vc_data *vc) |
2124 | { | 2124 | { |
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 217c5118ae9..1d5ae39cb27 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1002,101 +1002,139 @@ fb_blank(struct fb_info *info, int blank) | |||
1002 | return ret; | 1002 | return ret; |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | static int | 1005 | static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, |
1006 | fb_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | 1006 | unsigned long arg) |
1007 | unsigned long arg) | ||
1008 | { | 1007 | { |
1009 | int fbidx = iminor(inode); | 1008 | struct fb_ops *fb; |
1010 | struct fb_info *info = registered_fb[fbidx]; | ||
1011 | struct fb_ops *fb = info->fbops; | ||
1012 | struct fb_var_screeninfo var; | 1009 | struct fb_var_screeninfo var; |
1013 | struct fb_fix_screeninfo fix; | 1010 | struct fb_fix_screeninfo fix; |
1014 | struct fb_con2fbmap con2fb; | 1011 | struct fb_con2fbmap con2fb; |
1015 | struct fb_cmap_user cmap; | 1012 | struct fb_cmap_user cmap; |
1016 | struct fb_event event; | 1013 | struct fb_event event; |
1017 | void __user *argp = (void __user *)arg; | 1014 | void __user *argp = (void __user *)arg; |
1018 | int i; | 1015 | long ret = 0; |
1019 | 1016 | ||
1017 | fb = info->fbops; | ||
1020 | if (!fb) | 1018 | if (!fb) |
1021 | return -ENODEV; | 1019 | return -ENODEV; |
1020 | |||
1022 | switch (cmd) { | 1021 | switch (cmd) { |
1023 | case FBIOGET_VSCREENINFO: | 1022 | case FBIOGET_VSCREENINFO: |
1024 | return copy_to_user(argp, &info->var, | 1023 | ret = copy_to_user(argp, &info->var, |
1025 | sizeof(var)) ? -EFAULT : 0; | 1024 | sizeof(var)) ? -EFAULT : 0; |
1025 | break; | ||
1026 | case FBIOPUT_VSCREENINFO: | 1026 | case FBIOPUT_VSCREENINFO: |
1027 | if (copy_from_user(&var, argp, sizeof(var))) | 1027 | if (copy_from_user(&var, argp, sizeof(var))) { |
1028 | return -EFAULT; | 1028 | ret = -EFAULT; |
1029 | break; | ||
1030 | } | ||
1029 | acquire_console_sem(); | 1031 | acquire_console_sem(); |
1030 | info->flags |= FBINFO_MISC_USEREVENT; | 1032 | info->flags |= FBINFO_MISC_USEREVENT; |
1031 | i = fb_set_var(info, &var); | 1033 | ret = fb_set_var(info, &var); |
1032 | info->flags &= ~FBINFO_MISC_USEREVENT; | 1034 | info->flags &= ~FBINFO_MISC_USEREVENT; |
1033 | release_console_sem(); | 1035 | release_console_sem(); |
1034 | if (i) return i; | 1036 | if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) |
1035 | if (copy_to_user(argp, &var, sizeof(var))) | 1037 | ret = -EFAULT; |
1036 | return -EFAULT; | 1038 | break; |
1037 | return 0; | ||
1038 | case FBIOGET_FSCREENINFO: | 1039 | case FBIOGET_FSCREENINFO: |
1039 | return copy_to_user(argp, &info->fix, | 1040 | ret = copy_to_user(argp, &info->fix, |
1040 | sizeof(fix)) ? -EFAULT : 0; | 1041 | sizeof(fix)) ? -EFAULT : 0; |
1042 | break; | ||
1041 | case FBIOPUTCMAP: | 1043 | case FBIOPUTCMAP: |
1042 | if (copy_from_user(&cmap, argp, sizeof(cmap))) | 1044 | if (copy_from_user(&cmap, argp, sizeof(cmap))) |
1043 | return -EFAULT; | 1045 | ret = -EFAULT; |
1044 | return (fb_set_user_cmap(&cmap, info)); | 1046 | else |
1047 | ret = fb_set_user_cmap(&cmap, info); | ||
1048 | break; | ||
1045 | case FBIOGETCMAP: | 1049 | case FBIOGETCMAP: |
1046 | if (copy_from_user(&cmap, argp, sizeof(cmap))) | 1050 | if (copy_from_user(&cmap, argp, sizeof(cmap))) |
1047 | return -EFAULT; | 1051 | ret = -EFAULT; |
1048 | return fb_cmap_to_user(&info->cmap, &cmap); | 1052 | else |
1053 | ret = fb_cmap_to_user(&info->cmap, &cmap); | ||
1054 | break; | ||
1049 | case FBIOPAN_DISPLAY: | 1055 | case FBIOPAN_DISPLAY: |
1050 | if (copy_from_user(&var, argp, sizeof(var))) | 1056 | if (copy_from_user(&var, argp, sizeof(var))) { |
1051 | return -EFAULT; | 1057 | ret = -EFAULT; |
1058 | break; | ||
1059 | } | ||
1052 | acquire_console_sem(); | 1060 | acquire_console_sem(); |
1053 | i = fb_pan_display(info, &var); | 1061 | ret = fb_pan_display(info, &var); |
1054 | release_console_sem(); | 1062 | release_console_sem(); |
1055 | if (i) | 1063 | if (ret == 0 && copy_to_user(argp, &var, sizeof(var))) |
1056 | return i; | 1064 | ret = -EFAULT; |
1057 | if (copy_to_user(argp, &var, sizeof(var))) | 1065 | break; |
1058 | return -EFAULT; | ||
1059 | return 0; | ||
1060 | case FBIO_CURSOR: | 1066 | case FBIO_CURSOR: |
1061 | return -EINVAL; | 1067 | ret = -EINVAL; |
1068 | break; | ||
1062 | case FBIOGET_CON2FBMAP: | 1069 | case FBIOGET_CON2FBMAP: |
1063 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) | 1070 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) |
1064 | return -EFAULT; | 1071 | ret = -EFAULT; |
1065 | if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) | 1072 | else if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) |
1066 | return -EINVAL; | 1073 | ret = -EINVAL; |
1067 | con2fb.framebuffer = -1; | 1074 | else { |
1068 | event.info = info; | 1075 | con2fb.framebuffer = -1; |
1069 | event.data = &con2fb; | 1076 | event.info = info; |
1070 | fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, &event); | 1077 | event.data = &con2fb; |
1071 | return copy_to_user(argp, &con2fb, | 1078 | fb_notifier_call_chain(FB_EVENT_GET_CONSOLE_MAP, |
1079 | &event); | ||
1080 | ret = copy_to_user(argp, &con2fb, | ||
1072 | sizeof(con2fb)) ? -EFAULT : 0; | 1081 | sizeof(con2fb)) ? -EFAULT : 0; |
1082 | } | ||
1083 | break; | ||
1073 | case FBIOPUT_CON2FBMAP: | 1084 | case FBIOPUT_CON2FBMAP: |
1074 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) | 1085 | if (copy_from_user(&con2fb, argp, sizeof(con2fb))) { |
1075 | return - EFAULT; | 1086 | ret = -EFAULT; |
1076 | if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) | 1087 | break; |
1077 | return -EINVAL; | 1088 | } |
1078 | if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) | 1089 | if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES) { |
1079 | return -EINVAL; | 1090 | ret = -EINVAL; |
1080 | if (!registered_fb[con2fb.framebuffer]) | 1091 | break; |
1081 | request_module("fb%d", con2fb.framebuffer); | 1092 | } |
1093 | if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX) { | ||
1094 | ret = -EINVAL; | ||
1095 | break; | ||
1096 | } | ||
1082 | if (!registered_fb[con2fb.framebuffer]) | 1097 | if (!registered_fb[con2fb.framebuffer]) |
1083 | return -EINVAL; | 1098 | request_module("fb%d", con2fb.framebuffer); |
1099 | if (!registered_fb[con2fb.framebuffer]) { | ||
1100 | ret = -EINVAL; | ||
1101 | break; | ||
1102 | } | ||
1084 | event.info = info; | 1103 | event.info = info; |
1085 | event.data = &con2fb; | 1104 | event.data = &con2fb; |
1086 | return fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, | 1105 | ret = fb_notifier_call_chain(FB_EVENT_SET_CONSOLE_MAP, |
1087 | &event); | 1106 | &event); |
1107 | break; | ||
1088 | case FBIOBLANK: | 1108 | case FBIOBLANK: |
1089 | acquire_console_sem(); | 1109 | acquire_console_sem(); |
1090 | info->flags |= FBINFO_MISC_USEREVENT; | 1110 | info->flags |= FBINFO_MISC_USEREVENT; |
1091 | i = fb_blank(info, arg); | 1111 | ret = fb_blank(info, arg); |
1092 | info->flags &= ~FBINFO_MISC_USEREVENT; | 1112 | info->flags &= ~FBINFO_MISC_USEREVENT; |
1093 | release_console_sem(); | 1113 | release_console_sem(); |
1094 | return i; | 1114 | break;; |
1095 | default: | 1115 | default: |
1096 | if (fb->fb_ioctl == NULL) | 1116 | if (fb->fb_ioctl == NULL) |
1097 | return -EINVAL; | 1117 | ret = -ENOTTY; |
1098 | return fb->fb_ioctl(info, cmd, arg); | 1118 | else |
1119 | ret = fb->fb_ioctl(info, cmd, arg); | ||
1099 | } | 1120 | } |
1121 | return ret; | ||
1122 | } | ||
1123 | |||
1124 | static long fb_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | ||
1125 | __acquires(&info->lock) | ||
1126 | __releases(&info->lock) | ||
1127 | { | ||
1128 | struct inode *inode = file->f_path.dentry->d_inode; | ||
1129 | int fbidx = iminor(inode); | ||
1130 | struct fb_info *info; | ||
1131 | long ret; | ||
1132 | |||
1133 | info = registered_fb[fbidx]; | ||
1134 | mutex_lock(&info->lock); | ||
1135 | ret = do_fb_ioctl(info, cmd, arg); | ||
1136 | mutex_unlock(&info->lock); | ||
1137 | return ret; | ||
1100 | } | 1138 | } |
1101 | 1139 | ||
1102 | #ifdef CONFIG_COMPAT | 1140 | #ifdef CONFIG_COMPAT |
@@ -1126,8 +1164,8 @@ struct fb_cmap32 { | |||
1126 | compat_caddr_t transp; | 1164 | compat_caddr_t transp; |
1127 | }; | 1165 | }; |
1128 | 1166 | ||
1129 | static int fb_getput_cmap(struct inode *inode, struct file *file, | 1167 | static int fb_getput_cmap(struct fb_info *info, unsigned int cmd, |
1130 | unsigned int cmd, unsigned long arg) | 1168 | unsigned long arg) |
1131 | { | 1169 | { |
1132 | struct fb_cmap_user __user *cmap; | 1170 | struct fb_cmap_user __user *cmap; |
1133 | struct fb_cmap32 __user *cmap32; | 1171 | struct fb_cmap32 __user *cmap32; |
@@ -1150,7 +1188,7 @@ static int fb_getput_cmap(struct inode *inode, struct file *file, | |||
1150 | put_user(compat_ptr(data), &cmap->transp)) | 1188 | put_user(compat_ptr(data), &cmap->transp)) |
1151 | return -EFAULT; | 1189 | return -EFAULT; |
1152 | 1190 | ||
1153 | err = fb_ioctl(inode, file, cmd, (unsigned long) cmap); | 1191 | err = do_fb_ioctl(info, cmd, (unsigned long) cmap); |
1154 | 1192 | ||
1155 | if (!err) { | 1193 | if (!err) { |
1156 | if (copy_in_user(&cmap32->start, | 1194 | if (copy_in_user(&cmap32->start, |
@@ -1192,8 +1230,8 @@ static int do_fscreeninfo_to_user(struct fb_fix_screeninfo *fix, | |||
1192 | return err; | 1230 | return err; |
1193 | } | 1231 | } |
1194 | 1232 | ||
1195 | static int fb_get_fscreeninfo(struct inode *inode, struct file *file, | 1233 | static int fb_get_fscreeninfo(struct fb_info *info, unsigned int cmd, |
1196 | unsigned int cmd, unsigned long arg) | 1234 | unsigned long arg) |
1197 | { | 1235 | { |
1198 | mm_segment_t old_fs; | 1236 | mm_segment_t old_fs; |
1199 | struct fb_fix_screeninfo fix; | 1237 | struct fb_fix_screeninfo fix; |
@@ -1204,7 +1242,7 @@ static int fb_get_fscreeninfo(struct inode *inode, struct file *file, | |||
1204 | 1242 | ||
1205 | old_fs = get_fs(); | 1243 | old_fs = get_fs(); |
1206 | set_fs(KERNEL_DS); | 1244 | set_fs(KERNEL_DS); |
1207 | err = fb_ioctl(inode, file, cmd, (unsigned long) &fix); | 1245 | err = do_fb_ioctl(info, cmd, (unsigned long) &fix); |
1208 | set_fs(old_fs); | 1246 | set_fs(old_fs); |
1209 | 1247 | ||
1210 | if (!err) | 1248 | if (!err) |
@@ -1213,8 +1251,10 @@ static int fb_get_fscreeninfo(struct inode *inode, struct file *file, | |||
1213 | return err; | 1251 | return err; |
1214 | } | 1252 | } |
1215 | 1253 | ||
1216 | static long | 1254 | static long fb_compat_ioctl(struct file *file, unsigned int cmd, |
1217 | fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 1255 | unsigned long arg) |
1256 | __acquires(&info->lock) | ||
1257 | __releases(&info->lock) | ||
1218 | { | 1258 | { |
1219 | struct inode *inode = file->f_path.dentry->d_inode; | 1259 | struct inode *inode = file->f_path.dentry->d_inode; |
1220 | int fbidx = iminor(inode); | 1260 | int fbidx = iminor(inode); |
@@ -1222,7 +1262,7 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1222 | struct fb_ops *fb = info->fbops; | 1262 | struct fb_ops *fb = info->fbops; |
1223 | long ret = -ENOIOCTLCMD; | 1263 | long ret = -ENOIOCTLCMD; |
1224 | 1264 | ||
1225 | lock_kernel(); | 1265 | mutex_lock(&info->lock); |
1226 | switch(cmd) { | 1266 | switch(cmd) { |
1227 | case FBIOGET_VSCREENINFO: | 1267 | case FBIOGET_VSCREENINFO: |
1228 | case FBIOPUT_VSCREENINFO: | 1268 | case FBIOPUT_VSCREENINFO: |
@@ -1231,16 +1271,16 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1231 | case FBIOPUT_CON2FBMAP: | 1271 | case FBIOPUT_CON2FBMAP: |
1232 | arg = (unsigned long) compat_ptr(arg); | 1272 | arg = (unsigned long) compat_ptr(arg); |
1233 | case FBIOBLANK: | 1273 | case FBIOBLANK: |
1234 | ret = fb_ioctl(inode, file, cmd, arg); | 1274 | ret = do_fb_ioctl(info, cmd, arg); |
1235 | break; | 1275 | break; |
1236 | 1276 | ||
1237 | case FBIOGET_FSCREENINFO: | 1277 | case FBIOGET_FSCREENINFO: |
1238 | ret = fb_get_fscreeninfo(inode, file, cmd, arg); | 1278 | ret = fb_get_fscreeninfo(info, cmd, arg); |
1239 | break; | 1279 | break; |
1240 | 1280 | ||
1241 | case FBIOGETCMAP: | 1281 | case FBIOGETCMAP: |
1242 | case FBIOPUTCMAP: | 1282 | case FBIOPUTCMAP: |
1243 | ret = fb_getput_cmap(inode, file, cmd, arg); | 1283 | ret = fb_getput_cmap(info, cmd, arg); |
1244 | break; | 1284 | break; |
1245 | 1285 | ||
1246 | default: | 1286 | default: |
@@ -1248,13 +1288,15 @@ fb_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1248 | ret = fb->fb_compat_ioctl(info, cmd, arg); | 1288 | ret = fb->fb_compat_ioctl(info, cmd, arg); |
1249 | break; | 1289 | break; |
1250 | } | 1290 | } |
1251 | unlock_kernel(); | 1291 | mutex_unlock(&info->lock); |
1252 | return ret; | 1292 | return ret; |
1253 | } | 1293 | } |
1254 | #endif | 1294 | #endif |
1255 | 1295 | ||
1256 | static int | 1296 | static int |
1257 | fb_mmap(struct file *file, struct vm_area_struct * vma) | 1297 | fb_mmap(struct file *file, struct vm_area_struct * vma) |
1298 | __acquires(&info->lock) | ||
1299 | __releases(&info->lock) | ||
1258 | { | 1300 | { |
1259 | int fbidx = iminor(file->f_path.dentry->d_inode); | 1301 | int fbidx = iminor(file->f_path.dentry->d_inode); |
1260 | struct fb_info *info = registered_fb[fbidx]; | 1302 | struct fb_info *info = registered_fb[fbidx]; |
@@ -1270,13 +1312,13 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) | |||
1270 | return -ENODEV; | 1312 | return -ENODEV; |
1271 | if (fb->fb_mmap) { | 1313 | if (fb->fb_mmap) { |
1272 | int res; | 1314 | int res; |
1273 | lock_kernel(); | 1315 | mutex_lock(&info->lock); |
1274 | res = fb->fb_mmap(info, vma); | 1316 | res = fb->fb_mmap(info, vma); |
1275 | unlock_kernel(); | 1317 | mutex_unlock(&info->lock); |
1276 | return res; | 1318 | return res; |
1277 | } | 1319 | } |
1278 | 1320 | ||
1279 | lock_kernel(); | 1321 | mutex_lock(&info->lock); |
1280 | 1322 | ||
1281 | /* frame buffer memory */ | 1323 | /* frame buffer memory */ |
1282 | start = info->fix.smem_start; | 1324 | start = info->fix.smem_start; |
@@ -1285,13 +1327,13 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) | |||
1285 | /* memory mapped io */ | 1327 | /* memory mapped io */ |
1286 | off -= len; | 1328 | off -= len; |
1287 | if (info->var.accel_flags) { | 1329 | if (info->var.accel_flags) { |
1288 | unlock_kernel(); | 1330 | mutex_unlock(&info->lock); |
1289 | return -EINVAL; | 1331 | return -EINVAL; |
1290 | } | 1332 | } |
1291 | start = info->fix.mmio_start; | 1333 | start = info->fix.mmio_start; |
1292 | len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len); | 1334 | len = PAGE_ALIGN((start & ~PAGE_MASK) + info->fix.mmio_len); |
1293 | } | 1335 | } |
1294 | unlock_kernel(); | 1336 | mutex_unlock(&info->lock); |
1295 | start &= PAGE_MASK; | 1337 | start &= PAGE_MASK; |
1296 | if ((vma->vm_end - vma->vm_start + off) > len) | 1338 | if ((vma->vm_end - vma->vm_start + off) > len) |
1297 | return -EINVAL; | 1339 | return -EINVAL; |
@@ -1308,6 +1350,8 @@ fb_mmap(struct file *file, struct vm_area_struct * vma) | |||
1308 | 1350 | ||
1309 | static int | 1351 | static int |
1310 | fb_open(struct inode *inode, struct file *file) | 1352 | fb_open(struct inode *inode, struct file *file) |
1353 | __acquires(&info->lock) | ||
1354 | __releases(&info->lock) | ||
1311 | { | 1355 | { |
1312 | int fbidx = iminor(inode); | 1356 | int fbidx = iminor(inode); |
1313 | struct fb_info *info; | 1357 | struct fb_info *info; |
@@ -1315,13 +1359,13 @@ fb_open(struct inode *inode, struct file *file) | |||
1315 | 1359 | ||
1316 | if (fbidx >= FB_MAX) | 1360 | if (fbidx >= FB_MAX) |
1317 | return -ENODEV; | 1361 | return -ENODEV; |
1318 | lock_kernel(); | 1362 | info = registered_fb[fbidx]; |
1319 | if (!(info = registered_fb[fbidx])) | 1363 | if (!info) |
1320 | request_module("fb%d", fbidx); | 1364 | request_module("fb%d", fbidx); |
1321 | if (!(info = registered_fb[fbidx])) { | 1365 | info = registered_fb[fbidx]; |
1322 | res = -ENODEV; | 1366 | if (!info) |
1323 | goto out; | 1367 | return -ENODEV; |
1324 | } | 1368 | mutex_lock(&info->lock); |
1325 | if (!try_module_get(info->fbops->owner)) { | 1369 | if (!try_module_get(info->fbops->owner)) { |
1326 | res = -ENODEV; | 1370 | res = -ENODEV; |
1327 | goto out; | 1371 | goto out; |
@@ -1337,20 +1381,22 @@ fb_open(struct inode *inode, struct file *file) | |||
1337 | fb_deferred_io_open(info, inode, file); | 1381 | fb_deferred_io_open(info, inode, file); |
1338 | #endif | 1382 | #endif |
1339 | out: | 1383 | out: |
1340 | unlock_kernel(); | 1384 | mutex_unlock(&info->lock); |
1341 | return res; | 1385 | return res; |
1342 | } | 1386 | } |
1343 | 1387 | ||
1344 | static int | 1388 | static int |
1345 | fb_release(struct inode *inode, struct file *file) | 1389 | fb_release(struct inode *inode, struct file *file) |
1390 | __acquires(&info->lock) | ||
1391 | __releases(&info->lock) | ||
1346 | { | 1392 | { |
1347 | struct fb_info * const info = file->private_data; | 1393 | struct fb_info * const info = file->private_data; |
1348 | 1394 | ||
1349 | lock_kernel(); | 1395 | mutex_lock(&info->lock); |
1350 | if (info->fbops->fb_release) | 1396 | if (info->fbops->fb_release) |
1351 | info->fbops->fb_release(info,1); | 1397 | info->fbops->fb_release(info,1); |
1352 | module_put(info->fbops->owner); | 1398 | module_put(info->fbops->owner); |
1353 | unlock_kernel(); | 1399 | mutex_unlock(&info->lock); |
1354 | return 0; | 1400 | return 0; |
1355 | } | 1401 | } |
1356 | 1402 | ||
@@ -1358,7 +1404,7 @@ static const struct file_operations fb_fops = { | |||
1358 | .owner = THIS_MODULE, | 1404 | .owner = THIS_MODULE, |
1359 | .read = fb_read, | 1405 | .read = fb_read, |
1360 | .write = fb_write, | 1406 | .write = fb_write, |
1361 | .ioctl = fb_ioctl, | 1407 | .unlocked_ioctl = fb_ioctl, |
1362 | #ifdef CONFIG_COMPAT | 1408 | #ifdef CONFIG_COMPAT |
1363 | .compat_ioctl = fb_compat_ioctl, | 1409 | .compat_ioctl = fb_compat_ioctl, |
1364 | #endif | 1410 | #endif |
@@ -1429,6 +1475,7 @@ register_framebuffer(struct fb_info *fb_info) | |||
1429 | if (!registered_fb[i]) | 1475 | if (!registered_fb[i]) |
1430 | break; | 1476 | break; |
1431 | fb_info->node = i; | 1477 | fb_info->node = i; |
1478 | mutex_init(&fb_info->lock); | ||
1432 | 1479 | ||
1433 | fb_info->dev = device_create(fb_class, fb_info->device, | 1480 | fb_info->dev = device_create(fb_class, fb_info->device, |
1434 | MKDEV(FB_MAJOR, i), NULL, "fb%d", i); | 1481 | MKDEV(FB_MAJOR, i), NULL, "fb%d", i); |
diff --git a/drivers/video/imacfb.c b/drivers/video/imacfb.c deleted file mode 100644 index e69de29bb2d..00000000000 --- a/drivers/video/imacfb.c +++ /dev/null | |||
diff --git a/drivers/video/mb862xx/Makefile b/drivers/video/mb862xx/Makefile new file mode 100644 index 00000000000..07664814bb1 --- /dev/null +++ b/drivers/video/mb862xx/Makefile | |||
@@ -0,0 +1,5 @@ | |||
1 | # | ||
2 | # Makefile for the MB862xx framebuffer driver | ||
3 | # | ||
4 | |||
5 | obj-$(CONFIG_FB_MB862XX) := mb862xxfb.o | ||
diff --git a/drivers/video/mb862xx/mb862xx_reg.h b/drivers/video/mb862xx/mb862xx_reg.h new file mode 100644 index 00000000000..2ba65e11850 --- /dev/null +++ b/drivers/video/mb862xx/mb862xx_reg.h | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * Fujitsu MB862xx Graphics Controller Registers/Bits | ||
3 | */ | ||
4 | |||
5 | #ifndef _MB862XX_REG_H | ||
6 | #define _MB862XX_REG_H | ||
7 | |||
8 | #ifdef MB862XX_MMIO_BOTTOM | ||
9 | #define MB862XX_MMIO_BASE 0x03fc0000 | ||
10 | #else | ||
11 | #define MB862XX_MMIO_BASE 0x01fc0000 | ||
12 | #endif | ||
13 | #define MB862XX_I2C_BASE 0x0000c000 | ||
14 | #define MB862XX_DISP_BASE 0x00010000 | ||
15 | #define MB862XX_CAP_BASE 0x00018000 | ||
16 | #define MB862XX_DRAW_BASE 0x00030000 | ||
17 | #define MB862XX_GEO_BASE 0x00038000 | ||
18 | #define MB862XX_PIO_BASE 0x00038000 | ||
19 | #define MB862XX_MMIO_SIZE 0x40000 | ||
20 | |||
21 | /* Host interface/pio registers */ | ||
22 | #define GC_IST 0x00000020 | ||
23 | #define GC_IMASK 0x00000024 | ||
24 | #define GC_SRST 0x0000002c | ||
25 | #define GC_CCF 0x00000038 | ||
26 | #define GC_CID 0x000000f0 | ||
27 | #define GC_REVISION 0x00000084 | ||
28 | |||
29 | #define GC_CCF_CGE_100 0x00000000 | ||
30 | #define GC_CCF_CGE_133 0x00040000 | ||
31 | #define GC_CCF_CGE_166 0x00080000 | ||
32 | #define GC_CCF_COT_100 0x00000000 | ||
33 | #define GC_CCF_COT_133 0x00010000 | ||
34 | #define GC_CID_CNAME_MSK 0x0000ff00 | ||
35 | #define GC_CID_VERSION_MSK 0x000000ff | ||
36 | |||
37 | /* define enabled interrupts hereby */ | ||
38 | #define GC_INT_EN 0x00000000 | ||
39 | |||
40 | /* Memory interface mode register */ | ||
41 | #define GC_MMR 0x0000fffc | ||
42 | |||
43 | /* Display Controller registers */ | ||
44 | #define GC_DCM0 0x00000000 | ||
45 | #define GC_HTP 0x00000004 | ||
46 | #define GC_HDB_HDP 0x00000008 | ||
47 | #define GC_VSW_HSW_HSP 0x0000000c | ||
48 | #define GC_VTR 0x00000010 | ||
49 | #define GC_VDP_VSP 0x00000014 | ||
50 | #define GC_WY_WX 0x00000018 | ||
51 | #define GC_WH_WW 0x0000001c | ||
52 | #define GC_L0M 0x00000020 | ||
53 | #define GC_L0OA0 0x00000024 | ||
54 | #define GC_L0DA0 0x00000028 | ||
55 | #define GC_L0DY_L0DX 0x0000002c | ||
56 | #define GC_DCM1 0x00000100 | ||
57 | #define GC_L0EM 0x00000110 | ||
58 | #define GC_L0WY_L0WX 0x00000114 | ||
59 | #define GC_L0WH_L0WW 0x00000118 | ||
60 | #define GC_DCM2 0x00000104 | ||
61 | #define GC_DCM3 0x00000108 | ||
62 | #define GC_CPM_CUTC 0x000000a0 | ||
63 | #define GC_CUOA0 0x000000a4 | ||
64 | #define GC_CUY0_CUX0 0x000000a8 | ||
65 | #define GC_CUOA1 0x000000ac | ||
66 | #define GC_CUY1_CUX1 0x000000b0 | ||
67 | #define GC_L0PAL0 0x00000400 | ||
68 | |||
69 | #define GC_CPM_CEN0 0x00100000 | ||
70 | #define GC_CPM_CEN1 0x00200000 | ||
71 | |||
72 | #define GC_DCM01_ESY 0x00000004 | ||
73 | #define GC_DCM01_SC 0x00003f00 | ||
74 | #define GC_DCM01_RESV 0x00004000 | ||
75 | #define GC_DCM01_CKS 0x00008000 | ||
76 | #define GC_DCM01_L0E 0x00010000 | ||
77 | #define GC_DCM01_DEN 0x80000000 | ||
78 | #define GC_L0M_L0C_8 0x00000000 | ||
79 | #define GC_L0M_L0C_16 0x80000000 | ||
80 | #define GC_L0EM_L0EC_24 0x40000000 | ||
81 | #define GC_L0M_L0W_UNIT 64 | ||
82 | |||
83 | #define GC_DISP_REFCLK_400 400 | ||
84 | |||
85 | /* Carmine specific */ | ||
86 | #define MB86297_DRAW_BASE 0x00020000 | ||
87 | #define MB86297_DISP0_BASE 0x00100000 | ||
88 | #define MB86297_DISP1_BASE 0x00140000 | ||
89 | #define MB86297_WRBACK_BASE 0x00180000 | ||
90 | #define MB86297_CAP0_BASE 0x00200000 | ||
91 | #define MB86297_CAP1_BASE 0x00280000 | ||
92 | #define MB86297_DRAMCTRL_BASE 0x00300000 | ||
93 | #define MB86297_CTRL_BASE 0x00400000 | ||
94 | #define MB86297_I2C_BASE 0x00500000 | ||
95 | |||
96 | #define GC_CTRL_STATUS 0x00000000 | ||
97 | #define GC_CTRL_INT_MASK 0x00000004 | ||
98 | #define GC_CTRL_CLK_ENABLE 0x0000000c | ||
99 | #define GC_CTRL_SOFT_RST 0x00000010 | ||
100 | |||
101 | #define GC_CTRL_CLK_EN_DRAM 0x00000001 | ||
102 | #define GC_CTRL_CLK_EN_2D3D 0x00000002 | ||
103 | #define GC_CTRL_CLK_EN_DISP0 0x00000020 | ||
104 | #define GC_CTRL_CLK_EN_DISP1 0x00000040 | ||
105 | |||
106 | #define GC_2D3D_REV 0x000004b4 | ||
107 | #define GC_RE_REVISION 0x24240200 | ||
108 | |||
109 | /* define enabled interrupts hereby */ | ||
110 | #define GC_CARMINE_INT_EN 0x00000004 | ||
111 | |||
112 | /* DRAM controller */ | ||
113 | #define GC_DCTL_MODE_ADD 0x00000000 | ||
114 | #define GC_DCTL_SETTIME1_EMODE 0x00000004 | ||
115 | #define GC_DCTL_REFRESH_SETTIME2 0x00000008 | ||
116 | #define GC_DCTL_RSV0_STATES 0x0000000C | ||
117 | #define GC_DCTL_RSV2_RSV1 0x00000010 | ||
118 | #define GC_DCTL_DDRIF2_DDRIF1 0x00000014 | ||
119 | #define GC_DCTL_IOCONT1_IOCONT0 0x00000024 | ||
120 | |||
121 | #define GC_DCTL_STATES_MSK 0x0000000f | ||
122 | #define GC_DCTL_INIT_WAIT_CNT 3000 | ||
123 | #define GC_DCTL_INIT_WAIT_INTERVAL 1 | ||
124 | |||
125 | /* DRAM ctrl values for Carmine PCI Eval. board */ | ||
126 | #define GC_EVB_DCTL_MODE_ADD 0x012105c3 | ||
127 | #define GC_EVB_DCTL_MODE_ADD_AFT_RST 0x002105c3 | ||
128 | #define GC_EVB_DCTL_SETTIME1_EMODE 0x47498000 | ||
129 | #define GC_EVB_DCTL_REFRESH_SETTIME2 0x00422a22 | ||
130 | #define GC_EVB_DCTL_RSV0_STATES 0x00200003 | ||
131 | #define GC_EVB_DCTL_RSV0_STATES_AFT_RST 0x00200002 | ||
132 | #define GC_EVB_DCTL_RSV2_RSV1 0x0000000f | ||
133 | #define GC_EVB_DCTL_DDRIF2_DDRIF1 0x00556646 | ||
134 | #define GC_EVB_DCTL_IOCONT1_IOCONT0 0x05550555 | ||
135 | |||
136 | #define GC_DISP_REFCLK_533 533 | ||
137 | |||
138 | #endif | ||
diff --git a/drivers/video/mb862xx/mb862xxfb.c b/drivers/video/mb862xx/mb862xxfb.c new file mode 100644 index 00000000000..38718d95fbb --- /dev/null +++ b/drivers/video/mb862xx/mb862xxfb.c | |||
@@ -0,0 +1,1061 @@ | |||
1 | /* | ||
2 | * drivers/mb862xx/mb862xxfb.c | ||
3 | * | ||
4 | * Fujitsu Carmine/Coral-P(A)/Lime framebuffer driver | ||
5 | * | ||
6 | * (C) 2008 Anatolij Gustschin <agust@denx.de> | ||
7 | * DENX Software Engineering | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | * | ||
13 | */ | ||
14 | |||
15 | #undef DEBUG | ||
16 | |||
17 | #include <linux/fb.h> | ||
18 | #include <linux/delay.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/pci.h> | ||
22 | #if defined(CONFIG_PPC_OF) | ||
23 | #include <linux/of_platform.h> | ||
24 | #endif | ||
25 | #include "mb862xxfb.h" | ||
26 | #include "mb862xx_reg.h" | ||
27 | |||
28 | #define NR_PALETTE 256 | ||
29 | #define MB862XX_MEM_SIZE 0x1000000 | ||
30 | #define CORALP_MEM_SIZE 0x4000000 | ||
31 | #define CARMINE_MEM_SIZE 0x8000000 | ||
32 | #define DRV_NAME "mb862xxfb" | ||
33 | |||
34 | #if defined(CONFIG_LWMON5) | ||
35 | static struct mb862xx_gc_mode lwmon5_gc_mode = { | ||
36 | /* Mode for Sharp LQ104V1DG61 TFT LCD Panel */ | ||
37 | { "640x480", 60, 640, 480, 40000, 48, 16, 32, 11, 96, 2, 0, 0, 0 }, | ||
38 | /* 16 bits/pixel, 32MB, 100MHz, SDRAM memory mode value */ | ||
39 | 16, 0x2000000, GC_CCF_COT_100, 0x414fb7f2 | ||
40 | }; | ||
41 | #endif | ||
42 | |||
43 | #if defined(CONFIG_SOCRATES) | ||
44 | static struct mb862xx_gc_mode socrates_gc_mode = { | ||
45 | /* Mode for Prime View PM070WL4 TFT LCD Panel */ | ||
46 | { "800x480", 45, 800, 480, 40000, 86, 42, 33, 10, 128, 2, 0, 0, 0 }, | ||
47 | /* 16 bits/pixel, 16MB, 133MHz, SDRAM memory mode value */ | ||
48 | 16, 0x1000000, GC_CCF_COT_133, 0x4157ba63 | ||
49 | }; | ||
50 | #endif | ||
51 | |||
52 | /* Helpers */ | ||
53 | static inline int h_total(struct fb_var_screeninfo *var) | ||
54 | { | ||
55 | return var->xres + var->left_margin + | ||
56 | var->right_margin + var->hsync_len; | ||
57 | } | ||
58 | |||
59 | static inline int v_total(struct fb_var_screeninfo *var) | ||
60 | { | ||
61 | return var->yres + var->upper_margin + | ||
62 | var->lower_margin + var->vsync_len; | ||
63 | } | ||
64 | |||
65 | static inline int hsp(struct fb_var_screeninfo *var) | ||
66 | { | ||
67 | return var->xres + var->right_margin - 1; | ||
68 | } | ||
69 | |||
70 | static inline int vsp(struct fb_var_screeninfo *var) | ||
71 | { | ||
72 | return var->yres + var->lower_margin - 1; | ||
73 | } | ||
74 | |||
75 | static inline int d_pitch(struct fb_var_screeninfo *var) | ||
76 | { | ||
77 | return var->xres * var->bits_per_pixel / 8; | ||
78 | } | ||
79 | |||
80 | static inline unsigned int chan_to_field(unsigned int chan, | ||
81 | struct fb_bitfield *bf) | ||
82 | { | ||
83 | chan &= 0xffff; | ||
84 | chan >>= 16 - bf->length; | ||
85 | return chan << bf->offset; | ||
86 | } | ||
87 | |||
88 | static int mb862xxfb_setcolreg(unsigned regno, | ||
89 | unsigned red, unsigned green, unsigned blue, | ||
90 | unsigned transp, struct fb_info *info) | ||
91 | { | ||
92 | struct mb862xxfb_par *par = info->par; | ||
93 | unsigned int val; | ||
94 | |||
95 | switch (info->fix.visual) { | ||
96 | case FB_VISUAL_TRUECOLOR: | ||
97 | if (regno < 16) { | ||
98 | val = chan_to_field(red, &info->var.red); | ||
99 | val |= chan_to_field(green, &info->var.green); | ||
100 | val |= chan_to_field(blue, &info->var.blue); | ||
101 | par->pseudo_palette[regno] = val; | ||
102 | } | ||
103 | break; | ||
104 | case FB_VISUAL_PSEUDOCOLOR: | ||
105 | if (regno < 256) { | ||
106 | val = (red >> 8) << 16; | ||
107 | val |= (green >> 8) << 8; | ||
108 | val |= blue >> 8; | ||
109 | outreg(disp, GC_L0PAL0 + (regno * 4), val); | ||
110 | } | ||
111 | break; | ||
112 | default: | ||
113 | return 1; /* unsupported type */ | ||
114 | } | ||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | static int mb862xxfb_check_var(struct fb_var_screeninfo *var, | ||
119 | struct fb_info *fbi) | ||
120 | { | ||
121 | unsigned long tmp; | ||
122 | |||
123 | if (fbi->dev) | ||
124 | dev_dbg(fbi->dev, "%s\n", __func__); | ||
125 | |||
126 | /* check if these values fit into the registers */ | ||
127 | if (var->hsync_len > 255 || var->vsync_len > 255) | ||
128 | return -EINVAL; | ||
129 | |||
130 | if ((var->xres + var->right_margin) >= 4096) | ||
131 | return -EINVAL; | ||
132 | |||
133 | if ((var->yres + var->lower_margin) > 4096) | ||
134 | return -EINVAL; | ||
135 | |||
136 | if (h_total(var) > 4096 || v_total(var) > 4096) | ||
137 | return -EINVAL; | ||
138 | |||
139 | if (var->xres_virtual > 4096 || var->yres_virtual > 4096) | ||
140 | return -EINVAL; | ||
141 | |||
142 | if (var->bits_per_pixel <= 8) | ||
143 | var->bits_per_pixel = 8; | ||
144 | else if (var->bits_per_pixel <= 16) | ||
145 | var->bits_per_pixel = 16; | ||
146 | else if (var->bits_per_pixel <= 32) | ||
147 | var->bits_per_pixel = 32; | ||
148 | |||
149 | /* | ||
150 | * can cope with 8,16 or 24/32bpp if resulting | ||
151 | * pitch is divisible by 64 without remainder | ||
152 | */ | ||
153 | if (d_pitch(&fbi->var) % GC_L0M_L0W_UNIT) { | ||
154 | int r; | ||
155 | |||
156 | var->bits_per_pixel = 0; | ||
157 | do { | ||
158 | var->bits_per_pixel += 8; | ||
159 | r = d_pitch(&fbi->var) % GC_L0M_L0W_UNIT; | ||
160 | } while (r && var->bits_per_pixel <= 32); | ||
161 | |||
162 | if (d_pitch(&fbi->var) % GC_L0M_L0W_UNIT) | ||
163 | return -EINVAL; | ||
164 | } | ||
165 | |||
166 | /* line length is going to be 128 bit aligned */ | ||
167 | tmp = (var->xres * var->bits_per_pixel) / 8; | ||
168 | if ((tmp & 15) != 0) | ||
169 | return -EINVAL; | ||
170 | |||
171 | /* set r/g/b positions and validate bpp */ | ||
172 | switch (var->bits_per_pixel) { | ||
173 | case 8: | ||
174 | var->red.length = var->bits_per_pixel; | ||
175 | var->green.length = var->bits_per_pixel; | ||
176 | var->blue.length = var->bits_per_pixel; | ||
177 | var->red.offset = 0; | ||
178 | var->green.offset = 0; | ||
179 | var->blue.offset = 0; | ||
180 | var->transp.length = 0; | ||
181 | break; | ||
182 | case 16: | ||
183 | var->red.length = 5; | ||
184 | var->green.length = 5; | ||
185 | var->blue.length = 5; | ||
186 | var->red.offset = 10; | ||
187 | var->green.offset = 5; | ||
188 | var->blue.offset = 0; | ||
189 | var->transp.length = 0; | ||
190 | break; | ||
191 | case 24: | ||
192 | case 32: | ||
193 | var->transp.length = 8; | ||
194 | var->red.length = 8; | ||
195 | var->green.length = 8; | ||
196 | var->blue.length = 8; | ||
197 | var->transp.offset = 24; | ||
198 | var->red.offset = 16; | ||
199 | var->green.offset = 8; | ||
200 | var->blue.offset = 0; | ||
201 | break; | ||
202 | default: | ||
203 | return -EINVAL; | ||
204 | } | ||
205 | return 0; | ||
206 | } | ||
207 | |||
208 | /* | ||
209 | * set display parameters | ||
210 | */ | ||
211 | static int mb862xxfb_set_par(struct fb_info *fbi) | ||
212 | { | ||
213 | struct mb862xxfb_par *par = fbi->par; | ||
214 | unsigned long reg, sc; | ||
215 | |||
216 | dev_dbg(par->dev, "%s\n", __func__); | ||
217 | |||
218 | if (par->pre_init) | ||
219 | return 0; | ||
220 | |||
221 | /* disp off */ | ||
222 | reg = inreg(disp, GC_DCM1); | ||
223 | reg &= ~GC_DCM01_DEN; | ||
224 | outreg(disp, GC_DCM1, reg); | ||
225 | |||
226 | /* set display reference clock div. */ | ||
227 | sc = par->refclk / (1000000 / fbi->var.pixclock) - 1; | ||
228 | reg = inreg(disp, GC_DCM1); | ||
229 | reg &= ~(GC_DCM01_CKS | GC_DCM01_RESV | GC_DCM01_SC); | ||
230 | reg |= sc << 8; | ||
231 | outreg(disp, GC_DCM1, reg); | ||
232 | dev_dbg(par->dev, "SC 0x%lx\n", sc); | ||
233 | |||
234 | /* disp dimension, format */ | ||
235 | reg = pack(d_pitch(&fbi->var) / GC_L0M_L0W_UNIT, | ||
236 | (fbi->var.yres - 1)); | ||
237 | if (fbi->var.bits_per_pixel == 16) | ||
238 | reg |= GC_L0M_L0C_16; | ||
239 | outreg(disp, GC_L0M, reg); | ||
240 | |||
241 | if (fbi->var.bits_per_pixel == 32) { | ||
242 | reg = inreg(disp, GC_L0EM); | ||
243 | outreg(disp, GC_L0EM, reg | GC_L0EM_L0EC_24); | ||
244 | } | ||
245 | outreg(disp, GC_WY_WX, 0); | ||
246 | reg = pack(fbi->var.yres - 1, fbi->var.xres); | ||
247 | outreg(disp, GC_WH_WW, reg); | ||
248 | outreg(disp, GC_L0OA0, 0); | ||
249 | outreg(disp, GC_L0DA0, 0); | ||
250 | outreg(disp, GC_L0DY_L0DX, 0); | ||
251 | outreg(disp, GC_L0WY_L0WX, 0); | ||
252 | outreg(disp, GC_L0WH_L0WW, reg); | ||
253 | |||
254 | /* both HW-cursors off */ | ||
255 | reg = inreg(disp, GC_CPM_CUTC); | ||
256 | reg &= ~(GC_CPM_CEN0 | GC_CPM_CEN1); | ||
257 | outreg(disp, GC_CPM_CUTC, reg); | ||
258 | |||
259 | /* timings */ | ||
260 | reg = pack(fbi->var.xres - 1, fbi->var.xres - 1); | ||
261 | outreg(disp, GC_HDB_HDP, reg); | ||
262 | reg = pack((fbi->var.yres - 1), vsp(&fbi->var)); | ||
263 | outreg(disp, GC_VDP_VSP, reg); | ||
264 | reg = ((fbi->var.vsync_len - 1) << 24) | | ||
265 | pack((fbi->var.hsync_len - 1), hsp(&fbi->var)); | ||
266 | outreg(disp, GC_VSW_HSW_HSP, reg); | ||
267 | outreg(disp, GC_HTP, pack(h_total(&fbi->var) - 1, 0)); | ||
268 | outreg(disp, GC_VTR, pack(v_total(&fbi->var) - 1, 0)); | ||
269 | |||
270 | /* display on */ | ||
271 | reg = inreg(disp, GC_DCM1); | ||
272 | reg |= GC_DCM01_DEN | GC_DCM01_L0E; | ||
273 | reg &= ~GC_DCM01_ESY; | ||
274 | outreg(disp, GC_DCM1, reg); | ||
275 | return 0; | ||
276 | } | ||
277 | |||
278 | static int mb862xxfb_pan(struct fb_var_screeninfo *var, | ||
279 | struct fb_info *info) | ||
280 | { | ||
281 | struct mb862xxfb_par *par = info->par; | ||
282 | unsigned long reg; | ||
283 | |||
284 | reg = pack(var->yoffset, var->xoffset); | ||
285 | outreg(disp, GC_L0WY_L0WX, reg); | ||
286 | |||
287 | reg = pack(var->yres_virtual, var->xres_virtual); | ||
288 | outreg(disp, GC_L0WH_L0WW, reg); | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | static int mb862xxfb_blank(int mode, struct fb_info *fbi) | ||
293 | { | ||
294 | struct mb862xxfb_par *par = fbi->par; | ||
295 | unsigned long reg; | ||
296 | |||
297 | dev_dbg(fbi->dev, "blank mode=%d\n", mode); | ||
298 | |||
299 | switch (mode) { | ||
300 | case FB_BLANK_POWERDOWN: | ||
301 | reg = inreg(disp, GC_DCM1); | ||
302 | reg &= ~GC_DCM01_DEN; | ||
303 | outreg(disp, GC_DCM1, reg); | ||
304 | break; | ||
305 | case FB_BLANK_UNBLANK: | ||
306 | reg = inreg(disp, GC_DCM1); | ||
307 | reg |= GC_DCM01_DEN; | ||
308 | outreg(disp, GC_DCM1, reg); | ||
309 | break; | ||
310 | case FB_BLANK_NORMAL: | ||
311 | case FB_BLANK_VSYNC_SUSPEND: | ||
312 | case FB_BLANK_HSYNC_SUSPEND: | ||
313 | default: | ||
314 | return 1; | ||
315 | } | ||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | /* framebuffer ops */ | ||
320 | static struct fb_ops mb862xxfb_ops = { | ||
321 | .owner = THIS_MODULE, | ||
322 | .fb_check_var = mb862xxfb_check_var, | ||
323 | .fb_set_par = mb862xxfb_set_par, | ||
324 | .fb_setcolreg = mb862xxfb_setcolreg, | ||
325 | .fb_blank = mb862xxfb_blank, | ||
326 | .fb_pan_display = mb862xxfb_pan, | ||
327 | .fb_fillrect = cfb_fillrect, | ||
328 | .fb_copyarea = cfb_copyarea, | ||
329 | .fb_imageblit = cfb_imageblit, | ||
330 | }; | ||
331 | |||
332 | /* initialize fb_info data */ | ||
333 | static int mb862xxfb_init_fbinfo(struct fb_info *fbi) | ||
334 | { | ||
335 | struct mb862xxfb_par *par = fbi->par; | ||
336 | struct mb862xx_gc_mode *mode = par->gc_mode; | ||
337 | unsigned long reg; | ||
338 | |||
339 | fbi->fbops = &mb862xxfb_ops; | ||
340 | fbi->pseudo_palette = par->pseudo_palette; | ||
341 | fbi->screen_base = par->fb_base; | ||
342 | fbi->screen_size = par->mapped_vram; | ||
343 | |||
344 | strcpy(fbi->fix.id, DRV_NAME); | ||
345 | fbi->fix.smem_start = (unsigned long)par->fb_base_phys; | ||
346 | fbi->fix.smem_len = par->mapped_vram; | ||
347 | fbi->fix.mmio_start = (unsigned long)par->mmio_base_phys; | ||
348 | fbi->fix.mmio_len = par->mmio_len; | ||
349 | fbi->fix.accel = FB_ACCEL_NONE; | ||
350 | fbi->fix.type = FB_TYPE_PACKED_PIXELS; | ||
351 | fbi->fix.type_aux = 0; | ||
352 | fbi->fix.xpanstep = 1; | ||
353 | fbi->fix.ypanstep = 1; | ||
354 | fbi->fix.ywrapstep = 0; | ||
355 | |||
356 | reg = inreg(disp, GC_DCM1); | ||
357 | if (reg & GC_DCM01_DEN && reg & GC_DCM01_L0E) { | ||
358 | /* get the disp mode from active display cfg */ | ||
359 | unsigned long sc = ((reg & GC_DCM01_SC) >> 8) + 1; | ||
360 | unsigned long hsp, vsp, ht, vt; | ||
361 | |||
362 | dev_dbg(par->dev, "using bootloader's disp. mode\n"); | ||
363 | fbi->var.pixclock = (sc * 1000000) / par->refclk; | ||
364 | fbi->var.xres = (inreg(disp, GC_HDB_HDP) & 0x0fff) + 1; | ||
365 | reg = inreg(disp, GC_VDP_VSP); | ||
366 | fbi->var.yres = ((reg >> 16) & 0x0fff) + 1; | ||
367 | vsp = (reg & 0x0fff) + 1; | ||
368 | fbi->var.xres_virtual = fbi->var.xres; | ||
369 | fbi->var.yres_virtual = fbi->var.yres; | ||
370 | reg = inreg(disp, GC_L0EM); | ||
371 | if (reg & GC_L0EM_L0EC_24) { | ||
372 | fbi->var.bits_per_pixel = 32; | ||
373 | } else { | ||
374 | reg = inreg(disp, GC_L0M); | ||
375 | if (reg & GC_L0M_L0C_16) | ||
376 | fbi->var.bits_per_pixel = 16; | ||
377 | else | ||
378 | fbi->var.bits_per_pixel = 8; | ||
379 | } | ||
380 | reg = inreg(disp, GC_VSW_HSW_HSP); | ||
381 | fbi->var.hsync_len = ((reg & 0xff0000) >> 16) + 1; | ||
382 | fbi->var.vsync_len = ((reg & 0x3f000000) >> 24) + 1; | ||
383 | hsp = (reg & 0xffff) + 1; | ||
384 | ht = ((inreg(disp, GC_HTP) & 0xfff0000) >> 16) + 1; | ||
385 | fbi->var.right_margin = hsp - fbi->var.xres; | ||
386 | fbi->var.left_margin = ht - hsp - fbi->var.hsync_len; | ||
387 | vt = ((inreg(disp, GC_VTR) & 0xfff0000) >> 16) + 1; | ||
388 | fbi->var.lower_margin = vsp - fbi->var.yres; | ||
389 | fbi->var.upper_margin = vt - vsp - fbi->var.vsync_len; | ||
390 | } else if (mode) { | ||
391 | dev_dbg(par->dev, "using supplied mode\n"); | ||
392 | fb_videomode_to_var(&fbi->var, (struct fb_videomode *)mode); | ||
393 | fbi->var.bits_per_pixel = mode->def_bpp ? mode->def_bpp : 8; | ||
394 | } else { | ||
395 | int ret; | ||
396 | |||
397 | ret = fb_find_mode(&fbi->var, fbi, "640x480-16@60", | ||
398 | NULL, 0, NULL, 16); | ||
399 | if (ret == 0 || ret == 4) { | ||
400 | dev_err(par->dev, | ||
401 | "failed to get initial mode\n"); | ||
402 | return -EINVAL; | ||
403 | } | ||
404 | } | ||
405 | |||
406 | fbi->var.xoffset = 0; | ||
407 | fbi->var.yoffset = 0; | ||
408 | fbi->var.grayscale = 0; | ||
409 | fbi->var.nonstd = 0; | ||
410 | fbi->var.height = -1; | ||
411 | fbi->var.width = -1; | ||
412 | fbi->var.accel_flags = 0; | ||
413 | fbi->var.vmode = FB_VMODE_NONINTERLACED; | ||
414 | fbi->var.activate = FB_ACTIVATE_NOW; | ||
415 | fbi->flags = FBINFO_DEFAULT | | ||
416 | #ifdef __BIG_ENDIAN | ||
417 | FBINFO_FOREIGN_ENDIAN | | ||
418 | #endif | ||
419 | FBINFO_HWACCEL_XPAN | | ||
420 | FBINFO_HWACCEL_YPAN; | ||
421 | |||
422 | /* check and possibly fix bpp */ | ||
423 | if ((fbi->fbops->fb_check_var)(&fbi->var, fbi)) | ||
424 | dev_err(par->dev, "check_var() failed on initial setup?\n"); | ||
425 | |||
426 | fbi->fix.visual = fbi->var.bits_per_pixel == 8 ? | ||
427 | FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR; | ||
428 | fbi->fix.line_length = (fbi->var.xres_virtual * | ||
429 | fbi->var.bits_per_pixel) / 8; | ||
430 | return 0; | ||
431 | } | ||
432 | |||
433 | /* | ||
434 | * show some display controller and cursor registers | ||
435 | */ | ||
436 | static ssize_t mb862xxfb_show_dispregs(struct device *dev, | ||
437 | struct device_attribute *attr, char *buf) | ||
438 | { | ||
439 | struct fb_info *fbi = dev_get_drvdata(dev); | ||
440 | struct mb862xxfb_par *par = fbi->par; | ||
441 | char *ptr = buf; | ||
442 | unsigned int reg; | ||
443 | |||
444 | for (reg = GC_DCM0; reg <= GC_L0DY_L0DX; reg += 4) | ||
445 | ptr += sprintf(ptr, "%08x = %08x\n", | ||
446 | reg, inreg(disp, reg)); | ||
447 | |||
448 | for (reg = GC_CPM_CUTC; reg <= GC_CUY1_CUX1; reg += 4) | ||
449 | ptr += sprintf(ptr, "%08x = %08x\n", | ||
450 | reg, inreg(disp, reg)); | ||
451 | |||
452 | for (reg = GC_DCM1; reg <= GC_L0WH_L0WW; reg += 4) | ||
453 | ptr += sprintf(ptr, "%08x = %08x\n", | ||
454 | reg, inreg(disp, reg)); | ||
455 | |||
456 | return ptr - buf; | ||
457 | } | ||
458 | |||
459 | static DEVICE_ATTR(dispregs, 0444, mb862xxfb_show_dispregs, NULL); | ||
460 | |||
461 | irqreturn_t mb862xx_intr(int irq, void *dev_id) | ||
462 | { | ||
463 | struct mb862xxfb_par *par = (struct mb862xxfb_par *) dev_id; | ||
464 | unsigned long reg_ist, mask; | ||
465 | |||
466 | if (!par) | ||
467 | return IRQ_NONE; | ||
468 | |||
469 | if (par->type == BT_CARMINE) { | ||
470 | /* Get Interrupt Status */ | ||
471 | reg_ist = inreg(ctrl, GC_CTRL_STATUS); | ||
472 | mask = inreg(ctrl, GC_CTRL_INT_MASK); | ||
473 | if (reg_ist == 0) | ||
474 | return IRQ_HANDLED; | ||
475 | |||
476 | reg_ist &= mask; | ||
477 | if (reg_ist == 0) | ||
478 | return IRQ_HANDLED; | ||
479 | |||
480 | /* Clear interrupt status */ | ||
481 | outreg(ctrl, 0x0, reg_ist); | ||
482 | } else { | ||
483 | /* Get status */ | ||
484 | reg_ist = inreg(host, GC_IST); | ||
485 | mask = inreg(host, GC_IMASK); | ||
486 | |||
487 | reg_ist &= mask; | ||
488 | if (reg_ist == 0) | ||
489 | return IRQ_HANDLED; | ||
490 | |||
491 | /* Clear status */ | ||
492 | outreg(host, GC_IST, ~reg_ist); | ||
493 | } | ||
494 | return IRQ_HANDLED; | ||
495 | } | ||
496 | |||
497 | #if defined(CONFIG_FB_MB862XX_LIME) | ||
498 | /* | ||
499 | * GDC (Lime, Coral(B/Q), Mint, ...) on host bus | ||
500 | */ | ||
501 | static int mb862xx_gdc_init(struct mb862xxfb_par *par) | ||
502 | { | ||
503 | unsigned long ccf, mmr; | ||
504 | unsigned long ver, rev; | ||
505 | |||
506 | if (!par) | ||
507 | return -ENODEV; | ||
508 | |||
509 | #if defined(CONFIG_FB_PRE_INIT_FB) | ||
510 | par->pre_init = 1; | ||
511 | #endif | ||
512 | par->host = par->mmio_base; | ||
513 | par->i2c = par->mmio_base + MB862XX_I2C_BASE; | ||
514 | par->disp = par->mmio_base + MB862XX_DISP_BASE; | ||
515 | par->cap = par->mmio_base + MB862XX_CAP_BASE; | ||
516 | par->draw = par->mmio_base + MB862XX_DRAW_BASE; | ||
517 | par->geo = par->mmio_base + MB862XX_GEO_BASE; | ||
518 | par->pio = par->mmio_base + MB862XX_PIO_BASE; | ||
519 | |||
520 | par->refclk = GC_DISP_REFCLK_400; | ||
521 | |||
522 | ver = inreg(host, GC_CID); | ||
523 | rev = inreg(pio, GC_REVISION); | ||
524 | if ((ver == 0x303) && (rev & 0xffffff00) == 0x20050100) { | ||
525 | dev_info(par->dev, "Fujitsu Lime v1.%d found\n", | ||
526 | (int)rev & 0xff); | ||
527 | par->type = BT_LIME; | ||
528 | ccf = par->gc_mode ? par->gc_mode->ccf : GC_CCF_COT_100; | ||
529 | mmr = par->gc_mode ? par->gc_mode->mmr : 0x414fb7f2; | ||
530 | } else { | ||
531 | dev_info(par->dev, "? GDC, CID/Rev.: 0x%lx/0x%lx \n", ver, rev); | ||
532 | return -ENODEV; | ||
533 | } | ||
534 | |||
535 | if (!par->pre_init) { | ||
536 | outreg(host, GC_CCF, ccf); | ||
537 | udelay(200); | ||
538 | outreg(host, GC_MMR, mmr); | ||
539 | udelay(10); | ||
540 | } | ||
541 | |||
542 | /* interrupt status */ | ||
543 | outreg(host, GC_IST, 0); | ||
544 | outreg(host, GC_IMASK, GC_INT_EN); | ||
545 | return 0; | ||
546 | } | ||
547 | |||
548 | static int __devinit of_platform_mb862xx_probe(struct of_device *ofdev, | ||
549 | const struct of_device_id *id) | ||
550 | { | ||
551 | struct device_node *np = ofdev->node; | ||
552 | struct device *dev = &ofdev->dev; | ||
553 | struct mb862xxfb_par *par; | ||
554 | struct fb_info *info; | ||
555 | struct resource res; | ||
556 | resource_size_t res_size; | ||
557 | unsigned long ret = -ENODEV; | ||
558 | |||
559 | if (of_address_to_resource(np, 0, &res)) { | ||
560 | dev_err(dev, "Invalid address\n"); | ||
561 | return -ENXIO; | ||
562 | } | ||
563 | |||
564 | info = framebuffer_alloc(sizeof(struct mb862xxfb_par), dev); | ||
565 | if (info == NULL) { | ||
566 | dev_err(dev, "cannot allocate framebuffer\n"); | ||
567 | return -ENOMEM; | ||
568 | } | ||
569 | |||
570 | par = info->par; | ||
571 | par->info = info; | ||
572 | par->dev = dev; | ||
573 | |||
574 | par->irq = irq_of_parse_and_map(np, 0); | ||
575 | if (par->irq == NO_IRQ) { | ||
576 | dev_err(dev, "failed to map irq\n"); | ||
577 | ret = -ENODEV; | ||
578 | goto fbrel; | ||
579 | } | ||
580 | |||
581 | res_size = 1 + res.end - res.start; | ||
582 | par->res = request_mem_region(res.start, res_size, DRV_NAME); | ||
583 | if (par->res == NULL) { | ||
584 | dev_err(dev, "Cannot claim framebuffer/mmio\n"); | ||
585 | ret = -ENXIO; | ||
586 | goto irqdisp; | ||
587 | } | ||
588 | |||
589 | #if defined(CONFIG_LWMON5) | ||
590 | par->gc_mode = &lwmon5_gc_mode; | ||
591 | #endif | ||
592 | |||
593 | #if defined(CONFIG_SOCRATES) | ||
594 | par->gc_mode = &socrates_gc_mode; | ||
595 | #endif | ||
596 | |||
597 | par->fb_base_phys = res.start; | ||
598 | par->mmio_base_phys = res.start + MB862XX_MMIO_BASE; | ||
599 | par->mmio_len = MB862XX_MMIO_SIZE; | ||
600 | if (par->gc_mode) | ||
601 | par->mapped_vram = par->gc_mode->max_vram; | ||
602 | else | ||
603 | par->mapped_vram = MB862XX_MEM_SIZE; | ||
604 | |||
605 | par->fb_base = ioremap(par->fb_base_phys, par->mapped_vram); | ||
606 | if (par->fb_base == NULL) { | ||
607 | dev_err(dev, "Cannot map framebuffer\n"); | ||
608 | goto rel_reg; | ||
609 | } | ||
610 | |||
611 | par->mmio_base = ioremap(par->mmio_base_phys, par->mmio_len); | ||
612 | if (par->mmio_base == NULL) { | ||
613 | dev_err(dev, "Cannot map registers\n"); | ||
614 | goto fb_unmap; | ||
615 | } | ||
616 | |||
617 | dev_dbg(dev, "fb phys 0x%llx 0x%lx\n", | ||
618 | (u64)par->fb_base_phys, (ulong)par->mapped_vram); | ||
619 | dev_dbg(dev, "mmio phys 0x%llx 0x%lx, (irq = %d)\n", | ||
620 | (u64)par->mmio_base_phys, (ulong)par->mmio_len, par->irq); | ||
621 | |||
622 | if (mb862xx_gdc_init(par)) | ||
623 | goto io_unmap; | ||
624 | |||
625 | if (request_irq(par->irq, mb862xx_intr, IRQF_DISABLED, | ||
626 | DRV_NAME, (void *)par)) { | ||
627 | dev_err(dev, "Cannot request irq\n"); | ||
628 | goto io_unmap; | ||
629 | } | ||
630 | |||
631 | mb862xxfb_init_fbinfo(info); | ||
632 | |||
633 | if (fb_alloc_cmap(&info->cmap, NR_PALETTE, 0) < 0) { | ||
634 | dev_err(dev, "Could not allocate cmap for fb_info.\n"); | ||
635 | goto free_irq; | ||
636 | } | ||
637 | |||
638 | if ((info->fbops->fb_set_par)(info)) | ||
639 | dev_err(dev, "set_var() failed on initial setup?\n"); | ||
640 | |||
641 | if (register_framebuffer(info)) { | ||
642 | dev_err(dev, "failed to register framebuffer\n"); | ||
643 | goto rel_cmap; | ||
644 | } | ||
645 | |||
646 | dev_set_drvdata(dev, info); | ||
647 | |||
648 | if (device_create_file(dev, &dev_attr_dispregs)) | ||
649 | dev_err(dev, "Can't create sysfs regdump file\n"); | ||
650 | return 0; | ||
651 | |||
652 | rel_cmap: | ||
653 | fb_dealloc_cmap(&info->cmap); | ||
654 | free_irq: | ||
655 | outreg(host, GC_IMASK, 0); | ||
656 | free_irq(par->irq, (void *)par); | ||
657 | io_unmap: | ||
658 | iounmap(par->mmio_base); | ||
659 | fb_unmap: | ||
660 | iounmap(par->fb_base); | ||
661 | rel_reg: | ||
662 | release_mem_region(res.start, res_size); | ||
663 | irqdisp: | ||
664 | irq_dispose_mapping(par->irq); | ||
665 | fbrel: | ||
666 | dev_set_drvdata(dev, NULL); | ||
667 | framebuffer_release(info); | ||
668 | return ret; | ||
669 | } | ||
670 | |||
671 | static int __devexit of_platform_mb862xx_remove(struct of_device *ofdev) | ||
672 | { | ||
673 | struct fb_info *fbi = dev_get_drvdata(&ofdev->dev); | ||
674 | struct mb862xxfb_par *par = fbi->par; | ||
675 | resource_size_t res_size = 1 + par->res->end - par->res->start; | ||
676 | unsigned long reg; | ||
677 | |||
678 | dev_dbg(fbi->dev, "%s release\n", fbi->fix.id); | ||
679 | |||
680 | /* display off */ | ||
681 | reg = inreg(disp, GC_DCM1); | ||
682 | reg &= ~(GC_DCM01_DEN | GC_DCM01_L0E); | ||
683 | outreg(disp, GC_DCM1, reg); | ||
684 | |||
685 | /* disable interrupts */ | ||
686 | outreg(host, GC_IMASK, 0); | ||
687 | |||
688 | free_irq(par->irq, (void *)par); | ||
689 | irq_dispose_mapping(par->irq); | ||
690 | |||
691 | device_remove_file(&ofdev->dev, &dev_attr_dispregs); | ||
692 | |||
693 | unregister_framebuffer(fbi); | ||
694 | fb_dealloc_cmap(&fbi->cmap); | ||
695 | |||
696 | iounmap(par->mmio_base); | ||
697 | iounmap(par->fb_base); | ||
698 | |||
699 | dev_set_drvdata(&ofdev->dev, NULL); | ||
700 | release_mem_region(par->res->start, res_size); | ||
701 | framebuffer_release(fbi); | ||
702 | return 0; | ||
703 | } | ||
704 | |||
705 | /* | ||
706 | * common types | ||
707 | */ | ||
708 | static struct of_device_id __devinitdata of_platform_mb862xx_tbl[] = { | ||
709 | { .compatible = "fujitsu,MB86276", }, | ||
710 | { .compatible = "fujitsu,lime", }, | ||
711 | { .compatible = "fujitsu,MB86277", }, | ||
712 | { .compatible = "fujitsu,mint", }, | ||
713 | { .compatible = "fujitsu,MB86293", }, | ||
714 | { .compatible = "fujitsu,MB86294", }, | ||
715 | { .compatible = "fujitsu,coral", }, | ||
716 | { /* end */ } | ||
717 | }; | ||
718 | |||
719 | static struct of_platform_driver of_platform_mb862xxfb_driver = { | ||
720 | .owner = THIS_MODULE, | ||
721 | .name = DRV_NAME, | ||
722 | .match_table = of_platform_mb862xx_tbl, | ||
723 | .probe = of_platform_mb862xx_probe, | ||
724 | .remove = __devexit_p(of_platform_mb862xx_remove), | ||
725 | }; | ||
726 | #endif | ||
727 | |||
728 | #if defined(CONFIG_FB_MB862XX_PCI_GDC) | ||
729 | static int coralp_init(struct mb862xxfb_par *par) | ||
730 | { | ||
731 | int cn, ver; | ||
732 | |||
733 | par->host = par->mmio_base; | ||
734 | par->i2c = par->mmio_base + MB862XX_I2C_BASE; | ||
735 | par->disp = par->mmio_base + MB862XX_DISP_BASE; | ||
736 | par->cap = par->mmio_base + MB862XX_CAP_BASE; | ||
737 | par->draw = par->mmio_base + MB862XX_DRAW_BASE; | ||
738 | par->geo = par->mmio_base + MB862XX_GEO_BASE; | ||
739 | par->pio = par->mmio_base + MB862XX_PIO_BASE; | ||
740 | |||
741 | par->refclk = GC_DISP_REFCLK_400; | ||
742 | |||
743 | ver = inreg(host, GC_CID); | ||
744 | cn = (ver & GC_CID_CNAME_MSK) >> 8; | ||
745 | ver = ver & GC_CID_VERSION_MSK; | ||
746 | if (cn == 3) { | ||
747 | dev_info(par->dev, "Fujitsu Coral-%s GDC Rev.%d found\n",\ | ||
748 | (ver == 6) ? "P" : (ver == 8) ? "PA" : "?", | ||
749 | par->pdev->revision); | ||
750 | outreg(host, GC_CCF, GC_CCF_CGE_166 | GC_CCF_COT_133); | ||
751 | udelay(200); | ||
752 | outreg(host, GC_MMR, GC_MMR_CORALP_EVB_VAL); | ||
753 | udelay(10); | ||
754 | /* Clear interrupt status */ | ||
755 | outreg(host, GC_IST, 0); | ||
756 | } else { | ||
757 | return -ENODEV; | ||
758 | } | ||
759 | return 0; | ||
760 | } | ||
761 | |||
762 | static int init_dram_ctrl(struct mb862xxfb_par *par) | ||
763 | { | ||
764 | unsigned long i = 0; | ||
765 | |||
766 | /* | ||
767 | * Set io mode first! Spec. says IC may be destroyed | ||
768 | * if not set to SSTL2/LVCMOS before init. | ||
769 | */ | ||
770 | outreg(dram_ctrl, GC_DCTL_IOCONT1_IOCONT0, GC_EVB_DCTL_IOCONT1_IOCONT0); | ||
771 | |||
772 | /* DRAM init */ | ||
773 | outreg(dram_ctrl, GC_DCTL_MODE_ADD, GC_EVB_DCTL_MODE_ADD); | ||
774 | outreg(dram_ctrl, GC_DCTL_SETTIME1_EMODE, GC_EVB_DCTL_SETTIME1_EMODE); | ||
775 | outreg(dram_ctrl, GC_DCTL_REFRESH_SETTIME2, | ||
776 | GC_EVB_DCTL_REFRESH_SETTIME2); | ||
777 | outreg(dram_ctrl, GC_DCTL_RSV2_RSV1, GC_EVB_DCTL_RSV2_RSV1); | ||
778 | outreg(dram_ctrl, GC_DCTL_DDRIF2_DDRIF1, GC_EVB_DCTL_DDRIF2_DDRIF1); | ||
779 | outreg(dram_ctrl, GC_DCTL_RSV0_STATES, GC_EVB_DCTL_RSV0_STATES); | ||
780 | |||
781 | /* DLL reset done? */ | ||
782 | while ((inreg(dram_ctrl, GC_DCTL_RSV0_STATES) & GC_DCTL_STATES_MSK)) { | ||
783 | udelay(GC_DCTL_INIT_WAIT_INTERVAL); | ||
784 | if (i++ > GC_DCTL_INIT_WAIT_CNT) { | ||
785 | dev_err(par->dev, "VRAM init failed.\n"); | ||
786 | return -EINVAL; | ||
787 | } | ||
788 | } | ||
789 | outreg(dram_ctrl, GC_DCTL_MODE_ADD, GC_EVB_DCTL_MODE_ADD_AFT_RST); | ||
790 | outreg(dram_ctrl, GC_DCTL_RSV0_STATES, GC_EVB_DCTL_RSV0_STATES_AFT_RST); | ||
791 | return 0; | ||
792 | } | ||
793 | |||
794 | static int carmine_init(struct mb862xxfb_par *par) | ||
795 | { | ||
796 | unsigned long reg; | ||
797 | |||
798 | par->ctrl = par->mmio_base + MB86297_CTRL_BASE; | ||
799 | par->i2c = par->mmio_base + MB86297_I2C_BASE; | ||
800 | par->disp = par->mmio_base + MB86297_DISP0_BASE; | ||
801 | par->disp1 = par->mmio_base + MB86297_DISP1_BASE; | ||
802 | par->cap = par->mmio_base + MB86297_CAP0_BASE; | ||
803 | par->cap1 = par->mmio_base + MB86297_CAP1_BASE; | ||
804 | par->draw = par->mmio_base + MB86297_DRAW_BASE; | ||
805 | par->dram_ctrl = par->mmio_base + MB86297_DRAMCTRL_BASE; | ||
806 | par->wrback = par->mmio_base + MB86297_WRBACK_BASE; | ||
807 | |||
808 | par->refclk = GC_DISP_REFCLK_533; | ||
809 | |||
810 | /* warm up */ | ||
811 | reg = GC_CTRL_CLK_EN_DRAM | GC_CTRL_CLK_EN_2D3D | GC_CTRL_CLK_EN_DISP0; | ||
812 | outreg(ctrl, GC_CTRL_CLK_ENABLE, reg); | ||
813 | |||
814 | /* check for engine module revision */ | ||
815 | if (inreg(draw, GC_2D3D_REV) == GC_RE_REVISION) | ||
816 | dev_info(par->dev, "Fujitsu Carmine GDC Rev.%d found\n", | ||
817 | par->pdev->revision); | ||
818 | else | ||
819 | goto err_init; | ||
820 | |||
821 | reg &= ~GC_CTRL_CLK_EN_2D3D; | ||
822 | outreg(ctrl, GC_CTRL_CLK_ENABLE, reg); | ||
823 | |||
824 | /* set up vram */ | ||
825 | if (init_dram_ctrl(par) < 0) | ||
826 | goto err_init; | ||
827 | |||
828 | outreg(ctrl, GC_CTRL_INT_MASK, 0); | ||
829 | return 0; | ||
830 | |||
831 | err_init: | ||
832 | outreg(ctrl, GC_CTRL_CLK_ENABLE, 0); | ||
833 | return -EINVAL; | ||
834 | } | ||
835 | |||
836 | static inline int mb862xx_pci_gdc_init(struct mb862xxfb_par *par) | ||
837 | { | ||
838 | switch (par->type) { | ||
839 | case BT_CORALP: | ||
840 | return coralp_init(par); | ||
841 | case BT_CARMINE: | ||
842 | return carmine_init(par); | ||
843 | default: | ||
844 | return -ENODEV; | ||
845 | } | ||
846 | } | ||
847 | |||
848 | #define CHIP_ID(id) \ | ||
849 | { PCI_DEVICE(PCI_VENDOR_ID_FUJITSU_LIMITED, id) } | ||
850 | |||
851 | static struct pci_device_id mb862xx_pci_tbl[] __devinitdata = { | ||
852 | /* MB86295/MB86296 */ | ||
853 | CHIP_ID(PCI_DEVICE_ID_FUJITSU_CORALP), | ||
854 | CHIP_ID(PCI_DEVICE_ID_FUJITSU_CORALPA), | ||
855 | /* MB86297 */ | ||
856 | CHIP_ID(PCI_DEVICE_ID_FUJITSU_CARMINE), | ||
857 | { 0, } | ||
858 | }; | ||
859 | |||
860 | MODULE_DEVICE_TABLE(pci, mb862xx_pci_tbl); | ||
861 | |||
862 | static int __devinit mb862xx_pci_probe(struct pci_dev *pdev, | ||
863 | const struct pci_device_id *ent) | ||
864 | { | ||
865 | struct mb862xxfb_par *par; | ||
866 | struct fb_info *info; | ||
867 | struct device *dev = &pdev->dev; | ||
868 | int ret; | ||
869 | |||
870 | ret = pci_enable_device(pdev); | ||
871 | if (ret < 0) { | ||
872 | dev_err(dev, "Cannot enable PCI device\n"); | ||
873 | goto out; | ||
874 | } | ||
875 | |||
876 | info = framebuffer_alloc(sizeof(struct mb862xxfb_par), dev); | ||
877 | if (!info) { | ||
878 | dev_err(dev, "framebuffer alloc failed\n"); | ||
879 | ret = -ENOMEM; | ||
880 | goto dis_dev; | ||
881 | } | ||
882 | |||
883 | par = info->par; | ||
884 | par->info = info; | ||
885 | par->dev = dev; | ||
886 | par->pdev = pdev; | ||
887 | par->irq = pdev->irq; | ||
888 | |||
889 | ret = pci_request_regions(pdev, DRV_NAME); | ||
890 | if (ret < 0) { | ||
891 | dev_err(dev, "Cannot reserve region(s) for PCI device\n"); | ||
892 | goto rel_fb; | ||
893 | } | ||
894 | |||
895 | switch (pdev->device) { | ||
896 | case PCI_DEVICE_ID_FUJITSU_CORALP: | ||
897 | case PCI_DEVICE_ID_FUJITSU_CORALPA: | ||
898 | par->fb_base_phys = pci_resource_start(par->pdev, 0); | ||
899 | par->mapped_vram = CORALP_MEM_SIZE; | ||
900 | par->mmio_base_phys = par->fb_base_phys + MB862XX_MMIO_BASE; | ||
901 | par->mmio_len = MB862XX_MMIO_SIZE; | ||
902 | par->type = BT_CORALP; | ||
903 | break; | ||
904 | case PCI_DEVICE_ID_FUJITSU_CARMINE: | ||
905 | par->fb_base_phys = pci_resource_start(par->pdev, 2); | ||
906 | par->mmio_base_phys = pci_resource_start(par->pdev, 3); | ||
907 | par->mmio_len = pci_resource_len(par->pdev, 3); | ||
908 | par->mapped_vram = CARMINE_MEM_SIZE; | ||
909 | par->type = BT_CARMINE; | ||
910 | break; | ||
911 | default: | ||
912 | /* should never occur */ | ||
913 | goto rel_reg; | ||
914 | } | ||
915 | |||
916 | par->fb_base = ioremap(par->fb_base_phys, par->mapped_vram); | ||
917 | if (par->fb_base == NULL) { | ||
918 | dev_err(dev, "Cannot map framebuffer\n"); | ||
919 | goto rel_reg; | ||
920 | } | ||
921 | |||
922 | par->mmio_base = ioremap(par->mmio_base_phys, par->mmio_len); | ||
923 | if (par->mmio_base == NULL) { | ||
924 | dev_err(dev, "Cannot map registers\n"); | ||
925 | ret = -EIO; | ||
926 | goto fb_unmap; | ||
927 | } | ||
928 | |||
929 | dev_dbg(dev, "fb phys 0x%llx 0x%lx\n", | ||
930 | (u64)par->fb_base_phys, (ulong)par->mapped_vram); | ||
931 | dev_dbg(dev, "mmio phys 0x%llx 0x%lx\n", | ||
932 | (u64)par->mmio_base_phys, (ulong)par->mmio_len); | ||
933 | |||
934 | if (mb862xx_pci_gdc_init(par)) | ||
935 | goto io_unmap; | ||
936 | |||
937 | if (request_irq(par->irq, mb862xx_intr, IRQF_DISABLED | IRQF_SHARED, | ||
938 | DRV_NAME, (void *)par)) { | ||
939 | dev_err(dev, "Cannot request irq\n"); | ||
940 | goto io_unmap; | ||
941 | } | ||
942 | |||
943 | mb862xxfb_init_fbinfo(info); | ||
944 | |||
945 | if (fb_alloc_cmap(&info->cmap, NR_PALETTE, 0) < 0) { | ||
946 | dev_err(dev, "Could not allocate cmap for fb_info.\n"); | ||
947 | ret = -ENOMEM; | ||
948 | goto free_irq; | ||
949 | } | ||
950 | |||
951 | if ((info->fbops->fb_set_par)(info)) | ||
952 | dev_err(dev, "set_var() failed on initial setup?\n"); | ||
953 | |||
954 | ret = register_framebuffer(info); | ||
955 | if (ret < 0) { | ||
956 | dev_err(dev, "failed to register framebuffer\n"); | ||
957 | goto rel_cmap; | ||
958 | } | ||
959 | |||
960 | pci_set_drvdata(pdev, info); | ||
961 | |||
962 | if (device_create_file(dev, &dev_attr_dispregs)) | ||
963 | dev_err(dev, "Can't create sysfs regdump file\n"); | ||
964 | |||
965 | if (par->type == BT_CARMINE) | ||
966 | outreg(ctrl, GC_CTRL_INT_MASK, GC_CARMINE_INT_EN); | ||
967 | else | ||
968 | outreg(host, GC_IMASK, GC_INT_EN); | ||
969 | |||
970 | return 0; | ||
971 | |||
972 | rel_cmap: | ||
973 | fb_dealloc_cmap(&info->cmap); | ||
974 | free_irq: | ||
975 | free_irq(par->irq, (void *)par); | ||
976 | io_unmap: | ||
977 | iounmap(par->mmio_base); | ||
978 | fb_unmap: | ||
979 | iounmap(par->fb_base); | ||
980 | rel_reg: | ||
981 | pci_release_regions(pdev); | ||
982 | rel_fb: | ||
983 | framebuffer_release(info); | ||
984 | dis_dev: | ||
985 | pci_disable_device(pdev); | ||
986 | out: | ||
987 | return ret; | ||
988 | } | ||
989 | |||
990 | static void __devexit mb862xx_pci_remove(struct pci_dev *pdev) | ||
991 | { | ||
992 | struct fb_info *fbi = pci_get_drvdata(pdev); | ||
993 | struct mb862xxfb_par *par = fbi->par; | ||
994 | unsigned long reg; | ||
995 | |||
996 | dev_dbg(fbi->dev, "%s release\n", fbi->fix.id); | ||
997 | |||
998 | /* display off */ | ||
999 | reg = inreg(disp, GC_DCM1); | ||
1000 | reg &= ~(GC_DCM01_DEN | GC_DCM01_L0E); | ||
1001 | outreg(disp, GC_DCM1, reg); | ||
1002 | |||
1003 | if (par->type == BT_CARMINE) { | ||
1004 | outreg(ctrl, GC_CTRL_INT_MASK, 0); | ||
1005 | outreg(ctrl, GC_CTRL_CLK_ENABLE, 0); | ||
1006 | } else { | ||
1007 | outreg(host, GC_IMASK, 0); | ||
1008 | } | ||
1009 | |||
1010 | device_remove_file(&pdev->dev, &dev_attr_dispregs); | ||
1011 | |||
1012 | pci_set_drvdata(pdev, NULL); | ||
1013 | unregister_framebuffer(fbi); | ||
1014 | fb_dealloc_cmap(&fbi->cmap); | ||
1015 | |||
1016 | free_irq(par->irq, (void *)par); | ||
1017 | iounmap(par->mmio_base); | ||
1018 | iounmap(par->fb_base); | ||
1019 | |||
1020 | pci_release_regions(pdev); | ||
1021 | framebuffer_release(fbi); | ||
1022 | pci_disable_device(pdev); | ||
1023 | } | ||
1024 | |||
1025 | static struct pci_driver mb862xxfb_pci_driver = { | ||
1026 | .name = DRV_NAME, | ||
1027 | .id_table = mb862xx_pci_tbl, | ||
1028 | .probe = mb862xx_pci_probe, | ||
1029 | .remove = __devexit_p(mb862xx_pci_remove), | ||
1030 | }; | ||
1031 | #endif | ||
1032 | |||
1033 | static int __devinit mb862xxfb_init(void) | ||
1034 | { | ||
1035 | int ret = -ENODEV; | ||
1036 | |||
1037 | #if defined(CONFIG_FB_MB862XX_LIME) | ||
1038 | ret = of_register_platform_driver(&of_platform_mb862xxfb_driver); | ||
1039 | #endif | ||
1040 | #if defined(CONFIG_FB_MB862XX_PCI_GDC) | ||
1041 | ret = pci_register_driver(&mb862xxfb_pci_driver); | ||
1042 | #endif | ||
1043 | return ret; | ||
1044 | } | ||
1045 | |||
1046 | static void __exit mb862xxfb_exit(void) | ||
1047 | { | ||
1048 | #if defined(CONFIG_FB_MB862XX_LIME) | ||
1049 | of_unregister_platform_driver(&of_platform_mb862xxfb_driver); | ||
1050 | #endif | ||
1051 | #if defined(CONFIG_FB_MB862XX_PCI_GDC) | ||
1052 | pci_unregister_driver(&mb862xxfb_pci_driver); | ||
1053 | #endif | ||
1054 | } | ||
1055 | |||
1056 | module_init(mb862xxfb_init); | ||
1057 | module_exit(mb862xxfb_exit); | ||
1058 | |||
1059 | MODULE_DESCRIPTION("Fujitsu MB862xx Framebuffer driver"); | ||
1060 | MODULE_AUTHOR("Anatolij Gustschin <agust@denx.de>"); | ||
1061 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/video/mb862xx/mb862xxfb.h b/drivers/video/mb862xx/mb862xxfb.h new file mode 100644 index 00000000000..c4c8f4dd221 --- /dev/null +++ b/drivers/video/mb862xx/mb862xxfb.h | |||
@@ -0,0 +1,83 @@ | |||
1 | #ifndef __MB862XX_H__ | ||
2 | #define __MB862XX_H__ | ||
3 | |||
4 | #define PCI_VENDOR_ID_FUJITSU_LIMITED 0x10cf | ||
5 | #define PCI_DEVICE_ID_FUJITSU_CORALP 0x2019 | ||
6 | #define PCI_DEVICE_ID_FUJITSU_CORALPA 0x201e | ||
7 | #define PCI_DEVICE_ID_FUJITSU_CARMINE 0x202b | ||
8 | |||
9 | #define GC_MMR_CORALP_EVB_VAL 0x11d7fa13 | ||
10 | |||
11 | enum gdctype { | ||
12 | BT_NONE, | ||
13 | BT_LIME, | ||
14 | BT_MINT, | ||
15 | BT_CORAL, | ||
16 | BT_CORALP, | ||
17 | BT_CARMINE, | ||
18 | }; | ||
19 | |||
20 | struct mb862xx_gc_mode { | ||
21 | struct fb_videomode def_mode; /* mode of connected display */ | ||
22 | unsigned int def_bpp; /* default depth */ | ||
23 | unsigned long max_vram; /* connected SDRAM size */ | ||
24 | unsigned long ccf; /* gdc clk */ | ||
25 | unsigned long mmr; /* memory mode for SDRAM */ | ||
26 | }; | ||
27 | |||
28 | /* private data */ | ||
29 | struct mb862xxfb_par { | ||
30 | struct fb_info *info; /* fb info head */ | ||
31 | struct device *dev; | ||
32 | struct pci_dev *pdev; | ||
33 | struct resource *res; /* framebuffer/mmio resource */ | ||
34 | |||
35 | resource_size_t fb_base_phys; /* fb base, 36-bit PPC440EPx */ | ||
36 | resource_size_t mmio_base_phys; /* io base addr */ | ||
37 | void __iomem *fb_base; /* remapped framebuffer */ | ||
38 | void __iomem *mmio_base; /* remapped registers */ | ||
39 | size_t mapped_vram; /* length of remapped vram */ | ||
40 | size_t mmio_len; /* length of register region */ | ||
41 | |||
42 | void __iomem *host; /* relocatable reg. bases */ | ||
43 | void __iomem *i2c; | ||
44 | void __iomem *disp; | ||
45 | void __iomem *disp1; | ||
46 | void __iomem *cap; | ||
47 | void __iomem *cap1; | ||
48 | void __iomem *draw; | ||
49 | void __iomem *geo; | ||
50 | void __iomem *pio; | ||
51 | void __iomem *ctrl; | ||
52 | void __iomem *dram_ctrl; | ||
53 | void __iomem *wrback; | ||
54 | |||
55 | unsigned int irq; | ||
56 | unsigned int type; /* GDC type */ | ||
57 | unsigned int refclk; /* disp. reference clock */ | ||
58 | struct mb862xx_gc_mode *gc_mode; /* GDC mode init data */ | ||
59 | int pre_init; /* don't init display if 1 */ | ||
60 | |||
61 | u32 pseudo_palette[16]; | ||
62 | }; | ||
63 | |||
64 | #if defined(CONFIG_FB_MB862XX_LIME) && defined(CONFIG_FB_MB862XX_PCI_GDC) | ||
65 | #error "Select Lime GDC or CoralP/Carmine support, but not both together" | ||
66 | #endif | ||
67 | #if defined(CONFIG_FB_MB862XX_LIME) | ||
68 | #define gdc_read __raw_readl | ||
69 | #define gdc_write __raw_writel | ||
70 | #else | ||
71 | #define gdc_read readl | ||
72 | #define gdc_write writel | ||
73 | #endif | ||
74 | |||
75 | #define inreg(type, off) \ | ||
76 | gdc_read((par->type + (off))) | ||
77 | |||
78 | #define outreg(type, off, val) \ | ||
79 | gdc_write((val), (par->type + (off))) | ||
80 | |||
81 | #define pack(a, b) (((a) << 16) | (b)) | ||
82 | |||
83 | #endif | ||
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c index 4c32c06579a..efff672fd7b 100644 --- a/drivers/video/sh_mobile_lcdcfb.c +++ b/drivers/video/sh_mobile_lcdcfb.c | |||
@@ -16,7 +16,7 @@ | |||
16 | #include <linux/clk.h> | 16 | #include <linux/clk.h> |
17 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
18 | #include <linux/dma-mapping.h> | 18 | #include <linux/dma-mapping.h> |
19 | #include <asm/sh_mobile_lcdc.h> | 19 | #include <video/sh_mobile_lcdc.h> |
20 | 20 | ||
21 | #define PALETTE_NR 16 | 21 | #define PALETTE_NR 16 |
22 | 22 | ||
@@ -34,7 +34,9 @@ struct sh_mobile_lcdc_chan { | |||
34 | 34 | ||
35 | struct sh_mobile_lcdc_priv { | 35 | struct sh_mobile_lcdc_priv { |
36 | void __iomem *base; | 36 | void __iomem *base; |
37 | #ifdef CONFIG_HAVE_CLK | ||
37 | struct clk *clk; | 38 | struct clk *clk; |
39 | #endif | ||
38 | unsigned long lddckr; | 40 | unsigned long lddckr; |
39 | struct sh_mobile_lcdc_chan ch[2]; | 41 | struct sh_mobile_lcdc_chan ch[2]; |
40 | }; | 42 | }; |
@@ -260,6 +262,11 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv) | |||
260 | tmp = ch->ldmt1r_value; | 262 | tmp = ch->ldmt1r_value; |
261 | tmp |= (lcd_cfg->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : 1 << 28; | 263 | tmp |= (lcd_cfg->sync & FB_SYNC_VERT_HIGH_ACT) ? 0 : 1 << 28; |
262 | tmp |= (lcd_cfg->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : 1 << 27; | 264 | tmp |= (lcd_cfg->sync & FB_SYNC_HOR_HIGH_ACT) ? 0 : 1 << 27; |
265 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DWPOL) ? 1 << 26 : 0; | ||
266 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DIPOL) ? 1 << 25 : 0; | ||
267 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DAPOL) ? 1 << 24 : 0; | ||
268 | tmp |= (ch->cfg.flags & LCDC_FLAGS_HSCNT) ? 1 << 17 : 0; | ||
269 | tmp |= (ch->cfg.flags & LCDC_FLAGS_DWCNT) ? 1 << 16 : 0; | ||
263 | lcdc_write_chan(ch, LDMT1R, tmp); | 270 | lcdc_write_chan(ch, LDMT1R, tmp); |
264 | 271 | ||
265 | /* setup SYS bus */ | 272 | /* setup SYS bus */ |
@@ -422,6 +429,7 @@ static int sh_mobile_lcdc_setup_clocks(struct device *dev, int clock_source, | |||
422 | 429 | ||
423 | priv->lddckr = icksel << 16; | 430 | priv->lddckr = icksel << 16; |
424 | 431 | ||
432 | #ifdef CONFIG_HAVE_CLK | ||
425 | if (str) { | 433 | if (str) { |
426 | priv->clk = clk_get(dev, str); | 434 | priv->clk = clk_get(dev, str); |
427 | if (IS_ERR(priv->clk)) { | 435 | if (IS_ERR(priv->clk)) { |
@@ -431,6 +439,7 @@ static int sh_mobile_lcdc_setup_clocks(struct device *dev, int clock_source, | |||
431 | 439 | ||
432 | clk_enable(priv->clk); | 440 | clk_enable(priv->clk); |
433 | } | 441 | } |
442 | #endif | ||
434 | 443 | ||
435 | return 0; | 444 | return 0; |
436 | } | 445 | } |
@@ -585,7 +594,6 @@ static int __init sh_mobile_lcdc_probe(struct platform_device *pdev) | |||
585 | goto err1; | 594 | goto err1; |
586 | } | 595 | } |
587 | 596 | ||
588 | priv->lddckr = pdata->lddckr; | ||
589 | priv->base = ioremap_nocache(res->start, (res->end - res->start) + 1); | 597 | priv->base = ioremap_nocache(res->start, (res->end - res->start) + 1); |
590 | 598 | ||
591 | for (i = 0; i < j; i++) { | 599 | for (i = 0; i < j; i++) { |
@@ -688,10 +696,12 @@ static int sh_mobile_lcdc_remove(struct platform_device *pdev) | |||
688 | fb_dealloc_cmap(&info->cmap); | 696 | fb_dealloc_cmap(&info->cmap); |
689 | } | 697 | } |
690 | 698 | ||
699 | #ifdef CONFIG_HAVE_CLK | ||
691 | if (priv->clk) { | 700 | if (priv->clk) { |
692 | clk_disable(priv->clk); | 701 | clk_disable(priv->clk); |
693 | clk_put(priv->clk); | 702 | clk_put(priv->clk); |
694 | } | 703 | } |
704 | #endif | ||
695 | 705 | ||
696 | if (priv->base) | 706 | if (priv->base) |
697 | iounmap(priv->base); | 707 | iounmap(priv->base); |
diff --git a/drivers/video/via/global.h b/drivers/video/via/global.h index 8e5263c5b81..7543d5f7e30 100644 --- a/drivers/video/via/global.h +++ b/drivers/video/via/global.h | |||
@@ -38,7 +38,6 @@ | |||
38 | #include "iface.h" | 38 | #include "iface.h" |
39 | #include "viafbdev.h" | 39 | #include "viafbdev.h" |
40 | #include "chip.h" | 40 | #include "chip.h" |
41 | #include "debug.h" | ||
42 | #include "accel.h" | 41 | #include "accel.h" |
43 | #include "share.h" | 42 | #include "share.h" |
44 | #include "dvi.h" | 43 | #include "dvi.h" |
@@ -48,12 +47,10 @@ | |||
48 | 47 | ||
49 | #include "lcd.h" | 48 | #include "lcd.h" |
50 | #include "ioctl.h" | 49 | #include "ioctl.h" |
51 | #include "viamode.h" | ||
52 | #include "via_utility.h" | 50 | #include "via_utility.h" |
53 | #include "vt1636.h" | 51 | #include "vt1636.h" |
54 | #include "tblDPASetting.h" | 52 | #include "tblDPASetting.h" |
55 | #include "tbl1636.h" | 53 | #include "tbl1636.h" |
56 | #include "viafbdev.h" | ||
57 | 54 | ||
58 | /* External struct*/ | 55 | /* External struct*/ |
59 | 56 | ||