arkfb.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. /*
  2. * linux/drivers/video/arkfb.c -- Frame buffer device driver for ARK 2000PV
  3. * with ICS 5342 dac (it is easy to add support for different dacs).
  4. *
  5. * Copyright (c) 2007 Ondrej Zajicek <santiago@crfreenet.org>
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file COPYING in the main directory of this archive for
  9. * more details.
  10. *
  11. * Code is based on s3fb
  12. */
  13. #include <linux/version.h>
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/errno.h>
  17. #include <linux/string.h>
  18. #include <linux/mm.h>
  19. #include <linux/tty.h>
  20. #include <linux/slab.h>
  21. #include <linux/delay.h>
  22. #include <linux/fb.h>
  23. #include <linux/svga.h>
  24. #include <linux/init.h>
  25. #include <linux/pci.h>
  26. #include <linux/console.h> /* Why should fb driver call console functions? because acquire_console_sem() */
  27. #include <video/vga.h>
  28. #ifdef CONFIG_MTRR
  29. #include <asm/mtrr.h>
  30. #endif
  31. struct arkfb_info {
  32. int mclk_freq;
  33. int mtrr_reg;
  34. struct dac_info *dac;
  35. struct vgastate state;
  36. struct mutex open_lock;
  37. unsigned int ref_count;
  38. u32 pseudo_palette[16];
  39. };
  40. /* ------------------------------------------------------------------------- */
  41. static const struct svga_fb_format arkfb_formats[] = {
  42. { 0, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  43. FB_TYPE_TEXT, FB_AUX_TEXT_SVGA_STEP4, FB_VISUAL_PSEUDOCOLOR, 8, 8},
  44. { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  45. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 16},
  46. { 4, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 1,
  47. FB_TYPE_INTERLEAVED_PLANES, 1, FB_VISUAL_PSEUDOCOLOR, 8, 16},
  48. { 8, {0, 6, 0}, {0, 6, 0}, {0, 6, 0}, {0, 0, 0}, 0,
  49. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_PSEUDOCOLOR, 8, 8},
  50. {16, {10, 5, 0}, {5, 5, 0}, {0, 5, 0}, {0, 0, 0}, 0,
  51. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4},
  52. {16, {11, 5, 0}, {5, 6, 0}, {0, 5, 0}, {0, 0, 0}, 0,
  53. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 4, 4},
  54. {24, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
  55. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 8, 8},
  56. {32, {16, 8, 0}, {8, 8, 0}, {0, 8, 0}, {0, 0, 0}, 0,
  57. FB_TYPE_PACKED_PIXELS, 0, FB_VISUAL_TRUECOLOR, 2, 2},
  58. SVGA_FORMAT_END
  59. };
  60. /* CRT timing register sets */
  61. static const struct vga_regset ark_h_total_regs[] = {{0x00, 0, 7}, {0x41, 7, 7}, VGA_REGSET_END};
  62. static const struct vga_regset ark_h_display_regs[] = {{0x01, 0, 7}, {0x41, 6, 6}, VGA_REGSET_END};
  63. static const struct vga_regset ark_h_blank_start_regs[] = {{0x02, 0, 7}, {0x41, 5, 5}, VGA_REGSET_END};
  64. static const struct vga_regset ark_h_blank_end_regs[] = {{0x03, 0, 4}, {0x05, 7, 7 }, VGA_REGSET_END};
  65. static const struct vga_regset ark_h_sync_start_regs[] = {{0x04, 0, 7}, {0x41, 4, 4}, VGA_REGSET_END};
  66. static const struct vga_regset ark_h_sync_end_regs[] = {{0x05, 0, 4}, VGA_REGSET_END};
  67. static const struct vga_regset ark_v_total_regs[] = {{0x06, 0, 7}, {0x07, 0, 0}, {0x07, 5, 5}, {0x40, 7, 7}, VGA_REGSET_END};
  68. static const struct vga_regset ark_v_display_regs[] = {{0x12, 0, 7}, {0x07, 1, 1}, {0x07, 6, 6}, {0x40, 6, 6}, VGA_REGSET_END};
  69. static const struct vga_regset ark_v_blank_start_regs[] = {{0x15, 0, 7}, {0x07, 3, 3}, {0x09, 5, 5}, {0x40, 5, 5}, VGA_REGSET_END};
  70. // const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 6}, VGA_REGSET_END};
  71. static const struct vga_regset ark_v_blank_end_regs[] = {{0x16, 0, 7}, VGA_REGSET_END};
  72. static const struct vga_regset ark_v_sync_start_regs[] = {{0x10, 0, 7}, {0x07, 2, 2}, {0x07, 7, 7}, {0x40, 4, 4}, VGA_REGSET_END};
  73. static const struct vga_regset ark_v_sync_end_regs[] = {{0x11, 0, 3}, VGA_REGSET_END};
  74. static const struct vga_regset ark_line_compare_regs[] = {{0x18, 0, 7}, {0x07, 4, 4}, {0x09, 6, 6}, VGA_REGSET_END};
  75. static const struct vga_regset ark_start_address_regs[] = {{0x0d, 0, 7}, {0x0c, 0, 7}, {0x40, 0, 2}, VGA_REGSET_END};
  76. static const struct vga_regset ark_offset_regs[] = {{0x13, 0, 7}, {0x41, 3, 3}, VGA_REGSET_END};
  77. static const struct svga_timing_regs ark_timing_regs = {
  78. ark_h_total_regs, ark_h_display_regs, ark_h_blank_start_regs,
  79. ark_h_blank_end_regs, ark_h_sync_start_regs, ark_h_sync_end_regs,
  80. ark_v_total_regs, ark_v_display_regs, ark_v_blank_start_regs,
  81. ark_v_blank_end_regs, ark_v_sync_start_regs, ark_v_sync_end_regs,
  82. };
  83. /* ------------------------------------------------------------------------- */
  84. /* Module parameters */
  85. static char *mode = "640x480-8@60";
  86. #ifdef CONFIG_MTRR
  87. static int mtrr = 1;
  88. #endif
  89. MODULE_AUTHOR("(c) 2007 Ondrej Zajicek <santiago@crfreenet.org>");
  90. MODULE_LICENSE("GPL");
  91. MODULE_DESCRIPTION("fbdev driver for ARK 2000PV");
  92. module_param(mode, charp, 0444);
  93. MODULE_PARM_DESC(mode, "Default video mode ('640x480-8@60', etc)");
  94. #ifdef CONFIG_MTRR
  95. module_param(mtrr, int, 0444);
  96. MODULE_PARM_DESC(mtrr, "Enable write-combining with MTRR (1=enable, 0=disable, default=1)");
  97. #endif
  98. static int threshold = 4;
  99. module_param(threshold, int, 0644);
  100. MODULE_PARM_DESC(threshold, "FIFO threshold");
  101. /* ------------------------------------------------------------------------- */
  102. static void arkfb_settile(struct fb_info *info, struct fb_tilemap *map)
  103. {
  104. const u8 *font = map->data;
  105. u8 __iomem *fb = (u8 __iomem *)info->screen_base;
  106. int i, c;
  107. if ((map->width != 8) || (map->height != 16) ||
  108. (map->depth != 1) || (map->length != 256)) {
  109. printk(KERN_ERR "fb%d: unsupported font parameters: width %d, "
  110. "height %d, depth %d, length %d\n", info->node,
  111. map->width, map->height, map->depth, map->length);
  112. return;
  113. }
  114. fb += 2;
  115. for (c = 0; c < map->length; c++) {
  116. for (i = 0; i < map->height; i++) {
  117. fb_writeb(font[i], &fb[i * 4]);
  118. fb_writeb(font[i], &fb[i * 4 + (128 * 8)]);
  119. }
  120. fb += 128;
  121. if ((c % 8) == 7)
  122. fb += 128*8;
  123. font += map->height;
  124. }
  125. }
  126. static struct fb_tile_ops arkfb_tile_ops = {
  127. .fb_settile = arkfb_settile,
  128. .fb_tilecopy = svga_tilecopy,
  129. .fb_tilefill = svga_tilefill,
  130. .fb_tileblit = svga_tileblit,
  131. .fb_tilecursor = svga_tilecursor,
  132. .fb_get_tilemax = svga_get_tilemax,
  133. };
  134. /* ------------------------------------------------------------------------- */
  135. /* image data is MSB-first, fb structure is MSB-first too */
  136. static inline u32 expand_color(u32 c)
  137. {
  138. return ((c & 1) | ((c & 2) << 7) | ((c & 4) << 14) | ((c & 8) << 21)) * 0xFF;
  139. }
  140. /* arkfb_iplan_imageblit silently assumes that almost everything is 8-pixel aligned */
  141. static void arkfb_iplan_imageblit(struct fb_info *info, const struct fb_image *image)
  142. {
  143. u32 fg = expand_color(image->fg_color);
  144. u32 bg = expand_color(image->bg_color);
  145. const u8 *src1, *src;
  146. u8 __iomem *dst1;
  147. u32 __iomem *dst;
  148. u32 val;
  149. int x, y;
  150. src1 = image->data;
  151. dst1 = info->screen_base + (image->dy * info->fix.line_length)
  152. + ((image->dx / 8) * 4);
  153. for (y = 0; y < image->height; y++) {
  154. src = src1;
  155. dst = (u32 __iomem *) dst1;
  156. for (x = 0; x < image->width; x += 8) {
  157. val = *(src++) * 0x01010101;
  158. val = (val & fg) | (~val & bg);
  159. fb_writel(val, dst++);
  160. }
  161. src1 += image->width / 8;
  162. dst1 += info->fix.line_length;
  163. }
  164. }
  165. /* arkfb_iplan_fillrect silently assumes that almost everything is 8-pixel aligned */
  166. static void arkfb_iplan_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  167. {
  168. u32 fg = expand_color(rect->color);
  169. u8 __iomem *dst1;
  170. u32 __iomem *dst;
  171. int x, y;
  172. dst1 = info->screen_base + (rect->dy * info->fix.line_length)
  173. + ((rect->dx / 8) * 4);
  174. for (y = 0; y < rect->height; y++) {
  175. dst = (u32 __iomem *) dst1;
  176. for (x = 0; x < rect->width; x += 8) {
  177. fb_writel(fg, dst++);
  178. }
  179. dst1 += info->fix.line_length;
  180. }
  181. }
  182. /* image data is MSB-first, fb structure is high-nibble-in-low-byte-first */
  183. static inline u32 expand_pixel(u32 c)
  184. {
  185. return (((c & 1) << 24) | ((c & 2) << 27) | ((c & 4) << 14) | ((c & 8) << 17) |
  186. ((c & 16) << 4) | ((c & 32) << 7) | ((c & 64) >> 6) | ((c & 128) >> 3)) * 0xF;
  187. }
  188. /* arkfb_cfb4_imageblit silently assumes that almost everything is 8-pixel aligned */
  189. static void arkfb_cfb4_imageblit(struct fb_info *info, const struct fb_image *image)
  190. {
  191. u32 fg = image->fg_color * 0x11111111;
  192. u32 bg = image->bg_color * 0x11111111;
  193. const u8 *src1, *src;
  194. u8 __iomem *dst1;
  195. u32 __iomem *dst;
  196. u32 val;
  197. int x, y;
  198. src1 = image->data;
  199. dst1 = info->screen_base + (image->dy * info->fix.line_length)
  200. + ((image->dx / 8) * 4);
  201. for (y = 0; y < image->height; y++) {
  202. src = src1;
  203. dst = (u32 __iomem *) dst1;
  204. for (x = 0; x < image->width; x += 8) {
  205. val = expand_pixel(*(src++));
  206. val = (val & fg) | (~val & bg);
  207. fb_writel(val, dst++);
  208. }
  209. src1 += image->width / 8;
  210. dst1 += info->fix.line_length;
  211. }
  212. }
  213. static void arkfb_imageblit(struct fb_info *info, const struct fb_image *image)
  214. {
  215. if ((info->var.bits_per_pixel == 4) && (image->depth == 1)
  216. && ((image->width % 8) == 0) && ((image->dx % 8) == 0)) {
  217. if (info->fix.type == FB_TYPE_INTERLEAVED_PLANES)
  218. arkfb_iplan_imageblit(info, image);
  219. else
  220. arkfb_cfb4_imageblit(info, image);
  221. } else
  222. cfb_imageblit(info, image);
  223. }
  224. static void arkfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
  225. {
  226. if ((info->var.bits_per_pixel == 4)
  227. && ((rect->width % 8) == 0) && ((rect->dx % 8) == 0)
  228. && (info->fix.type == FB_TYPE_INTERLEAVED_PLANES))
  229. arkfb_iplan_fillrect(info, rect);
  230. else
  231. cfb_fillrect(info, rect);
  232. }
  233. /* ------------------------------------------------------------------------- */
  234. enum
  235. {
  236. DAC_PSEUDO8_8,
  237. DAC_RGB1555_8,
  238. DAC_RGB0565_8,
  239. DAC_RGB0888_8,
  240. DAC_RGB8888_8,
  241. DAC_PSEUDO8_16,
  242. DAC_RGB1555_16,
  243. DAC_RGB0565_16,
  244. DAC_RGB0888_16,
  245. DAC_RGB8888_16,
  246. DAC_MAX
  247. };
  248. struct dac_ops {
  249. int (*dac_get_mode)(struct dac_info *info);
  250. int (*dac_set_mode)(struct dac_info *info, int mode);
  251. int (*dac_get_freq)(struct dac_info *info, int channel);
  252. int (*dac_set_freq)(struct dac_info *info, int channel, u32 freq);
  253. void (*dac_release)(struct dac_info *info);
  254. };
  255. typedef void (*dac_read_regs_t)(void *data, u8 *code, int count);
  256. typedef void (*dac_write_regs_t)(void *data, u8 *code, int count);
  257. struct dac_info
  258. {
  259. struct dac_ops *dacops;
  260. dac_read_regs_t dac_read_regs;
  261. dac_write_regs_t dac_write_regs;
  262. void *data;
  263. };
  264. static inline u8 dac_read_reg(struct dac_info *info, u8 reg)
  265. {
  266. u8 code[2] = {reg, 0};
  267. info->dac_read_regs(info->data, code, 1);
  268. return code[1];
  269. }
  270. static inline void dac_read_regs(struct dac_info *info, u8 *code, int count)
  271. {
  272. info->dac_read_regs(info->data, code, count);
  273. }
  274. static inline void dac_write_reg(struct dac_info *info, u8 reg, u8 val)
  275. {
  276. u8 code[2] = {reg, val};
  277. info->dac_write_regs(info->data, code, 1);
  278. }
  279. static inline void dac_write_regs(struct dac_info *info, u8 *code, int count)
  280. {
  281. info->dac_write_regs(info->data, code, count);
  282. }
  283. static inline int dac_set_mode(struct dac_info *info, int mode)
  284. {
  285. return info->dacops->dac_set_mode(info, mode);
  286. }
  287. static inline int dac_set_freq(struct dac_info *info, int channel, u32 freq)
  288. {
  289. return info->dacops->dac_set_freq(info, channel, freq);
  290. }
  291. static inline void dac_release(struct dac_info *info)
  292. {
  293. info->dacops->dac_release(info);
  294. }
  295. /* ------------------------------------------------------------------------- */
  296. /* ICS5342 DAC */
  297. struct ics5342_info
  298. {
  299. struct dac_info dac;
  300. u8 mode;
  301. };
  302. #define DAC_PAR(info) ((struct ics5342_info *) info)
  303. /* LSB is set to distinguish unused slots */
  304. static const u8 ics5342_mode_table[DAC_MAX] = {
  305. [DAC_PSEUDO8_8] = 0x01, [DAC_RGB1555_8] = 0x21, [DAC_RGB0565_8] = 0x61,
  306. [DAC_RGB0888_8] = 0x41, [DAC_PSEUDO8_16] = 0x11, [DAC_RGB1555_16] = 0x31,
  307. [DAC_RGB0565_16] = 0x51, [DAC_RGB0888_16] = 0x91, [DAC_RGB8888_16] = 0x71
  308. };
  309. static int ics5342_set_mode(struct dac_info *info, int mode)
  310. {
  311. u8 code;
  312. if (mode >= DAC_MAX)
  313. return -EINVAL;
  314. code = ics5342_mode_table[mode];
  315. if (! code)
  316. return -EINVAL;
  317. dac_write_reg(info, 6, code & 0xF0);
  318. DAC_PAR(info)->mode = mode;
  319. return 0;
  320. }
  321. static const struct svga_pll ics5342_pll = {3, 129, 3, 33, 0, 3,
  322. 60000, 250000, 14318};
  323. /* pd4 - allow only posdivider 4 (r=2) */
  324. static const struct svga_pll ics5342_pll_pd4 = {3, 129, 3, 33, 2, 2,
  325. 60000, 335000, 14318};
  326. /* 270 MHz should be upper bound for VCO clock according to specs,
  327. but that is too restrictive in pd4 case */
  328. static int ics5342_set_freq(struct dac_info *info, int channel, u32 freq)
  329. {
  330. u16 m, n, r;
  331. /* only postdivider 4 (r=2) is valid in mode DAC_PSEUDO8_16 */
  332. int rv = svga_compute_pll((DAC_PAR(info)->mode == DAC_PSEUDO8_16)
  333. ? &ics5342_pll_pd4 : &ics5342_pll,
  334. freq, &m, &n, &r, 0);
  335. if (rv < 0) {
  336. return -EINVAL;
  337. } else {
  338. u8 code[6] = {4, 3, 5, m-2, 5, (n-2) | (r << 5)};
  339. dac_write_regs(info, code, 3);
  340. return 0;
  341. }
  342. }
  343. static void ics5342_release(struct dac_info *info)
  344. {
  345. ics5342_set_mode(info, DAC_PSEUDO8_8);
  346. kfree(info);
  347. }
  348. static struct dac_ops ics5342_ops = {
  349. .dac_set_mode = ics5342_set_mode,
  350. .dac_set_freq = ics5342_set_freq,
  351. .dac_release = ics5342_release
  352. };
  353. static struct dac_info * ics5342_init(dac_read_regs_t drr, dac_write_regs_t dwr, void *data)
  354. {
  355. struct dac_info *info = kzalloc(sizeof(struct ics5342_info), GFP_KERNEL);
  356. if (! info)
  357. return NULL;
  358. info->dacops = &ics5342_ops;
  359. info->dac_read_regs = drr;
  360. info->dac_write_regs = dwr;
  361. info->data = data;
  362. DAC_PAR(info)->mode = DAC_PSEUDO8_8; /* estimation */
  363. return info;
  364. }
  365. /* ------------------------------------------------------------------------- */
  366. static unsigned short dac_regs[4] = {0x3c8, 0x3c9, 0x3c6, 0x3c7};
  367. static void ark_dac_read_regs(void *data, u8 *code, int count)
  368. {
  369. u8 regval = vga_rseq(NULL, 0x1C);
  370. while (count != 0)
  371. {
  372. vga_wseq(NULL, 0x1C, regval | (code[0] & 4) ? 0x80 : 0);
  373. code[1] = vga_r(NULL, dac_regs[code[0] & 3]);
  374. count--;
  375. code += 2;
  376. }
  377. vga_wseq(NULL, 0x1C, regval);
  378. }
  379. static void ark_dac_write_regs(void *data, u8 *code, int count)
  380. {
  381. u8 regval = vga_rseq(NULL, 0x1C);
  382. while (count != 0)
  383. {
  384. vga_wseq(NULL, 0x1C, regval | (code[0] & 4) ? 0x80 : 0);
  385. vga_w(NULL, dac_regs[code[0] & 3], code[1]);
  386. count--;
  387. code += 2;
  388. }
  389. vga_wseq(NULL, 0x1C, regval);
  390. }
  391. static void ark_set_pixclock(struct fb_info *info, u32 pixclock)
  392. {
  393. struct arkfb_info *par = info->par;
  394. u8 regval;
  395. int rv = dac_set_freq(par->dac, 0, 1000000000 / pixclock);
  396. if (rv < 0) {
  397. printk(KERN_ERR "fb%d: cannot set requested pixclock, keeping old value\n", info->node);
  398. return;
  399. }
  400. /* Set VGA misc register */
  401. regval = vga_r(NULL, VGA_MIS_R);
  402. vga_w(NULL, VGA_MIS_W, regval | VGA_MIS_ENB_PLL_LOAD);
  403. }
  404. /* Open framebuffer */
  405. static int arkfb_open(struct fb_info *info, int user)
  406. {
  407. struct arkfb_info *par = info->par;
  408. mutex_lock(&(par->open_lock));
  409. if (par->ref_count == 0) {
  410. memset(&(par->state), 0, sizeof(struct vgastate));
  411. par->state.flags = VGA_SAVE_MODE | VGA_SAVE_FONTS | VGA_SAVE_CMAP;
  412. par->state.num_crtc = 0x60;
  413. par->state.num_seq = 0x30;
  414. save_vga(&(par->state));
  415. }
  416. par->ref_count++;
  417. mutex_unlock(&(par->open_lock));
  418. return 0;
  419. }
  420. /* Close framebuffer */
  421. static int arkfb_release(struct fb_info *info, int user)
  422. {
  423. struct arkfb_info *par = info->par;
  424. mutex_lock(&(par->open_lock));
  425. if (par->ref_count == 0) {
  426. mutex_unlock(&(par->open_lock));
  427. return -EINVAL;
  428. }
  429. if (par->ref_count == 1) {
  430. restore_vga(&(par->state));
  431. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  432. }
  433. par->ref_count--;
  434. mutex_unlock(&(par->open_lock));
  435. return 0;
  436. }
  437. /* Validate passed in var */
  438. static int arkfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
  439. {
  440. int rv, mem, step;
  441. /* Find appropriate format */
  442. rv = svga_match_format (arkfb_formats, var, NULL);
  443. if (rv < 0)
  444. {
  445. printk(KERN_ERR "fb%d: unsupported mode requested\n", info->node);
  446. return rv;
  447. }
  448. /* Do not allow to have real resoulution larger than virtual */
  449. if (var->xres > var->xres_virtual)
  450. var->xres_virtual = var->xres;
  451. if (var->yres > var->yres_virtual)
  452. var->yres_virtual = var->yres;
  453. /* Round up xres_virtual to have proper alignment of lines */
  454. step = arkfb_formats[rv].xresstep - 1;
  455. var->xres_virtual = (var->xres_virtual+step) & ~step;
  456. /* Check whether have enough memory */
  457. mem = ((var->bits_per_pixel * var->xres_virtual) >> 3) * var->yres_virtual;
  458. if (mem > info->screen_size)
  459. {
  460. printk(KERN_ERR "fb%d: not enough framebuffer memory (%d kB requested , %d kB available)\n", info->node, mem >> 10, (unsigned int) (info->screen_size >> 10));
  461. return -EINVAL;
  462. }
  463. rv = svga_check_timings (&ark_timing_regs, var, info->node);
  464. if (rv < 0)
  465. {
  466. printk(KERN_ERR "fb%d: invalid timings requested\n", info->node);
  467. return rv;
  468. }
  469. /* Interlaced mode is broken */
  470. if (var->vmode & FB_VMODE_INTERLACED)
  471. return -EINVAL;
  472. return 0;
  473. }
  474. /* Set video mode from par */
  475. static int arkfb_set_par(struct fb_info *info)
  476. {
  477. struct arkfb_info *par = info->par;
  478. u32 value, mode, hmul, hdiv, offset_value, screen_size;
  479. u32 bpp = info->var.bits_per_pixel;
  480. u8 regval;
  481. if (bpp != 0) {
  482. info->fix.ypanstep = 1;
  483. info->fix.line_length = (info->var.xres_virtual * bpp) / 8;
  484. info->flags &= ~FBINFO_MISC_TILEBLITTING;
  485. info->tileops = NULL;
  486. /* in 4bpp supports 8p wide tiles only, any tiles otherwise */
  487. info->pixmap.blit_x = (bpp == 4) ? (1 << (8 - 1)) : (~(u32)0);
  488. info->pixmap.blit_y = ~(u32)0;
  489. offset_value = (info->var.xres_virtual * bpp) / 64;
  490. screen_size = info->var.yres_virtual * info->fix.line_length;
  491. } else {
  492. info->fix.ypanstep = 16;
  493. info->fix.line_length = 0;
  494. info->flags |= FBINFO_MISC_TILEBLITTING;
  495. info->tileops = &arkfb_tile_ops;
  496. /* supports 8x16 tiles only */
  497. info->pixmap.blit_x = 1 << (8 - 1);
  498. info->pixmap.blit_y = 1 << (16 - 1);
  499. offset_value = info->var.xres_virtual / 16;
  500. screen_size = (info->var.xres_virtual * info->var.yres_virtual) / 64;
  501. }
  502. info->var.xoffset = 0;
  503. info->var.yoffset = 0;
  504. info->var.activate = FB_ACTIVATE_NOW;
  505. /* Unlock registers */
  506. svga_wcrt_mask(0x11, 0x00, 0x80);
  507. /* Blank screen and turn off sync */
  508. svga_wseq_mask(0x01, 0x20, 0x20);
  509. svga_wcrt_mask(0x17, 0x00, 0x80);
  510. /* Set default values */
  511. svga_set_default_gfx_regs();
  512. svga_set_default_atc_regs();
  513. svga_set_default_seq_regs();
  514. svga_set_default_crt_regs();
  515. svga_wcrt_multi(ark_line_compare_regs, 0xFFFFFFFF);
  516. svga_wcrt_multi(ark_start_address_regs, 0);
  517. /* ARK specific initialization */
  518. svga_wseq_mask(0x10, 0x1F, 0x1F); /* enable linear framebuffer and full memory access */
  519. svga_wseq_mask(0x12, 0x03, 0x03); /* 4 MB linear framebuffer size */
  520. vga_wseq(NULL, 0x13, info->fix.smem_start >> 16);
  521. vga_wseq(NULL, 0x14, info->fix.smem_start >> 24);
  522. vga_wseq(NULL, 0x15, 0);
  523. vga_wseq(NULL, 0x16, 0);
  524. /* Set the FIFO threshold register */
  525. /* It is fascinating way to store 5-bit value in 8-bit register */
  526. regval = 0x10 | ((threshold & 0x0E) >> 1) | (threshold & 0x01) << 7 | (threshold & 0x10) << 1;
  527. vga_wseq(NULL, 0x18, regval);
  528. /* Set the offset register */
  529. pr_debug("fb%d: offset register : %d\n", info->node, offset_value);
  530. svga_wcrt_multi(ark_offset_regs, offset_value);
  531. /* fix for hi-res textmode */
  532. svga_wcrt_mask(0x40, 0x08, 0x08);
  533. if (info->var.vmode & FB_VMODE_DOUBLE)
  534. svga_wcrt_mask(0x09, 0x80, 0x80);
  535. else
  536. svga_wcrt_mask(0x09, 0x00, 0x80);
  537. if (info->var.vmode & FB_VMODE_INTERLACED)
  538. svga_wcrt_mask(0x44, 0x04, 0x04);
  539. else
  540. svga_wcrt_mask(0x44, 0x00, 0x04);
  541. hmul = 1;
  542. hdiv = 1;
  543. mode = svga_match_format(arkfb_formats, &(info->var), &(info->fix));
  544. /* Set mode-specific register values */
  545. switch (mode) {
  546. case 0:
  547. pr_debug("fb%d: text mode\n", info->node);
  548. svga_set_textmode_vga_regs();
  549. vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */
  550. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  551. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  552. break;
  553. case 1:
  554. pr_debug("fb%d: 4 bit pseudocolor\n", info->node);
  555. vga_wgfx(NULL, VGA_GFX_MODE, 0x40);
  556. vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */
  557. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  558. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  559. break;
  560. case 2:
  561. pr_debug("fb%d: 4 bit pseudocolor, planar\n", info->node);
  562. vga_wseq(NULL, 0x11, 0x10); /* basic VGA mode */
  563. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  564. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  565. break;
  566. case 3:
  567. pr_debug("fb%d: 8 bit pseudocolor\n", info->node);
  568. vga_wseq(NULL, 0x11, 0x16); /* 8bpp accel mode */
  569. if (info->var.pixclock > 20000) {
  570. pr_debug("fb%d: not using multiplex\n", info->node);
  571. svga_wcrt_mask(0x46, 0x00, 0x04); /* 8bit pixel path */
  572. dac_set_mode(par->dac, DAC_PSEUDO8_8);
  573. } else {
  574. pr_debug("fb%d: using multiplex\n", info->node);
  575. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  576. dac_set_mode(par->dac, DAC_PSEUDO8_16);
  577. hdiv = 2;
  578. }
  579. break;
  580. case 4:
  581. pr_debug("fb%d: 5/5/5 truecolor\n", info->node);
  582. vga_wseq(NULL, 0x11, 0x1A); /* 16bpp accel mode */
  583. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  584. dac_set_mode(par->dac, DAC_RGB1555_16);
  585. break;
  586. case 5:
  587. pr_debug("fb%d: 5/6/5 truecolor\n", info->node);
  588. vga_wseq(NULL, 0x11, 0x1A); /* 16bpp accel mode */
  589. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  590. dac_set_mode(par->dac, DAC_RGB0565_16);
  591. break;
  592. case 6:
  593. pr_debug("fb%d: 8/8/8 truecolor\n", info->node);
  594. vga_wseq(NULL, 0x11, 0x16); /* 8bpp accel mode ??? */
  595. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  596. dac_set_mode(par->dac, DAC_RGB0888_16);
  597. hmul = 3;
  598. hdiv = 2;
  599. break;
  600. case 7:
  601. pr_debug("fb%d: 8/8/8/8 truecolor\n", info->node);
  602. vga_wseq(NULL, 0x11, 0x1E); /* 32bpp accel mode */
  603. svga_wcrt_mask(0x46, 0x04, 0x04); /* 16bit pixel path */
  604. dac_set_mode(par->dac, DAC_RGB8888_16);
  605. hmul = 2;
  606. break;
  607. default:
  608. printk(KERN_ERR "fb%d: unsupported mode - bug\n", info->node);
  609. return -EINVAL;
  610. }
  611. ark_set_pixclock(info, (hdiv * info->var.pixclock) / hmul);
  612. svga_set_timings(&ark_timing_regs, &(info->var), hmul, hdiv,
  613. (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1,
  614. (info->var.vmode & FB_VMODE_INTERLACED) ? 2 : 1,
  615. hmul, info->node);
  616. /* Set interlaced mode start/end register */
  617. value = info->var.xres + info->var.left_margin + info->var.right_margin + info->var.hsync_len;
  618. value = ((value * hmul / hdiv) / 8) - 5;
  619. vga_wcrt(NULL, 0x42, (value + 1) / 2);
  620. memset_io(info->screen_base, 0x00, screen_size);
  621. /* Device and screen back on */
  622. svga_wcrt_mask(0x17, 0x80, 0x80);
  623. svga_wseq_mask(0x01, 0x00, 0x20);
  624. return 0;
  625. }
  626. /* Set a colour register */
  627. static int arkfb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
  628. u_int transp, struct fb_info *fb)
  629. {
  630. switch (fb->var.bits_per_pixel) {
  631. case 0:
  632. case 4:
  633. if (regno >= 16)
  634. return -EINVAL;
  635. if ((fb->var.bits_per_pixel == 4) &&
  636. (fb->var.nonstd == 0)) {
  637. outb(0xF0, VGA_PEL_MSK);
  638. outb(regno*16, VGA_PEL_IW);
  639. } else {
  640. outb(0x0F, VGA_PEL_MSK);
  641. outb(regno, VGA_PEL_IW);
  642. }
  643. outb(red >> 10, VGA_PEL_D);
  644. outb(green >> 10, VGA_PEL_D);
  645. outb(blue >> 10, VGA_PEL_D);
  646. break;
  647. case 8:
  648. if (regno >= 256)
  649. return -EINVAL;
  650. outb(0xFF, VGA_PEL_MSK);
  651. outb(regno, VGA_PEL_IW);
  652. outb(red >> 10, VGA_PEL_D);
  653. outb(green >> 10, VGA_PEL_D);
  654. outb(blue >> 10, VGA_PEL_D);
  655. break;
  656. case 16:
  657. if (regno >= 16)
  658. return 0;
  659. if (fb->var.green.length == 5)
  660. ((u32*)fb->pseudo_palette)[regno] = ((red & 0xF800) >> 1) |
  661. ((green & 0xF800) >> 6) | ((blue & 0xF800) >> 11);
  662. else if (fb->var.green.length == 6)
  663. ((u32*)fb->pseudo_palette)[regno] = (red & 0xF800) |
  664. ((green & 0xFC00) >> 5) | ((blue & 0xF800) >> 11);
  665. else
  666. return -EINVAL;
  667. break;
  668. case 24:
  669. case 32:
  670. if (regno >= 16)
  671. return 0;
  672. ((u32*)fb->pseudo_palette)[regno] = ((red & 0xFF00) << 8) |
  673. (green & 0xFF00) | ((blue & 0xFF00) >> 8);
  674. break;
  675. default:
  676. return -EINVAL;
  677. }
  678. return 0;
  679. }
  680. /* Set the display blanking state */
  681. static int arkfb_blank(int blank_mode, struct fb_info *info)
  682. {
  683. switch (blank_mode) {
  684. case FB_BLANK_UNBLANK:
  685. pr_debug("fb%d: unblank\n", info->node);
  686. svga_wseq_mask(0x01, 0x00, 0x20);
  687. svga_wcrt_mask(0x17, 0x80, 0x80);
  688. break;
  689. case FB_BLANK_NORMAL:
  690. pr_debug("fb%d: blank\n", info->node);
  691. svga_wseq_mask(0x01, 0x20, 0x20);
  692. svga_wcrt_mask(0x17, 0x80, 0x80);
  693. break;
  694. case FB_BLANK_POWERDOWN:
  695. case FB_BLANK_HSYNC_SUSPEND:
  696. case FB_BLANK_VSYNC_SUSPEND:
  697. pr_debug("fb%d: sync down\n", info->node);
  698. svga_wseq_mask(0x01, 0x20, 0x20);
  699. svga_wcrt_mask(0x17, 0x00, 0x80);
  700. break;
  701. }
  702. return 0;
  703. }
  704. /* Pan the display */
  705. static int arkfb_pan_display(struct fb_var_screeninfo *var, struct fb_info *info)
  706. {
  707. unsigned int offset;
  708. /* Calculate the offset */
  709. if (var->bits_per_pixel == 0) {
  710. offset = (var->yoffset / 16) * (var->xres_virtual / 2) + (var->xoffset / 2);
  711. offset = offset >> 2;
  712. } else {
  713. offset = (var->yoffset * info->fix.line_length) +
  714. (var->xoffset * var->bits_per_pixel / 8);
  715. offset = offset >> ((var->bits_per_pixel == 4) ? 2 : 3);
  716. }
  717. /* Set the offset */
  718. svga_wcrt_multi(ark_start_address_regs, offset);
  719. return 0;
  720. }
  721. /* ------------------------------------------------------------------------- */
  722. /* Frame buffer operations */
  723. static struct fb_ops arkfb_ops = {
  724. .owner = THIS_MODULE,
  725. .fb_open = arkfb_open,
  726. .fb_release = arkfb_release,
  727. .fb_check_var = arkfb_check_var,
  728. .fb_set_par = arkfb_set_par,
  729. .fb_setcolreg = arkfb_setcolreg,
  730. .fb_blank = arkfb_blank,
  731. .fb_pan_display = arkfb_pan_display,
  732. .fb_fillrect = arkfb_fillrect,
  733. .fb_copyarea = cfb_copyarea,
  734. .fb_imageblit = arkfb_imageblit,
  735. };
  736. /* ------------------------------------------------------------------------- */
  737. /* PCI probe */
  738. static int __devinit ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
  739. {
  740. struct fb_info *info;
  741. struct arkfb_info *par;
  742. int rc;
  743. u8 regval;
  744. /* Ignore secondary VGA device because there is no VGA arbitration */
  745. if (! svga_primary_device(dev)) {
  746. dev_info(&(dev->dev), "ignoring secondary device\n");
  747. return -ENODEV;
  748. }
  749. /* Allocate and fill driver data structure */
  750. info = framebuffer_alloc(sizeof(struct arkfb_info), NULL);
  751. if (! info) {
  752. dev_err(&(dev->dev), "cannot allocate memory\n");
  753. return -ENOMEM;
  754. }
  755. par = info->par;
  756. mutex_init(&par->open_lock);
  757. info->flags = FBINFO_PARTIAL_PAN_OK | FBINFO_HWACCEL_YPAN;
  758. info->fbops = &arkfb_ops;
  759. /* Prepare PCI device */
  760. rc = pci_enable_device(dev);
  761. if (rc < 0) {
  762. dev_err(&(dev->dev), "cannot enable PCI device\n");
  763. goto err_enable_device;
  764. }
  765. rc = pci_request_regions(dev, "arkfb");
  766. if (rc < 0) {
  767. dev_err(&(dev->dev), "cannot reserve framebuffer region\n");
  768. goto err_request_regions;
  769. }
  770. par->dac = ics5342_init(ark_dac_read_regs, ark_dac_write_regs, info);
  771. if (! par->dac) {
  772. rc = -ENOMEM;
  773. dev_err(&(dev->dev), "RAMDAC initialization failed\n");
  774. goto err_dac;
  775. }
  776. info->fix.smem_start = pci_resource_start(dev, 0);
  777. info->fix.smem_len = pci_resource_len(dev, 0);
  778. /* Map physical IO memory address into kernel space */
  779. info->screen_base = pci_iomap(dev, 0, 0);
  780. if (! info->screen_base) {
  781. rc = -ENOMEM;
  782. dev_err(&(dev->dev), "iomap for framebuffer failed\n");
  783. goto err_iomap;
  784. }
  785. /* FIXME get memsize */
  786. regval = vga_rseq(NULL, 0x10);
  787. info->screen_size = (1 << (regval >> 6)) << 20;
  788. info->fix.smem_len = info->screen_size;
  789. strcpy(info->fix.id, "ARK 2000PV");
  790. info->fix.mmio_start = 0;
  791. info->fix.mmio_len = 0;
  792. info->fix.type = FB_TYPE_PACKED_PIXELS;
  793. info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
  794. info->fix.ypanstep = 0;
  795. info->fix.accel = FB_ACCEL_NONE;
  796. info->pseudo_palette = (void*) (par->pseudo_palette);
  797. /* Prepare startup mode */
  798. rc = fb_find_mode(&(info->var), info, mode, NULL, 0, NULL, 8);
  799. if (! ((rc == 1) || (rc == 2))) {
  800. rc = -EINVAL;
  801. dev_err(&(dev->dev), "mode %s not found\n", mode);
  802. goto err_find_mode;
  803. }
  804. rc = fb_alloc_cmap(&info->cmap, 256, 0);
  805. if (rc < 0) {
  806. dev_err(&(dev->dev), "cannot allocate colormap\n");
  807. goto err_alloc_cmap;
  808. }
  809. rc = register_framebuffer(info);
  810. if (rc < 0) {
  811. dev_err(&(dev->dev), "cannot register framebugger\n");
  812. goto err_reg_fb;
  813. }
  814. printk(KERN_INFO "fb%d: %s on %s, %d MB RAM\n", info->node, info->fix.id,
  815. pci_name(dev), info->fix.smem_len >> 20);
  816. /* Record a reference to the driver data */
  817. pci_set_drvdata(dev, info);
  818. #ifdef CONFIG_MTRR
  819. if (mtrr) {
  820. par->mtrr_reg = -1;
  821. par->mtrr_reg = mtrr_add(info->fix.smem_start, info->fix.smem_len, MTRR_TYPE_WRCOMB, 1);
  822. }
  823. #endif
  824. return 0;
  825. /* Error handling */
  826. err_reg_fb:
  827. fb_dealloc_cmap(&info->cmap);
  828. err_alloc_cmap:
  829. err_find_mode:
  830. pci_iounmap(dev, info->screen_base);
  831. err_iomap:
  832. dac_release(par->dac);
  833. err_dac:
  834. pci_release_regions(dev);
  835. err_request_regions:
  836. /* pci_disable_device(dev); */
  837. err_enable_device:
  838. framebuffer_release(info);
  839. return rc;
  840. }
  841. /* PCI remove */
  842. static void __devexit ark_pci_remove(struct pci_dev *dev)
  843. {
  844. struct fb_info *info = pci_get_drvdata(dev);
  845. struct arkfb_info *par = info->par;
  846. if (info) {
  847. #ifdef CONFIG_MTRR
  848. if (par->mtrr_reg >= 0) {
  849. mtrr_del(par->mtrr_reg, 0, 0);
  850. par->mtrr_reg = -1;
  851. }
  852. #endif
  853. dac_release(par->dac);
  854. unregister_framebuffer(info);
  855. fb_dealloc_cmap(&info->cmap);
  856. pci_iounmap(dev, info->screen_base);
  857. pci_release_regions(dev);
  858. /* pci_disable_device(dev); */
  859. pci_set_drvdata(dev, NULL);
  860. framebuffer_release(info);
  861. }
  862. }
  863. #ifdef CONFIG_PM
  864. /* PCI suspend */
  865. static int ark_pci_suspend (struct pci_dev* dev, pm_message_t state)
  866. {
  867. struct fb_info *info = pci_get_drvdata(dev);
  868. struct arkfb_info *par = info->par;
  869. dev_info(&(dev->dev), "suspend\n");
  870. acquire_console_sem();
  871. mutex_lock(&(par->open_lock));
  872. if ((state.event == PM_EVENT_FREEZE) || (par->ref_count == 0)) {
  873. mutex_unlock(&(par->open_lock));
  874. release_console_sem();
  875. return 0;
  876. }
  877. fb_set_suspend(info, 1);
  878. pci_save_state(dev);
  879. pci_disable_device(dev);
  880. pci_set_power_state(dev, pci_choose_state(dev, state));
  881. mutex_unlock(&(par->open_lock));
  882. release_console_sem();
  883. return 0;
  884. }
  885. /* PCI resume */
  886. static int ark_pci_resume (struct pci_dev* dev)
  887. {
  888. struct fb_info *info = pci_get_drvdata(dev);
  889. struct arkfb_info *par = info->par;
  890. dev_info(&(dev->dev), "resume\n");
  891. acquire_console_sem();
  892. mutex_lock(&(par->open_lock));
  893. if (par->ref_count == 0) {
  894. mutex_unlock(&(par->open_lock));
  895. release_console_sem();
  896. return 0;
  897. }
  898. pci_set_power_state(dev, PCI_D0);
  899. pci_restore_state(dev);
  900. if (pci_enable_device(dev))
  901. goto fail;
  902. pci_set_master(dev);
  903. arkfb_set_par(info);
  904. fb_set_suspend(info, 0);
  905. mutex_unlock(&(par->open_lock));
  906. fail:
  907. release_console_sem();
  908. return 0;
  909. }
  910. #else
  911. #define ark_pci_suspend NULL
  912. #define ark_pci_resume NULL
  913. #endif /* CONFIG_PM */
  914. /* List of boards that we are trying to support */
  915. static struct pci_device_id ark_devices[] __devinitdata = {
  916. {PCI_DEVICE(0xEDD8, 0xA099)},
  917. {0, 0, 0, 0, 0, 0, 0}
  918. };
  919. MODULE_DEVICE_TABLE(pci, ark_devices);
  920. static struct pci_driver arkfb_pci_driver = {
  921. .name = "arkfb",
  922. .id_table = ark_devices,
  923. .probe = ark_pci_probe,
  924. .remove = __devexit_p(ark_pci_remove),
  925. .suspend = ark_pci_suspend,
  926. .resume = ark_pci_resume,
  927. };
  928. /* Cleanup */
  929. static void __exit arkfb_cleanup(void)
  930. {
  931. pr_debug("arkfb: cleaning up\n");
  932. pci_unregister_driver(&arkfb_pci_driver);
  933. }
  934. /* Driver Initialisation */
  935. static int __init arkfb_init(void)
  936. {
  937. #ifndef MODULE
  938. char *option = NULL;
  939. if (fb_get_options("arkfb", &option))
  940. return -ENODEV;
  941. if (option && *option)
  942. mode = option;
  943. #endif
  944. pr_debug("arkfb: initializing\n");
  945. return pci_register_driver(&arkfb_pci_driver);
  946. }
  947. module_init(arkfb_init);
  948. module_exit(arkfb_cleanup);