3ce22f0e9ed65fbdf7a5697324a896f92738c75a
[coreboot.git] / src / mainboard / technologic / ts5300 / 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         extern unsigned char *rom_start, *rom_end;
39         volatile struct mmcrpic *pic = MMCRPIC;
40         volatile struct mmcr *mmcr = MMCRDEFAULT;
41
42         /* currently, nothing in the device to use, so ignore it. */
43         printk_err("Technologic Systems 5300 ENTER %s\n", __func__);
44
45         /* from fuctory bios */
46         /* NOTE: the following interrupt settings made interrupts work
47          * for hard drive, and serial, but not for ethernet 
48          */
49
50         printk_err("Setting up PIC\n");
51         /* just do what they say and nobody gets hurt. */
52         mmcr->pic.pcicr = 0 ;
53         /* all ints to level */
54         mmcr->pic.mpicmode = 0;
55         mmcr->pic.sl1picmode = 0;
56         mmcr->pic.sl2picmode = 0;
57
58         mmcr->pic.intpinpol = 0x100;
59
60         mmcr->pic.pit0map = 1;
61         mmcr->pic.uart1map = 0x0c;
62         mmcr->pic.uart2map = 0x0b;
63         mmcr->pic.rtcmap  = 0x03;
64         mmcr->pic.ferrmap = 0x00;
65         mmcr->pic.intpinpol = 0x100;
66         
67         mmcr->pic.gp0imap = 0x00;
68         mmcr->pic.gp1imap = 0x02;
69         mmcr->pic.gp2imap = 0x07;
70         mmcr->pic.gp3imap = 0x05;
71         mmcr->pic.gp4imap = 0x06;
72         mmcr->pic.gp5imap = 0x0d;
73         mmcr->pic.gp6imap = 0x15;
74         mmcr->pic.gp7imap = 0x16;
75         mmcr->pic.gp8imap = 0x3;
76         mmcr->pic.gp9imap = 0x4;
77         mmcr->pic.gp10imap = 0x9;
78
79         // irqdump();
80
81         printk_err("Setting up sysarb\n");
82         mmcr->dbctl.dbctl = 0x01;
83         mmcr->sysarb.ctl = 0x00;
84         mmcr->sysarb.menb = 0x1f;
85         mmcr->sysarb.prictl = 0x40000f0f;
86         
87         /* this is bios setting, depends on sysarb above */
88         mmcr->hostbridge.ctl = 0x0;
89         mmcr->hostbridge.tgtirqctl = 0x0;
90         mmcr->hostbridge.tgtirqsta = 0xf00;
91         mmcr->hostbridge.mstirqctl = 0x0;
92         mmcr->hostbridge.mstirqsta = 0x708;
93
94         printk_err("Setting up pio\n");
95         /* pio */
96         mmcr->pio.pfs15_0 = 0xffff;
97         mmcr->pio.pfs31_16 = 0xffff;
98         mmcr->pio.cspfs = 0xfe;
99         mmcr->pio.clksel = 0x13;
100         mmcr->pio.dsctl = 0x200;
101         mmcr->pio.data15_0 = 0xde04;
102         mmcr->pio.data31_16 = 0xef9f;
103
104         printk_err("Setting up sysmap\n");
105         /* system memory map */
106         mmcr->sysmap.adddecctl = 0x04;
107         mmcr->sysmap.wpvsta = 0x8006;
108         mmcr->sysmap.par[1] = 0x340f0070;
109         mmcr->sysmap.par[2] = 0x380701f0;
110         mmcr->sysmap.par[3] = 0x3c0103f6;
111         mmcr->sysmap.par[4] = 0x2c0f0300;
112         mmcr->sysmap.par[5] = 0x447c00a0;
113         mmcr->sysmap.par[6] = 0xe600000c;
114         mmcr->sysmap.par[7] = 0x300046e8;
115         mmcr->sysmap.par[8] = 0x500400d0;
116         mmcr->sysmap.par[9] = 0x281f0140;
117         mmcr->sysmap.par[13] = 0x8a07c940;
118         mmcr->sysmap.par[15] = 0xee00400e;
119
120         printk_err("Setting up gpctl\n");
121         mmcr->gpctl.gpcsrt = 0x01;
122         mmcr->gpctl.gpcspw = 0x09;
123         mmcr->gpctl.gpcsoff = 0x01;
124         mmcr->gpctl.gprdw = 0x07;
125         mmcr->gpctl.gprdoff = 0x02;
126         mmcr->gpctl.gpwrw = 0x07;
127         mmcr->gpctl.gpwroff = 0x02;
128         
129         //mmcr->reset.sysinfo = 0xdf;
130         //mmcr->reset.rescfg = 0x5;
131         /* their IRQ table is wrong. Just hardwire it */
132         //{
133         //  char pciints[4] = {15, 15, 15, 15};
134         //  pci_assign_irqs(0, 12, pciints);
135         //}
136         /* the assigned failed but we just noticed -- there is no
137          * dma mapping, and selftest on e100 requires that dma work
138          */
139         mmcr->dmacontrol.extchanmapa = 0xf210;
140         mmcr->dmacontrol.extchanmapb = 0xffff;
141
142         /* hack for IDIOTIC need to fix rom_start */
143         printk_err("Patching rom_start due to sc520 limits\n");
144         rom_start = 0x09400000 + 0xe0000;
145         rom_end = rom_start + PAYLOAD_SIZE - 1;
146
147         printk_err("TS5300 EXIT %s\n", __func__);
148         
149 }
150
151 struct chip_operations mainboard_ops = {
152         CHIP_NAME("Technologic Systems TS-5300 Mainboard")
153         .enable_dev = enable_dev
154 };
155