d9d3b14dff9d00eacd015c6228275102e7d7a23a
[coreboot.git] / src / mainboard / digitallogic / msm586seg / mainboard.c
1 #include <console/console.h>
2 #include <device/device.h>
3 #include <device/pci.h>
4 #include <device/pci_ids.h>
5 #include <device/pci_ops.h>
6 #include <cpu/amd/sc520.h>
7 #include "chip.h"
8
9
10 static void irqdump()
11 {
12   volatile unsigned char *irq;
13   void *mmcr;
14
15
16   int i;
17   int irqlist[] = {0xd00, 0xd02, 0xd03, 0xd04, 0xd08, 0xd0a,
18                 0xd14, 0xd18, 0xd1a, 0xd1b, 0xd1c,
19                 0xd20, 0xd21, 0xd22, 0xd28, 0xd29, 
20                 0xd30, 0xd31, 0xd32, 0xd33,
21                 0xd40, 0xd41, 0xd42, 0xd43,0xd44, 0xd45, 0xd46, 
22                 0xd50, 0xd51, 0xd52, 0xd53,0xd54, 0xd55, 0xd56, 0xd57,0xd58, 0xd59, 0xd5a, 
23                 -1};
24   mmcr = (void *) 0xfffef000;
25
26   printk_err("mmcr is %p\n", mmcr);
27   for(i = 0; irqlist[i] >= 0; i++) {
28     irq = mmcr + irqlist[i];
29     printk_err("0x%x register @%p is 0x%lx\n", irqlist[i], irq, *irq);
30   }
31
32 }
33
34 /* TODO: finish up mmcr struct in sc520.h, and;
35    - set ADDDECTL (now done in raminit.c in cpu/amd/sc520
36 */
37 static void enable_dev(struct device *dev) {
38         volatile struct mmcrpic *pic = MMCRPIC;
39         volatile struct mmcr *mmcr = MMCRDEFAULT;
40
41         /* msm586seg has this register set to a weird value. 
42          * follow the board, not the manual!
43          */
44
45         /* currently, nothing in the device to use, so ignore it. */
46         printk_err("digital logic msm586 seg ENTER %s\n", __func__);
47
48
49         /* from fuctory bios */
50         /* NOTE: the following interrupt settings made interrupts work
51          * for hard drive, and serial, but not for ethernet 
52          */
53         /* just do what they say and nobody gets hurt. */
54         mmcr->pic.pcicr = 0 ; // M_GINT_MODE | M_S1_MODE | M_S2_MODE;
55         /* all ints to level */
56         mmcr->pic.mpicmode = 0;
57         mmcr->pic.sl1picmode = 0;
58         mmcr->pic.sl2picmode = 0x80;
59
60         mmcr->pic.intpinpol = 0;
61
62         mmcr->pic.pit0map = 1;
63         mmcr->pic.uart1map = 0xc;
64         mmcr->pic.uart2map = 0xb;
65         mmcr->pic.rtcmap = 3;
66         mmcr->pic.ferrmap = 8;
67         mmcr->pic.gp0imap = 6;
68         mmcr->pic.gp1imap = 2;
69         mmcr->pic.gp2imap = 7;
70         mmcr->pic.gp6imap = 0x15;
71         mmcr->pic.gp7imap = 0x16;
72         mmcr->pic.gp10imap = 0x9;
73         mmcr->pic.gp9imap = 0x4;
74
75
76
77
78
79         irqdump();
80         printk_err("uart 1 ctl is 0x%x\n", *(unsigned char *) 0xfffefcc0);
81
82         printk_err("0xc20 ctl is 0x%x\n", *(unsigned short *) 0xfffefc20);
83         printk_err("0xc22 0x%x\n", *(unsigned short *) 0xfffefc22b);
84
85         /* The following block has NOT proven sufficient to get
86          * the VGA hardware to talk to us 
87          */
88         /* let's set some mmcr stuff per the BIOS settings */
89         mmcr->dbctl.dbctl = 0x10;
90         mmcr->sysarb.ctl = 6;
91         mmcr->sysarb.menb = 0xf;
92         mmcr->sysarb.prictl = 0xc0000f0f;
93         /* this is bios setting, depends on sysarb above */
94         mmcr->hostbridge.ctl = 0x108;
95         printk_err("digital logic msm586 seg EXIT %s\n", __func__);
96
97         /* pio */
98         mmcr->pio.data31_16 = 0xffbf;
99
100         /* pci stuff */
101         mmcr->pic.pciintamap = 0xa;
102
103         /* END block where vga hardware still will not talk to us */
104         /* all we get from VGA I/O addresses are ffff etc.
105          */
106         mmcr->sysmap.adddecctl = 0x10;
107
108         /* VGA now talks to us, so this adddecctl was the trick. 
109          * still no interrupts from enet. 
110          * Let's try fixing the piodata stuff, as there may be 
111          * some wire there not documented.
112          */
113         mmcr->pio.data31_16 = 0xffbf;
114         /* also, our sl?picmode needs to match fuctory bios */
115         mmcr->pic.sl1picmode = 0x80;
116         mmcr->pic.sl2picmode = 0x0;
117         /* and, finally, they do set gp5imap and we don't. 
118          */
119         mmcr->pic.gp5imap = 0xd;
120         /* remaining problem: almost certainly, the irq table is bogus
121          * NO SHOCK as it came from fuctory bios. 
122          * but let's try these 4 changes for now and see what shakes.
123          */
124         /* still not interrupts. */
125         /* their IRQ table is wrong. Just hardwire it */
126         {
127           char pciints[4] = {15, 15, 15, 15};
128           pci_assign_irqs(0, 12, pciints);
129         }
130         /* the assigned failed but we just noticed -- there is no
131          * dma mapping, and selftest on e100 requires that dma work
132          */
133         /* follow fuctory here */
134         mmcr->dmacontrol.extchanmapa = 0x3210;
135 }
136 struct chip_operations mainboard_ops = {
137         CHIP_NAME("DIGITAL-LOGIC MSM586SEG Mainboard")
138         .enable_dev = enable_dev
139 };
140