1 /* $Id: bwtwo.c,v 1.12 1997/04/10 03:02:40 davem Exp $ 2 * bwtwo.c: bwtwo console driver 4 * Copyright (C) 1996 Miguel de Icaza (miguel@nuclecu.unam.mx) 5 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be) 10 #include <linux/malloc.h> 11 #include <linux/proc_fs.h> 16 #include <asm/pgtable.h> 18 #include"../../char/vt_kern.h" 19 #include"../../char/selection.h" 20 #include"../../char/console_struct.h" 24 /* OBio addresses for the bwtwo registers */ 25 #define BWTWO_REGISTER_OFFSET 0x400000 28 __volatile__
struct bt_regs bt
; 29 __volatile__ __u8 control
; 30 __volatile__ __u8 status
; 31 __volatile__ __u8 cursor_start
; 32 __volatile__ __u8 cursor_end
; 33 __volatile__ __u8 h_blank_start
; 34 __volatile__ __u8 h_blank_end
; 35 __volatile__ __u8 h_sync_start
; 36 __volatile__ __u8 h_sync_end
; 37 __volatile__ __u8 comp_sync_end
; 38 __volatile__ __u8 v_blank_start_high
; 39 __volatile__ __u8 v_blank_start_low
; 40 __volatile__ __u8 v_blank_end
; 41 __volatile__ __u8 v_sync_start
; 42 __volatile__ __u8 v_sync_end
; 43 __volatile__ __u8 xfer_holdoff_start
; 44 __volatile__ __u8 xfer_holdoff_end
; 47 /* Status Register Constants */ 48 #define BWTWO_SR_RES_MASK 0x70 49 #define BWTWO_SR_1600_1280 0x50 50 #define BWTWO_SR_1152_900_76_A 0x40 51 #define BWTWO_SR_1152_900_76_B 0x60 52 #define BWTWO_SR_ID_MASK 0x0f 53 #define BWTWO_SR_ID_MONO 0x02 54 #define BWTWO_SR_ID_MONO_ECL 0x03 55 #define BWTWO_SR_ID_MSYNC 0x04 57 /* Control Register Constants */ 58 #define BWTWO_CTL_ENABLE_INTS 0x80 59 #define BWTWO_CTL_ENABLE_VIDEO 0x40 60 #define BWTWO_CTL_ENABLE_TIMING 0x20 61 #define BWTWO_CTL_ENABLE_CURCMP 0x10 62 #define BWTWO_CTL_XTAL_MASK 0x0C 63 #define BWTWO_CTL_DIVISOR_MASK 0x03 65 /* Status Register Constants */ 66 #define BWTWO_STAT_PENDING_INT 0x80 67 #define BWTWO_STAT_MSENSE_MASK 0x70 68 #define BWTWO_STAT_ID_MASK 0x0f 72 bwtwo_mmap(struct inode
*inode
,struct file
*file
,struct vm_area_struct
*vma
, 73 long base
, fbinfo_t
*fb
) 75 uint size
, map_offset
, r
; 78 map_size
= size
= vma
->vm_end
- vma
->vm_start
; 80 if(vma
->vm_offset
& ~PAGE_MASK
) 83 /* To stop the swapper from even considering these pages */ 84 vma
->vm_flags
|= FB_MMAP_VM_FLAGS
; 86 /* This routine should also map the register if asked for, 87 * but we don't do that yet. 89 map_offset
=get_phys((uint
) fb
->base
); 90 r
=io_remap_page_range(vma
->vm_start
, map_offset
, map_size
, 91 vma
->vm_page_prot
, fb
->space
); 93 vma
->vm_inode
= inode
; 99 bwtwo_blank(fbinfo_t
*fb
) 101 fb
->info
.bwtwo
.regs
->control
&= ~BWTWO_CTL_ENABLE_VIDEO
; 105 bwtwo_unblank(fbinfo_t
*fb
) 107 fb
->info
.bwtwo
.regs
->control
|= BWTWO_CTL_ENABLE_VIDEO
; 111 static u8 bw2regs_1600
[] __initdata
= { 112 0x14,0x8b,0x15,0x28,0x16,0x03,0x17,0x13, 113 0x18,0x7b,0x19,0x05,0x1a,0x34,0x1b,0x2e, 114 0x1c,0x00,0x1d,0x0a,0x1e,0xff,0x1f,0x01, 118 static u8 bw2regs_ecl
[] __initdata
= { 119 0x14,0x65,0x15,0x1e,0x16,0x04,0x17,0x0c, 120 0x18,0x5e,0x19,0x03,0x1a,0xa7,0x1b,0x23, 121 0x1c,0x00,0x1d,0x08,0x1e,0xff,0x1f,0x01, 125 static u8 bw2regs_analog
[] __initdata
= { 126 0x14,0xbb,0x15,0x2b,0x16,0x03,0x17,0x13, 127 0x18,0xb0,0x19,0x03,0x1a,0xa6,0x1b,0x22, 128 0x1c,0x01,0x1d,0x05,0x1e,0xff,0x1f,0x01, 132 static u8 bw2regs_76hz
[] __initdata
= { 133 0x14,0xb7,0x15,0x27,0x16,0x03,0x17,0x0f, 134 0x18,0xae,0x19,0x03,0x1a,0xae,0x1b,0x2a, 135 0x1c,0x01,0x1d,0x09,0x1e,0xff,0x1f,0x01, 139 static u8 bw2regs_66hz
[] __initdata
= { 140 0x14,0xbb,0x15,0x2b,0x16,0x04,0x17,0x14, 141 0x18,0xae,0x19,0x03,0x1a,0xa8,0x1b,0x24, 142 0x1c,0x01,0x1d,0x05,0x1e,0xff,0x1f,0x01, 146 __initfunc(voidbwtwo_setup(fbinfo_t
*fb
,int slot
,unsigned long bwtwo
,int bw2_io
, 147 struct linux_sbus_device
*sbdp
)) 149 printk("bwtwo%d at 0x%8.8x\n", slot
, (uint
)bwtwo
); 150 fb
->type
.fb_cmsize
=0; 151 fb
->mmap
= bwtwo_mmap
; 155 fb
->blank
= bwtwo_blank
; 156 fb
->unblank
= bwtwo_unblank
; 158 fb
->info
.bwtwo
.regs
= 159 sparc_alloc_io((u32
)(bwtwo
+ BWTWO_REGISTER_OFFSET
), 160 0,sizeof(struct bwtwo_regs
), 161 "bwtwo_regs", bw2_io
,0); 163 if(!prom_getbool(sbdp
->prom_node
,"width")) { 164 /* Ugh, broken PROM didn't initialize us. 165 * Let's deal with this ourselves. 170 status
= fb
->info
.bwtwo
.regs
->status
; 171 mon
= status
& BWTWO_SR_RES_MASK
; 172 switch(status
& BWTWO_SR_ID_MASK
) { 173 case BWTWO_SR_ID_MONO_ECL
: 174 if(mon
== BWTWO_SR_1600_1280
) { 176 fb
->type
.fb_width
=1600; 177 fb
->type
.fb_height
=1280; 182 case BWTWO_SR_ID_MONO
: 185 case BWTWO_SR_ID_MSYNC
: 186 if(mon
== BWTWO_SR_1152_900_76_A
|| 187 mon
== BWTWO_SR_1152_900_76_B
) { 194 prom_printf("bwtwo: can't handle SR %02x\n", 197 return;/* fool gcc. */ 200 ((u8
*)fb
->info
.bwtwo
.regs
)[p
[0]] = p
[1]; 204 fb
->base
= (unsigned long)sparc_alloc_io((u32
)bwtwo
,0, 205 ((fb
->type
.fb_depth
*fb
->type
.fb_height
*fb
->type
.fb_width
)/8), 206 "bwtwo_fbase", bw2_io
,0); 208 if(slot
&& sun_prom_console_id
!= slot
)