Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | /* $Id: bwtwofb.c,v 1.6 1998/09/15 15:45:35 jj Exp $ * bwtwofb.c: BWtwo frame buffer driver * * Copyright (C) 1998 Jakub Jelinek (jj@ultra.linux.cz) * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx) * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) * Copyright (C) 1998 Pavel Machek (pavel@ucw.cz) */ #include <linux/config.h> #include <linux/module.h> #include <linux/sched.h> #include <linux/kernel.h> #include <linux/errno.h> #include <linux/string.h> #include <linux/mm.h> #include <linux/tty.h> #include <linux/malloc.h> #include <linux/vmalloc.h> #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/fb.h> #include <linux/init.h> #include <linux/selection.h> #include <video/sbusfb.h> #include <asm/io.h> #ifndef __sparc_v9__ #include <asm/sun4paddr.h> #endif #include <video/fbcon-mfb.h> /* OBio addresses for the bwtwo registers */ #define BWTWO_REGISTER_OFFSET 0x400000 struct bw2_regs { struct bt_regs bt; volatile u8 control; volatile u8 status; volatile u8 cursor_start; volatile u8 cursor_end; volatile u8 h_blank_start; volatile u8 h_blank_end; volatile u8 h_sync_start; volatile u8 h_sync_end; volatile u8 comp_sync_end; volatile u8 v_blank_start_high; volatile u8 v_blank_start_low; volatile u8 v_blank_end; volatile u8 v_sync_start; volatile u8 v_sync_end; volatile u8 xfer_holdoff_start; volatile u8 xfer_holdoff_end; }; /* Status Register Constants */ #define BWTWO_SR_RES_MASK 0x70 #define BWTWO_SR_1600_1280 0x50 #define BWTWO_SR_1152_900_76_A 0x40 #define BWTWO_SR_1152_900_76_B 0x60 #define BWTWO_SR_ID_MASK 0x0f #define BWTWO_SR_ID_MONO 0x02 #define BWTWO_SR_ID_MONO_ECL 0x03 #define BWTWO_SR_ID_MSYNC 0x04 #define BWTWO_SR_ID_NOCONN 0x0a /* Control Register Constants */ #define BWTWO_CTL_ENABLE_INTS 0x80 #define BWTWO_CTL_ENABLE_VIDEO 0x40 #define BWTWO_CTL_ENABLE_TIMING 0x20 #define BWTWO_CTL_ENABLE_CURCMP 0x10 #define BWTWO_CTL_XTAL_MASK 0x0C #define BWTWO_CTL_DIVISOR_MASK 0x03 /* Status Register Constants */ #define BWTWO_STAT_PENDING_INT 0x80 #define BWTWO_STAT_MSENSE_MASK 0x70 #define BWTWO_STAT_ID_MASK 0x0f static struct sbus_mmap_map bw2_mmap_map[] = { { 0, 0, SBUS_MMAP_FBSIZE(1) }, { 0, 0, 0 } }; static void bw2_blank (struct fb_info_sbusfb *fb) { fb->s.bw2.regs->control &= ~BWTWO_CTL_ENABLE_VIDEO; } static void bw2_unblank (struct fb_info_sbusfb *fb) { fb->s.bw2.regs->control |= BWTWO_CTL_ENABLE_VIDEO; } static void bw2_margins (struct fb_info_sbusfb *fb, struct display *p, int x_margin, int y_margin) { p->screen_base += (y_margin - fb->y_margin) * p->line_length + ((x_margin - fb->x_margin) >> 3); } static u8 bw2regs_1600[] __initdata = { 0x14, 0x8b, 0x15, 0x28, 0x16, 0x03, 0x17, 0x13, 0x18, 0x7b, 0x19, 0x05, 0x1a, 0x34, 0x1b, 0x2e, 0x1c, 0x00, 0x1d, 0x0a, 0x1e, 0xff, 0x1f, 0x01, 0x10, 0x21, 0 }; static u8 bw2regs_ecl[] __initdata = { 0x14, 0x65, 0x15, 0x1e, 0x16, 0x04, 0x17, 0x0c, 0x18, 0x5e, 0x19, 0x03, 0x1a, 0xa7, 0x1b, 0x23, 0x1c, 0x00, 0x1d, 0x08, 0x1e, 0xff, 0x1f, 0x01, 0x10, 0x20, 0 }; static u8 bw2regs_analog[] __initdata = { 0x14, 0xbb, 0x15, 0x2b, 0x16, 0x03, 0x17, 0x13, 0x18, 0xb0, 0x19, 0x03, 0x1a, 0xa6, 0x1b, 0x22, 0x1c, 0x01, 0x1d, 0x05, 0x1e, 0xff, 0x1f, 0x01, 0x10, 0x20, 0 }; static u8 bw2regs_76hz[] __initdata = { 0x14, 0xb7, 0x15, 0x27, 0x16, 0x03, 0x17, 0x0f, 0x18, 0xae, 0x19, 0x03, 0x1a, 0xae, 0x1b, 0x2a, 0x1c, 0x01, 0x1d, 0x09, 0x1e, 0xff, 0x1f, 0x01, 0x10, 0x24, 0 }; static u8 bw2regs_66hz[] __initdata = { 0x14, 0xbb, 0x15, 0x2b, 0x16, 0x04, 0x17, 0x14, 0x18, 0xae, 0x19, 0x03, 0x1a, 0xa8, 0x1b, 0x24, 0x1c, 0x01, 0x1d, 0x05, 0x1e, 0xff, 0x1f, 0x01, 0x10, 0x20, 0 }; static char idstring[60] __initdata = { 0 }; char __init *bwtwofb_init(struct fb_info_sbusfb *fb) { struct fb_fix_screeninfo *fix = &fb->fix; struct display *disp = &fb->disp; struct fbtype *type = &fb->type; #ifdef CONFIG_SUN4 unsigned long phys = sun4_bwtwo_physaddr; #else unsigned long phys = fb->sbdp->reg_addrs[0].phys_addr; #endif #ifndef FBCON_HAS_MFB return NULL; #endif if (!fb->s.bw2.regs) { fb->s.bw2.regs = (struct bw2_regs *)sparc_alloc_io(phys+BWTWO_REGISTER_OFFSET, 0, sizeof(struct bw2_regs), "bw2_regs", fb->iospace, 0); if ((!ARCH_SUN4) && (!prom_getbool(fb->prom_node, "width"))) { /* Ugh, broken PROM didn't initialize us. * Let's deal with this ourselves. */ u8 status, mon; u8 *p; int sizechange = 0; status = fb->s.bw2.regs->status; mon = status & BWTWO_SR_RES_MASK; switch (status & BWTWO_SR_ID_MASK) { case BWTWO_SR_ID_MONO_ECL: if (mon == BWTWO_SR_1600_1280) { p = bw2regs_1600; fb->type.fb_width = 1600; fb->type.fb_height = 1280; sizechange = 1; } else p = bw2regs_ecl; break; case BWTWO_SR_ID_MONO: p = bw2regs_analog; break; case BWTWO_SR_ID_MSYNC: if (mon == BWTWO_SR_1152_900_76_A || mon == BWTWO_SR_1152_900_76_B) p = bw2regs_76hz; else p = bw2regs_66hz; break; case BWTWO_SR_ID_NOCONN: return NULL; default: prom_printf("bw2: can't handle SR %02x\n", status); prom_halt(); return NULL; /* fool gcc. */ } for ( ; *p; p += 2) ((u8 *)fb->s.bw2.regs)[p[0]] = p[1]; } } strcpy(fb->info.modename, "BWtwo"); strcpy(fix->id, "BWtwo"); fix->line_length = fb->var.xres_virtual>>3; disp->scrollmode = SCROLL_YREDRAW; disp->inverse = 1; if (!disp->screen_base) disp->screen_base = (char *)sparc_alloc_io(phys, 0, type->fb_size, "bw2_ram", fb->iospace, 0); disp->screen_base += fix->line_length * fb->y_margin + (fb->x_margin >> 3); fb->dispsw = fbcon_mfb; fix->visual = FB_VISUAL_MONO01; #ifndef CONFIG_SUN4 fb->blank = bw2_blank; fb->unblank = bw2_unblank; #endif fb->margins = bw2_margins; fb->physbase = phys; fb->mmap_map = bw2_mmap_map; #ifdef __sparc_v9__ sprintf(idstring, "bwtwo at %016lx", phys); #else sprintf(idstring, "bwtwo at %x.%08lx", fb->iospace, phys); #endif return idstring; } |