au1100fb.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /*
  2. * BRIEF MODULE DESCRIPTION
  3. * Au1100 LCD Driver.
  4. *
  5. * Copyright 2002 MontaVista Software
  6. * Author: MontaVista Software, Inc.
  7. * ppopov@mvista.com or source@mvista.com
  8. *
  9. * Copyright 2002 Alchemy Semiconductor
  10. * Author: Alchemy Semiconductor
  11. *
  12. * Based on:
  13. * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device
  14. * Created 28 Dec 1997 by Geert Uytterhoeven
  15. *
  16. * This program is free software; you can redistribute it and/or modify it
  17. * under the terms of the GNU General Public License as published by the
  18. * Free Software Foundation; either version 2 of the License, or (at your
  19. * option) any later version.
  20. *
  21. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  22. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  23. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  24. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  27. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  28. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. * You should have received a copy of the GNU General Public License along
  33. * with this program; if not, write to the Free Software Foundation, Inc.,
  34. * 675 Mass Ave, Cambridge, MA 02139, USA.
  35. */
  36. #include <linux/module.h>
  37. #include <linux/kernel.h>
  38. #include <linux/errno.h>
  39. #include <linux/string.h>
  40. #include <linux/mm.h>
  41. #include <linux/tty.h>
  42. #include <linux/slab.h>
  43. #include <linux/delay.h>
  44. #include <linux/fb.h>
  45. #include <linux/init.h>
  46. #include <linux/pci.h>
  47. #include <asm/au1000.h>
  48. #include <asm/pb1100.h>
  49. #include "au1100fb.h"
  50. #include <video/fbcon.h>
  51. #include <video/fbcon-mfb.h>
  52. #include <video/fbcon-cfb2.h>
  53. #include <video/fbcon-cfb4.h>
  54. #include <video/fbcon-cfb8.h>
  55. #include <video/fbcon-cfb16.h>
  56. /*
  57. * Sanity check. If this is a new Au1100 based board, search for
  58. * the PB1100 ifdefs to make sure you modify the code accordingly.
  59. */
  60. #if defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_DB1100) || defined(CONFIG_MIPS_HYDROGEN3)
  61. #else
  62. error Unknown Au1100 board
  63. #endif
  64. #define CMAPSIZE 16
  65. static int my_lcd_index; /* default is zero */
  66. struct known_lcd_panels *p_lcd;
  67. AU1100_LCD *p_lcd_reg = (AU1100_LCD *)AU1100_LCD_ADDR;
  68. struct au1100fb_info {
  69. struct fb_info_gen gen;
  70. unsigned long fb_virt_start;
  71. unsigned long fb_size;
  72. unsigned long fb_phys;
  73. int mmaped;
  74. int nohwcursor;
  75. struct { unsigned red, green, blue, pad; } palette[256];
  76. #if defined(FBCON_HAS_CFB16)
  77. u16 fbcon_cmap16[16];
  78. #endif
  79. };
  80. struct au1100fb_par {
  81. struct fb_var_screeninfo var;
  82. int line_length; // in bytes
  83. int cmap_len; // color-map length
  84. };
  85. static struct au1100fb_info fb_info;
  86. static struct au1100fb_par current_par;
  87. static struct display disp;
  88. int au1100fb_init(void);
  89. void au1100fb_setup(char *options, int *ints);
  90. static int au1100fb_mmap(struct fb_info *fb, struct file *file,
  91. struct vm_area_struct *vma);
  92. static int au1100_blank(int blank_mode, struct fb_info_gen *info);
  93. static int au1100fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
  94. u_long arg, int con, struct fb_info *info);
  95. void au1100_nocursor(struct display *p, int mode, int xx, int yy){};
  96. static struct fb_ops au1100fb_ops = {
  97. .owner = THIS_MODULE,
  98. .fb_get_fix = fbgen_get_fix,
  99. .fb_get_var = fbgen_get_var,
  100. .fb_set_var = fbgen_set_var,
  101. .fb_get_cmap = fbgen_get_cmap,
  102. .fb_set_cmap = fbgen_set_cmap,
  103. .fb_pan_display = fbgen_pan_display,
  104. .fb_ioctl = au1100fb_ioctl,
  105. .fb_mmap = au1100fb_mmap,
  106. };
  107. static void au1100_detect(void)
  108. {
  109. /*
  110. * This function should detect the current video mode settings
  111. * and store it as the default video mode
  112. */
  113. /*
  114. * Yeh, well, we're not going to change any settings so we're
  115. * always stuck with the default ...
  116. */
  117. }
  118. static int au1100_encode_fix(struct fb_fix_screeninfo *fix,
  119. const void *_par, struct fb_info_gen *_info)
  120. {
  121. struct au1100fb_info *info = (struct au1100fb_info *) _info;
  122. struct au1100fb_par *par = (struct au1100fb_par *) _par;
  123. struct fb_var_screeninfo *var = &par->var;
  124. memset(fix, 0, sizeof(struct fb_fix_screeninfo));
  125. fix->smem_start = info->fb_phys;
  126. fix->smem_len = info->fb_size;
  127. fix->type = FB_TYPE_PACKED_PIXELS;
  128. fix->type_aux = 0;
  129. fix->visual = (var->bits_per_pixel == 8) ?
  130. FB_VISUAL_PSEUDOCOLOR : FB_VISUAL_TRUECOLOR;
  131. fix->ywrapstep = 0;
  132. fix->xpanstep = 1;
  133. fix->ypanstep = 1;
  134. fix->line_length = current_par.line_length;
  135. return 0;
  136. }
  137. static void set_color_bitfields(struct fb_var_screeninfo *var)
  138. {
  139. switch (var->bits_per_pixel) {
  140. case 8:
  141. var->red.offset = 0;
  142. var->red.length = 8;
  143. var->green.offset = 0;
  144. var->green.length = 8;
  145. var->blue.offset = 0;
  146. var->blue.length = 8;
  147. var->transp.offset = 0;
  148. var->transp.length = 0;
  149. break;
  150. case 16: /* RGB 565 */
  151. var->red.offset = 11;
  152. var->red.length = 5;
  153. var->green.offset = 5;
  154. var->green.length = 6;
  155. var->blue.offset = 0;
  156. var->blue.length = 5;
  157. var->transp.offset = 0;
  158. var->transp.length = 0;
  159. break;
  160. }
  161. var->red.msb_right = 0;
  162. var->green.msb_right = 0;
  163. var->blue.msb_right = 0;
  164. var->transp.msb_right = 0;
  165. }
  166. static int au1100_decode_var(const struct fb_var_screeninfo *var,
  167. void *_par, struct fb_info_gen *_info)
  168. {
  169. struct au1100fb_par *par = (struct au1100fb_par *)_par;
  170. /*
  171. * Don't allow setting any of these yet: xres and yres don't
  172. * make sense for LCD panels.
  173. */
  174. if (var->xres != p_lcd->xres ||
  175. var->yres != p_lcd->yres ||
  176. var->xres != p_lcd->xres ||
  177. var->yres != p_lcd->yres) {
  178. return -EINVAL;
  179. }
  180. if(var->bits_per_pixel != p_lcd->bpp) {
  181. return -EINVAL;
  182. }
  183. memset(par, 0, sizeof(struct au1100fb_par));
  184. par->var = *var;
  185. /* FIXME */
  186. switch (var->bits_per_pixel) {
  187. case 8:
  188. par->var.bits_per_pixel = 8;
  189. break;
  190. case 16:
  191. par->var.bits_per_pixel = 16;
  192. break;
  193. default:
  194. printk("color depth %d bpp not supported\n",
  195. var->bits_per_pixel);
  196. return -EINVAL;
  197. }
  198. set_color_bitfields(&par->var);
  199. par->cmap_len = (par->var.bits_per_pixel == 8) ? 256 : 16;
  200. return 0;
  201. }
  202. static int au1100_encode_var(struct fb_var_screeninfo *var,
  203. const void *par, struct fb_info_gen *_info)
  204. {
  205. *var = ((struct au1100fb_par *)par)->var;
  206. return 0;
  207. }
  208. static void
  209. au1100_get_par(void *_par, struct fb_info_gen *_info)
  210. {
  211. *(struct au1100fb_par *)_par = current_par;
  212. }
  213. static void au1100_set_par(const void *par, struct fb_info_gen *info)
  214. {
  215. /* nothing to do: we don't change any settings */
  216. }
  217. static int au1100_getcolreg(unsigned regno, unsigned *red, unsigned *green,
  218. unsigned *blue, unsigned *transp,
  219. struct fb_info *info)
  220. {
  221. struct au1100fb_info* i = (struct au1100fb_info*)info;
  222. if (regno > 255)
  223. return 1;
  224. *red = i->palette[regno].red;
  225. *green = i->palette[regno].green;
  226. *blue = i->palette[regno].blue;
  227. *transp = 0;
  228. return 0;
  229. }
  230. static int au1100_setcolreg(unsigned regno, unsigned red, unsigned green,
  231. unsigned blue, unsigned transp,
  232. struct fb_info *info)
  233. {
  234. struct au1100fb_info* i = (struct au1100fb_info *)info;
  235. u32 rgbcol;
  236. if (regno > 255)
  237. return 1;
  238. i->palette[regno].red = red;
  239. i->palette[regno].green = green;
  240. i->palette[regno].blue = blue;
  241. switch(p_lcd->bpp) {
  242. #ifdef FBCON_HAS_CFB8
  243. case 8:
  244. red >>= 10;
  245. green >>= 10;
  246. blue >>= 10;
  247. p_lcd_reg->lcd_pallettebase[regno] = (blue&0x1f) |
  248. ((green&0x3f)<<5) | ((red&0x1f)<<11);
  249. break;
  250. #endif
  251. #ifdef FBCON_HAS_CFB16
  252. case 16:
  253. i->fbcon_cmap16[regno] =
  254. ((red & 0xf800) >> 0) |
  255. ((green & 0xfc00) >> 5) |
  256. ((blue & 0xf800) >> 11);
  257. break;
  258. #endif
  259. default:
  260. break;
  261. }
  262. return 0;
  263. }
  264. static int au1100_blank(int blank_mode, struct fb_info_gen *_info)
  265. {
  266. switch (blank_mode) {
  267. case VESA_NO_BLANKING:
  268. /* turn on panel */
  269. //printk("turn on panel\n");
  270. #ifdef CONFIG_MIPS_PB1100
  271. p_lcd_reg->lcd_control |= LCD_CONTROL_GO;
  272. au_writew(au_readw(PB1100_G_CONTROL) | p_lcd->mode_backlight,
  273. PB1100_G_CONTROL);
  274. #endif
  275. #ifdef CONFIG_MIPS_HYDROGEN3
  276. /* Turn controller & power supply on, GPIO213 */
  277. au_writel(0x20002000, 0xB1700008);
  278. au_writel(0x00040000, 0xB1900108);
  279. au_writel(0x01000100, 0xB1700008);
  280. #endif
  281. au_sync();
  282. break;
  283. case VESA_VSYNC_SUSPEND:
  284. case VESA_HSYNC_SUSPEND:
  285. case VESA_POWERDOWN:
  286. /* turn off panel */
  287. //printk("turn off panel\n");
  288. #ifdef CONFIG_MIPS_PB1100
  289. au_writew(au_readw(PB1100_G_CONTROL) & ~p_lcd->mode_backlight,
  290. PB1100_G_CONTROL);
  291. p_lcd_reg->lcd_control &= ~LCD_CONTROL_GO;
  292. #endif
  293. au_sync();
  294. break;
  295. default:
  296. break;
  297. }
  298. return 0;
  299. }
  300. static void au1100_set_disp(const void *unused, struct display *disp,
  301. struct fb_info_gen *info)
  302. {
  303. disp->screen_base = (char *)fb_info.fb_virt_start;
  304. switch (disp->var.bits_per_pixel) {
  305. #ifdef FBCON_HAS_CFB8
  306. case 8:
  307. disp->dispsw = &fbcon_cfb8;
  308. if (fb_info.nohwcursor)
  309. fbcon_cfb8.cursor = au1100_nocursor;
  310. break;
  311. #endif
  312. #ifdef FBCON_HAS_CFB16
  313. case 16:
  314. disp->dispsw = &fbcon_cfb16;
  315. disp->dispsw_data = fb_info.fbcon_cmap16;
  316. if (fb_info.nohwcursor)
  317. fbcon_cfb16.cursor = au1100_nocursor;
  318. break;
  319. #endif
  320. default:
  321. disp->dispsw = &fbcon_dummy;
  322. disp->dispsw_data = NULL;
  323. break;
  324. }
  325. }
  326. static int
  327. au1100fb_mmap(struct fb_info *_fb,
  328. struct file *file,
  329. struct vm_area_struct *vma)
  330. {
  331. unsigned int len;
  332. unsigned long start=0, off;
  333. struct au1100fb_info *fb = (struct au1100fb_info *)_fb;
  334. if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) {
  335. return -EINVAL;
  336. }
  337. start = fb_info.fb_phys & PAGE_MASK;
  338. len = PAGE_ALIGN((start & ~PAGE_MASK) + fb_info.fb_size);
  339. off = vma->vm_pgoff << PAGE_SHIFT;
  340. if ((vma->vm_end - vma->vm_start + off) > len) {
  341. return -EINVAL;
  342. }
  343. off += start;
  344. vma->vm_pgoff = off >> PAGE_SHIFT;
  345. pgprot_val(vma->vm_page_prot) &= ~_CACHE_MASK;
  346. //pgprot_val(vma->vm_page_prot) |= _CACHE_CACHABLE_NONCOHERENT;
  347. pgprot_val(vma->vm_page_prot) |= (6 << 9); //CCA=6
  348. /* This is an IO map - tell maydump to skip this VMA */
  349. vma->vm_flags |= VM_IO;
  350. if (io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT,
  351. vma->vm_end - vma->vm_start,
  352. vma->vm_page_prot)) {
  353. return -EAGAIN;
  354. }
  355. fb->mmaped = 1;
  356. return 0;
  357. }
  358. int au1100_pan_display(const struct fb_var_screeninfo *var,
  359. struct fb_info_gen *info)
  360. {
  361. return 0;
  362. }
  363. static int au1100fb_ioctl(struct inode *inode, struct file *file, u_int cmd,
  364. u_long arg, int con, struct fb_info *info)
  365. {
  366. /* nothing to do yet */
  367. return -EINVAL;
  368. }
  369. static struct fbgen_hwswitch au1100_switch = {
  370. au1100_detect,
  371. au1100_encode_fix,
  372. au1100_decode_var,
  373. au1100_encode_var,
  374. au1100_get_par,
  375. au1100_set_par,
  376. au1100_getcolreg,
  377. au1100_setcolreg,
  378. au1100_pan_display,
  379. au1100_blank,
  380. au1100_set_disp
  381. };
  382. int au1100_setmode(void)
  383. {
  384. int words;
  385. /* FIXME Need to accomodate for swivel mode and 12bpp, <8bpp*/
  386. switch (p_lcd->mode_control & LCD_CONTROL_SM)
  387. {
  388. case LCD_CONTROL_SM_0:
  389. case LCD_CONTROL_SM_180:
  390. words = (p_lcd->xres * p_lcd->yres * p_lcd->bpp) / 32;
  391. break;
  392. case LCD_CONTROL_SM_90:
  393. case LCD_CONTROL_SM_270:
  394. /* is this correct? */
  395. words = (p_lcd->xres * p_lcd->bpp) / 8;
  396. break;
  397. default:
  398. printk("mode_control reg not initialized\n");
  399. return -EINVAL;
  400. }
  401. /*
  402. * Setup LCD controller
  403. */
  404. p_lcd_reg->lcd_control = p_lcd->mode_control;
  405. p_lcd_reg->lcd_intstatus = 0;
  406. p_lcd_reg->lcd_intenable = 0;
  407. p_lcd_reg->lcd_horztiming = p_lcd->mode_horztiming;
  408. p_lcd_reg->lcd_verttiming = p_lcd->mode_verttiming;
  409. p_lcd_reg->lcd_clkcontrol = p_lcd->mode_clkcontrol;
  410. p_lcd_reg->lcd_words = words - 1;
  411. p_lcd_reg->lcd_dmaaddr0 = fb_info.fb_phys;
  412. /* turn on panel */
  413. #ifdef CONFIG_MIPS_PB1100
  414. au_writew(au_readw(PB1100_G_CONTROL) | p_lcd->mode_backlight,
  415. PB1100_G_CONTROL);
  416. #endif
  417. #ifdef CONFIG_MIPS_HYDROGEN3
  418. /* Turn controller & power supply on, GPIO213 */
  419. au_writel(0x20002000, 0xB1700008);
  420. au_writel(0x00040000, 0xB1900108);
  421. au_writel(0x01000100, 0xB1700008);
  422. #endif
  423. p_lcd_reg->lcd_control |= LCD_CONTROL_GO;
  424. return 0;
  425. }
  426. int __init au1100fb_init(void)
  427. {
  428. uint32 sys_clksrc;
  429. unsigned long page;
  430. /*
  431. * Get the panel information/display mode and update the registry
  432. */
  433. p_lcd = &panels[my_lcd_index];
  434. switch (p_lcd->mode_control & LCD_CONTROL_SM)
  435. {
  436. case LCD_CONTROL_SM_0:
  437. case LCD_CONTROL_SM_180:
  438. p_lcd->xres =
  439. (p_lcd->mode_horztiming & LCD_HORZTIMING_PPL) + 1;
  440. p_lcd->yres =
  441. (p_lcd->mode_verttiming & LCD_VERTTIMING_LPP) + 1;
  442. break;
  443. case LCD_CONTROL_SM_90:
  444. case LCD_CONTROL_SM_270:
  445. p_lcd->yres =
  446. (p_lcd->mode_horztiming & LCD_HORZTIMING_PPL) + 1;
  447. p_lcd->xres =
  448. (p_lcd->mode_verttiming & LCD_VERTTIMING_LPP) + 1;
  449. break;
  450. }
  451. /*
  452. * Panel dimensions x bpp must be divisible by 32
  453. */
  454. if (((p_lcd->yres * p_lcd->bpp) % 32) != 0)
  455. printk("VERT %% 32\n");
  456. if (((p_lcd->xres * p_lcd->bpp) % 32) != 0)
  457. printk("HORZ %% 32\n");
  458. /*
  459. * Allocate LCD framebuffer from system memory
  460. */
  461. fb_info.fb_size = (p_lcd->xres * p_lcd->yres * p_lcd->bpp) / 8;
  462. current_par.var.xres = p_lcd->xres;
  463. current_par.var.xres_virtual = p_lcd->xres;
  464. current_par.var.yres = p_lcd->yres;
  465. current_par.var.yres_virtual = p_lcd->yres;
  466. current_par.var.bits_per_pixel = p_lcd->bpp;
  467. /* FIX!!! only works for 8/16 bpp */
  468. current_par.line_length = p_lcd->xres * p_lcd->bpp / 8; /* in bytes */
  469. fb_info.fb_virt_start = (unsigned long )
  470. __get_free_pages(GFP_ATOMIC | GFP_DMA,
  471. get_order(fb_info.fb_size + 0x1000));
  472. if (!fb_info.fb_virt_start) {
  473. printk("Unable to allocate fb memory\n");
  474. return -ENOMEM;
  475. }
  476. fb_info.fb_phys = virt_to_bus((void *)fb_info.fb_virt_start);
  477. /*
  478. * Set page reserved so that mmap will work. This is necessary
  479. * since we'll be remapping normal memory.
  480. */
  481. for (page = fb_info.fb_virt_start;
  482. page < PAGE_ALIGN(fb_info.fb_virt_start + fb_info.fb_size);
  483. page += PAGE_SIZE) {
  484. SetPageReserved(virt_to_page(page));
  485. }
  486. memset((void *)fb_info.fb_virt_start, 0, fb_info.fb_size);
  487. /* set freqctrl now to allow more time to stabilize */
  488. /* zero-out out LCD bits */
  489. sys_clksrc = au_readl(SYS_CLKSRC) & ~0x000003e0;
  490. sys_clksrc |= p_lcd->mode_toyclksrc;
  491. au_writel(sys_clksrc, SYS_CLKSRC);
  492. /* FIXME add check to make sure auxpll is what is expected! */
  493. au1100_setmode();
  494. fb_info.gen.parsize = sizeof(struct au1100fb_par);
  495. fb_info.gen.fbhw = &au1100_switch;
  496. strcpy(fb_info.gen.info.modename, "Au1100 LCD");
  497. fb_info.gen.info.changevar = NULL;
  498. fb_info.gen.info.node = -1;
  499. fb_info.gen.info.fbops = &au1100fb_ops;
  500. fb_info.gen.info.disp = &disp;
  501. fb_info.gen.info.switch_con = &fbgen_switch;
  502. fb_info.gen.info.updatevar = &fbgen_update_var;
  503. fb_info.gen.info.blank = &fbgen_blank;
  504. fb_info.gen.info.flags = FBINFO_FLAG_DEFAULT;
  505. /* This should give a reasonable default video mode */
  506. fbgen_get_var(&disp.var, -1, &fb_info.gen.info);
  507. fbgen_do_set_var(&disp.var, 1, &fb_info.gen);
  508. fbgen_set_disp(-1, &fb_info.gen);
  509. fbgen_install_cmap(0, &fb_info.gen);
  510. if (register_framebuffer(&fb_info.gen.info) < 0)
  511. return -EINVAL;
  512. printk(KERN_INFO "fb%d: %s frame buffer device\n",
  513. GET_FB_IDX(fb_info.gen.info.node),
  514. fb_info.gen.info.modename);
  515. return 0;
  516. }
  517. void au1100fb_cleanup(struct fb_info *info)
  518. {
  519. unregister_framebuffer(info);
  520. }
  521. void au1100fb_setup(char *options, int *ints)
  522. {
  523. char* this_opt;
  524. int i;
  525. int num_panels = sizeof(panels)/sizeof(struct known_lcd_panels);
  526. if (!options || !*options)
  527. return;
  528. for(this_opt=strtok(options, ","); this_opt;
  529. this_opt=strtok(NULL, ",")) {
  530. if (!strncmp(this_opt, "panel:", 6)) {
  531. #if defined(CONFIG_MIPS_PB1100) || defined(CONFIG_MIPS_DB1100)
  532. /* Read Pb1100 Switch S10 ? */
  533. if (!strncmp(this_opt+6, "s10", 3))
  534. {
  535. int panel;
  536. panel = *(volatile int *)0xAE000008; /* BCSR SWITCHES */
  537. panel >>= 8;
  538. panel &= 0x0F;
  539. if (panel >= num_panels) panel = 0;
  540. my_lcd_index = panel;
  541. }
  542. else
  543. #endif
  544. /* Get the panel name, everything else if fixed */
  545. for (i=0; i<num_panels; i++) {
  546. if (!strncmp(this_opt+6, panels[i].panel_name,
  547. strlen(this_opt))) {
  548. my_lcd_index = i;
  549. break;
  550. }
  551. }
  552. }
  553. else if (!strncmp(this_opt, "nohwcursor", 10)) {
  554. printk("nohwcursor\n");
  555. fb_info.nohwcursor = 1;
  556. }
  557. }
  558. printk("au1100fb: Panel %d %s\n", my_lcd_index,
  559. panels[my_lcd_index].panel_name);
  560. }
  561. #ifdef MODULE
  562. MODULE_LICENSE("GPL");
  563. int init_module(void)
  564. {
  565. return au1100fb_init();
  566. }
  567. void cleanup_module(void)
  568. {
  569. au1100fb_cleanup(void);
  570. }
  571. MODULE_AUTHOR("Pete Popov <ppopov@mvista.com>");
  572. MODULE_DESCRIPTION("Au1100 LCD framebuffer device driver");
  573. #endif /* MODULE */