maxinefb.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * linux/drivers/video/maxinefb.c
  3. *
  4. * DECstation 5000/xx onboard framebuffer support ... derived from:
  5. * "HP300 Topcat framebuffer support (derived from macfb of all things)
  6. * Phil Blundell <philb@gnu.org> 1998", the original code can be
  7. * found in the file hpfb.c in the same directory.
  8. *
  9. * DECstation related code Copyright (C) 1999,2000,2001 by
  10. * Michael Engel <engel@unix-ag.org> and
  11. * Karsten Merker <merker@linuxtag.org>.
  12. * This file is subject to the terms and conditions of the GNU General
  13. * Public License. See the file COPYING in the main directory of this
  14. * archive for more details.
  15. *
  16. */
  17. /*
  18. * Changes:
  19. * 2001/01/27 removed debugging and testing code, fixed fb_ops
  20. * initialization which had caused a crash before,
  21. * general cleanup, first official release (KM)
  22. *
  23. */
  24. #include <linux/module.h>
  25. #include <linux/kernel.h>
  26. #include <linux/errno.h>
  27. #include <linux/string.h>
  28. #include <linux/mm.h>
  29. #include <linux/delay.h>
  30. #include <linux/init.h>
  31. #include <linux/fb.h>
  32. #include <video/maxinefb.h>
  33. /* bootinfo.h defines the machine type values, needed when checking */
  34. /* whether are really running on a maxine, KM */
  35. #include <asm/bootinfo.h>
  36. static struct fb_info fb_info;
  37. static const struct fb_var_screeninfo maxinefb_defined = {
  38. .xres = 1024,
  39. .yres = 768,
  40. .xres_virtual = 1024,
  41. .yres_virtual = 768,
  42. .bits_per_pixel =8,
  43. .activate = FB_ACTIVATE_NOW,
  44. .height = -1,
  45. .width = -1,
  46. .vmode = FB_VMODE_NONINTERLACED,
  47. };
  48. static struct fb_fix_screeninfo maxinefb_fix __initdata = {
  49. .id = "Maxine",
  50. .smem_len = (1024*768),
  51. .type = FB_TYPE_PACKED_PIXELS,
  52. .visual = FB_VISUAL_PSEUDOCOLOR,
  53. .line_length = 1024,
  54. };
  55. /* Handle the funny Inmos RamDAC/video controller ... */
  56. void maxinefb_ims332_write_register(int regno, register unsigned int val)
  57. {
  58. register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
  59. unsigned char *wptr;
  60. wptr = regs + 0xa0000 + (regno << 4);
  61. *((volatile unsigned int *) (regs)) = (val >> 8) & 0xff00;
  62. *((volatile unsigned short *) (wptr)) = val;
  63. }
  64. unsigned int maxinefb_ims332_read_register(int regno)
  65. {
  66. register unsigned char *regs = (char *) MAXINEFB_IMS332_ADDRESS;
  67. unsigned char *rptr;
  68. register unsigned int j, k;
  69. rptr = regs + 0x80000 + (regno << 4);
  70. j = *((volatile unsigned short *) rptr);
  71. k = *((volatile unsigned short *) regs);
  72. return (j & 0xffff) | ((k & 0xff00) << 8);
  73. }
  74. /* Set the palette */
  75. static int maxinefb_setcolreg(unsigned regno, unsigned red, unsigned green,
  76. unsigned blue, unsigned transp, struct fb_info *info)
  77. {
  78. /* value to be written into the palette reg. */
  79. unsigned long hw_colorvalue = 0;
  80. if (regno > 255)
  81. return 1;
  82. red >>= 8; /* The cmap fields are 16 bits */
  83. green >>= 8; /* wide, but the harware colormap */
  84. blue >>= 8; /* registers are only 8 bits wide */
  85. hw_colorvalue = (blue << 16) + (green << 8) + (red);
  86. maxinefb_ims332_write_register(IMS332_REG_COLOR_PALETTE + regno,
  87. hw_colorvalue);
  88. return 0;
  89. }
  90. static const struct fb_ops maxinefb_ops = {
  91. .owner = THIS_MODULE,
  92. .fb_setcolreg = maxinefb_setcolreg,
  93. .fb_fillrect = cfb_fillrect,
  94. .fb_copyarea = cfb_copyarea,
  95. .fb_imageblit = cfb_imageblit,
  96. };
  97. int __init maxinefb_init(void)
  98. {
  99. unsigned long fboff;
  100. unsigned long fb_start;
  101. int i;
  102. if (fb_get_options("maxinefb", NULL))
  103. return -ENODEV;
  104. /* Validate we're on the proper machine type */
  105. if (mips_machtype != MACH_DS5000_XX) {
  106. return -EINVAL;
  107. }
  108. printk(KERN_INFO "Maxinefb: Personal DECstation detected\n");
  109. printk(KERN_INFO "Maxinefb: initializing onboard framebuffer\n");
  110. /* Framebuffer display memory base address */
  111. fb_start = DS5000_xx_ONBOARD_FBMEM_START;
  112. /* Clear screen */
  113. for (fboff = fb_start; fboff < fb_start + 0x1ffff; fboff++)
  114. *(volatile unsigned char *)fboff = 0x0;
  115. maxinefb_fix.smem_start = fb_start;
  116. /* erase hardware cursor */
  117. for (i = 0; i < 512; i++) {
  118. maxinefb_ims332_write_register(IMS332_REG_CURSOR_RAM + i,
  119. 0);
  120. /*
  121. if (i&0x8 == 0)
  122. maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0x0f);
  123. else
  124. maxinefb_ims332_write_register (IMS332_REG_CURSOR_RAM + i, 0xf0);
  125. */
  126. }
  127. fb_info.fbops = &maxinefb_ops;
  128. fb_info.screen_base = (char *)maxinefb_fix.smem_start;
  129. fb_info.var = maxinefb_defined;
  130. fb_info.fix = maxinefb_fix;
  131. fb_info.flags = FBINFO_DEFAULT;
  132. fb_alloc_cmap(&fb_info.cmap, 256, 0);
  133. if (register_framebuffer(&fb_info) < 0)
  134. return 1;
  135. return 0;
  136. }
  137. static void __exit maxinefb_exit(void)
  138. {
  139. unregister_framebuffer(&fb_info);
  140. }
  141. #ifdef MODULE
  142. MODULE_LICENSE("GPL");
  143. #endif
  144. module_init(maxinefb_init);
  145. module_exit(maxinefb_exit);