mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
from dave ashley.
ron
This commit is contained in:
parent
1103ba3c2a
commit
5aad3ba0d0
5 changed files with 210 additions and 36 deletions
|
@ -190,9 +190,18 @@ biosint(
|
|||
eax = 64 * 1024;
|
||||
ret = 0;
|
||||
break;
|
||||
#ifdef CONFIG_INT21HANDLER
|
||||
case 0x15:
|
||||
ret=handleint21( &edi, &esi, &ebp, &esp,
|
||||
&ebx, &edx, &ecx, &eax, &flags);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
printk_info(__FUNCTION__ ": Unsupport int #0x%x\n",
|
||||
intnumber);
|
||||
#ifdef CONFIG_UNSUPPORTINT_RECOVER
|
||||
unsupportint_recover();
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (ret)
|
||||
|
|
|
@ -159,6 +159,13 @@ __asm__ (
|
|||
" ret\n"
|
||||
);
|
||||
|
||||
#ifdef CONFIG_UNSUPPORTINT_RECOVER
|
||||
void unsupportint_recover(void)
|
||||
{
|
||||
__asm__ __volatile__ ( " jmp vgarestart \n" );
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
do_vgabios(void)
|
||||
{
|
||||
|
@ -192,6 +199,9 @@ do_vgabios(void)
|
|||
if ((buf[0] == 0x55) && (buf[1] == 0xaa)) {
|
||||
|
||||
memcpy((void *) 0xc0000, buf, size);
|
||||
#ifdef VGABIOS_WRITE_PROTECT
|
||||
write_protect_vgabios();
|
||||
#endif
|
||||
|
||||
for(i = 0; i < 16; i++)
|
||||
printk_debug("0x%x ", buf[i]);
|
||||
|
|
|
@ -44,4 +44,6 @@ cpu p6
|
|||
|
||||
option MAINBOARD_PART_NUMBER=EPIA-M
|
||||
option MAINBOARD_VENDOR=VIA
|
||||
|
||||
option CONFIG_INT21HANDLER=1
|
||||
option VGABIOS_WRITE_PROTECT=1
|
||||
option CONFIG_UNSUPPORTINT_RECOVER=1
|
||||
|
|
|
@ -10,7 +10,7 @@ static const unsigned char enetIrqs[4] = { 11, 5, 10, 12 };
|
|||
static const unsigned char slotIrqs[4] = { 10, 12, 5, 11 };
|
||||
static const unsigned char firewireIrqs[4] = {10, 12, 5, 11 };
|
||||
static const unsigned char vt8235Irqs[4] = { 5,10, 12, 11 };
|
||||
|
||||
static const unsigned char vgaIrqs[4] = { 11, 5, 12, 10 };
|
||||
|
||||
/*
|
||||
Our IDSEL mappings are as follows
|
||||
|
@ -28,8 +28,8 @@ static void pci_routing_fixup(void)
|
|||
* on the PCB routing of PINTA-D
|
||||
*
|
||||
* PINTA = IRQ11
|
||||
* PINTB = IRQ12
|
||||
* PINTC = IRQ10
|
||||
* PINTB = IRQ10
|
||||
* PINTC = IRQ12
|
||||
* PINTD = IRQ5
|
||||
*/
|
||||
pci_write_config_byte(dev, 0x55, 0xb0);
|
||||
|
@ -46,10 +46,18 @@ static void pci_routing_fixup(void)
|
|||
printk_info("setting usb\n");
|
||||
pci_assign_irqs(0, 0x10, usbIrqs);
|
||||
|
||||
// VT8235 + sound hardware
|
||||
printk_info("setting vt8235\n");
|
||||
pci_assign_irqs(0, 0x11, vt8235Irqs);
|
||||
|
||||
// Ethernet built into southbridge
|
||||
printk_info("setting ethernet\n");
|
||||
pci_assign_irqs(0, 0x12, enetIrqs);
|
||||
|
||||
// VGA
|
||||
printk_info("setting vga\n");
|
||||
pci_assign_irqs(1, 0x00, vgaIrqs);
|
||||
|
||||
// PCI slot
|
||||
printk_info("setting pci slot\n");
|
||||
pci_assign_irqs(0, 0x14, slotIrqs);
|
||||
|
@ -59,10 +67,27 @@ static void pci_routing_fixup(void)
|
|||
pci_assign_irqs(0, 0x11, vt8235Irqs);
|
||||
}
|
||||
|
||||
static unsigned char vt1211hwmonitorinits[]={
|
||||
0x10,0x3, 0x11,0x10, 0x12,0xd, 0x13,0x7f,
|
||||
0x14,0x21, 0x15,0x81, 0x16,0xbd, 0x17,0x8a,
|
||||
0x18,0x0, 0x19,0x0, 0x1a,0x0, 0x1b,0x0,
|
||||
0x1d,0xff, 0x1e,0x0, 0x1f,0x73, 0x20,0x67,
|
||||
0x21,0xc1, 0x22,0xca, 0x23,0x74, 0x24,0xc2,
|
||||
0x25,0xc7, 0x26,0xc9, 0x27,0x7f, 0x29,0x0,
|
||||
0x2a,0x0, 0x2b,0xff, 0x2c,0x0, 0x2d,0xff,
|
||||
0x2e,0x0, 0x2f,0xff, 0x30,0x0, 0x31,0xff,
|
||||
0x32,0x0, 0x33,0xff, 0x34,0x0, 0x39,0xff,
|
||||
0x3a,0x0, 0x3b,0xff, 0x3c,0xff, 0x3d,0xff,
|
||||
0x3e,0x0, 0x3f,0xb0, 0x43,0xff, 0x44,0xff,
|
||||
0x46,0xff, 0x47,0x50, 0x4a,0x3, 0x4b,0xc0,
|
||||
0x4c,0x0, 0x4d,0x0, 0x4e,0xf, 0x5d,0x77,
|
||||
0x5c,0x0, 0x5f,0x33, 0x40,0x1};
|
||||
|
||||
void
|
||||
mainboard_fixup()
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
int i;
|
||||
printk_info("Mainboard fixup\n");
|
||||
|
||||
northbridge_fixup();
|
||||
|
@ -74,8 +99,64 @@ final_southbridge_fixup()
|
|||
{
|
||||
printk_info("Southbridge fixup\n");
|
||||
|
||||
nvram_on();
|
||||
pci_routing_fixup();
|
||||
// nvram_on();
|
||||
// pci_routing_fixup();
|
||||
northbridge_fixup();
|
||||
southbridge_fixup();
|
||||
|
||||
dev = pci_find_device(PCI_VENDOR_ID_VIA, 0x3123, 0);
|
||||
if(dev) {
|
||||
// enable shadow RAM for c0000-cffff
|
||||
pci_write_config_byte(dev, 0x61, 0xff);
|
||||
// enable 2x + 4x agp
|
||||
pci_write_config_byte(dev, 0xac, 0x2f);
|
||||
pci_write_config_byte(dev, 0xae, 0x04);
|
||||
}
|
||||
|
||||
|
||||
// Activate the vt1211 hardware monitor
|
||||
outb(0x87,0x2e); // enter config mode part a
|
||||
outb(0x87,0x2e); // enter config mode part b
|
||||
outb(7,0x2e); // device index#
|
||||
outb(0x0b,0x2f); // select hardware monitor LDN
|
||||
outb(0x30,0x2e); // activate index#
|
||||
outb(1,0x2f);
|
||||
outb(0xaa,0x2e); // exit config mode
|
||||
|
||||
|
||||
// initialize vt1211 hardware monitor registers, which are at 0xECXX
|
||||
for(i=0;i<sizeof(vt1211hwmonitorinits);i+=2)
|
||||
outb(vt1211hwmonitorinits[i+1],0xec00+vt1211hwmonitorinits[i]);
|
||||
|
||||
// clear out cmos contents, it seems to cause trouble
|
||||
for(i=14;i<256;++i)
|
||||
{
|
||||
outb(i,0x74);
|
||||
outb(0,0x75);
|
||||
}
|
||||
#ifdef CONFIG_EPIAMVERSIONSTRING
|
||||
// Use CMOS bytes 128+ to store version string
|
||||
for(i=0;;++i)
|
||||
{
|
||||
char c;
|
||||
outb(i+128,0x74);
|
||||
c=CONFIG_EPIAMVERSIONSTRING[i];
|
||||
outb(c,0x75);
|
||||
if(!c) break;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void write_protect_vgabios(void)
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
|
||||
printk_info("write_protect_vgabios\n");
|
||||
dev = pci_find_device(PCI_VENDOR_ID_VIA, 0x3123, 0);
|
||||
if(dev)
|
||||
pci_write_config_byte(dev, 0x61, 0xaa);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -85,3 +166,33 @@ final_mainboard_fixup()
|
|||
final_southbridge_fixup();
|
||||
}
|
||||
|
||||
int handleint21( unsigned long *edi, unsigned long *esi, unsigned long *ebp,
|
||||
unsigned long *esp, unsigned long *ebx, unsigned long *edx,
|
||||
unsigned long *ecx, unsigned long *eax, unsigned long *flags)
|
||||
{
|
||||
int res=-1;
|
||||
switch(*eax&0xffff)
|
||||
{
|
||||
case 0x5f19:
|
||||
break;
|
||||
case 0x5f18:
|
||||
*eax=0x5f;
|
||||
*ebx=0x15; // MCLK = 133, 32M frame buffer
|
||||
res=0;
|
||||
break;
|
||||
case 0x5f02:
|
||||
*eax=0x5f;
|
||||
*ebx=0 | (3<<8);
|
||||
*ecx=5 | (0<<8) | (0<<16);
|
||||
res=0;
|
||||
break;
|
||||
case 0x5f0f:
|
||||
*eax=0x5f;
|
||||
*ebx=0;
|
||||
*ecx=0;
|
||||
*edx=0;
|
||||
res=0;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -37,10 +37,23 @@ raminit:
|
|||
CS_WRITE($0x55, $0x07)
|
||||
|
||||
/* DRAM MA Map Type */
|
||||
CS_WRITE($0x58, $0xc0)
|
||||
/* CS_WRITE($0x58, $0xc0)*/
|
||||
//#define GETCHIP
|
||||
#undef GETCHIP
|
||||
#ifndef GETCHIP
|
||||
CS_WRITE($0x58, $0x71) // was 60 was 0x71 (DA) 20030722
|
||||
#else
|
||||
CS_WRITE($0x58, $0x40) // For GET memory
|
||||
#endif
|
||||
|
||||
|
||||
/* DRAM bank 0 - 3 size = 512M */
|
||||
#ifndef GETCHIP
|
||||
CS_WRITE($0x5a, $0x08)
|
||||
#else
|
||||
CS_WRITE($0x5a, $0x04) // For GET memory
|
||||
#endif
|
||||
|
||||
CS_WRITE($0x5b, $0x08)
|
||||
CS_WRITE($0x5c, $0x08)
|
||||
CS_WRITE($0x5d, $0x08)
|
||||
|
@ -54,11 +67,19 @@ raminit:
|
|||
/* DRAM Arbitration Timer */
|
||||
CS_WRITE($0x65, $0x32)
|
||||
CS_WRITE($0x66, $0x01)
|
||||
CS_WRITE($0x68, $0x41)
|
||||
#ifndef GETCHIP
|
||||
CS_WRITE($0x68, $0x59) // was 0xf0 was 0x59 (DA) 20030722
|
||||
#else
|
||||
CS_WRITE($0x68, $0x55) // GET
|
||||
#endif
|
||||
|
||||
/* DRAM Frequency */
|
||||
CS_WRITE($0x54, $0xe0)
|
||||
CS_WRITE($0x69, $0x25)
|
||||
#ifndef GETCHIP
|
||||
CS_WRITE($0x69, $0x2d)
|
||||
#else
|
||||
CS_WRITE($0x69, $0x25) // GET
|
||||
#endif
|
||||
|
||||
/* Enable CKE */
|
||||
CS_WRITE($0x6b, $0x10)
|
||||
|
@ -67,61 +88,82 @@ raminit:
|
|||
CS_WRITE($0x6a, $0x00)
|
||||
|
||||
/* Set heavy drive */
|
||||
#ifndef GETCHIP
|
||||
CS_WRITE($0x6d, $0x44)
|
||||
#else
|
||||
CS_WRITE($0x6d, $0x55) // GET
|
||||
CS_WRITE($0x6c, $0x84) // GET
|
||||
#endif
|
||||
|
||||
xorl %esi,%esi
|
||||
ritop:
|
||||
/* NOP Command Enable */
|
||||
CS_WRITE($0x6b, $0x01)
|
||||
/* read a double word from any address of the dimm */
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f000(%esi), %eax
|
||||
DELAY(loop200)
|
||||
|
||||
/* All bank Precharge Command Enable */
|
||||
CS_WRITE($0x6b, $0x02)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f100(%esi), %eax
|
||||
|
||||
/* MSR Enable */
|
||||
CS_WRITE($0x6b, $0x03)
|
||||
/* read 0x2000h */
|
||||
movl $0x2000, %esi
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x2000(%esi), %eax
|
||||
// movl $0x2000,%esi
|
||||
// movl (%esi), %eax
|
||||
// movl $0x4002000, %ecx
|
||||
// movl (%esi), %eax
|
||||
|
||||
|
||||
/* read 0x800h */
|
||||
movl $0x800, %esi
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x800(%esi), %eax
|
||||
// movl $0x800,%esi
|
||||
// movl (%esi), %eax
|
||||
// movl $0x4000800, %esi
|
||||
// movl (%esi), %eax
|
||||
|
||||
/* All banks Precharge Command Enable */
|
||||
CS_WRITE($0x6b, $0x02)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f200(%esi), %eax
|
||||
|
||||
/* CBR Cycle Enable */
|
||||
CS_WRITE($0x6b, $0x04)
|
||||
/* Read 8 times */
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f300(%esi), %eax
|
||||
DELAY(loop100)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f400(%esi), %eax
|
||||
DELAY(loop100)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f500(%esi), %eax
|
||||
DELAY(loop100)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f600(%esi), %eax
|
||||
DELAY(loop100)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f700(%esi), %eax
|
||||
DELAY(loop100)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f800(%esi), %eax
|
||||
DELAY(loop100)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1f900(%esi), %eax
|
||||
DELAY(loop100)
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x1fa00(%esi), %eax
|
||||
DELAY(loop100)
|
||||
|
||||
/* MSR Enable */
|
||||
CS_WRITE($0x6b, $0x03)
|
||||
/* 0x150 if CAS Latency 2 or 0x350 CAS Latency 2.5 */
|
||||
movl $0x350, %esi
|
||||
movl %ds:(%esi), %eax
|
||||
movl 0x350(%esi), %ecx
|
||||
// movl (%ecx), %eax
|
||||
// movl $0x4000350, %ecx
|
||||
// movl (%ecx), %eax
|
||||
|
||||
/* Normal SDRAM Mode */
|
||||
CS_WRITE($0x6b, $0x58)
|
||||
|
||||
#ifdef GETCHIP
|
||||
addl $0x40*0x100000,%esi
|
||||
cmpl $0x80*0x100000,%esi
|
||||
jne ritop
|
||||
#endif
|
||||
/* Set the refreash rate */
|
||||
CS_WRITE($0x6a, $0x43)
|
||||
CS_WRITE($0x67, $0x22)
|
||||
|
|
Loading…
Add table
Reference in a new issue