blob: 249862a5a4fddab52b7a921f60d3434a270b8ae1 [file] [log] [blame]
wdenkc6097192002-11-03 00:24:07 +00001/*
2 * (C) Copyright 2001
3 * Rob Taylor, Flying Pig Systems. robt@flyingpig.com.
4 *
5 * (C) Copyright 2002
6 * Gregory E. Allen, gallen@arlut.utexas.edu
7 * Matthew E. Karger, karger@arlut.utexas.edu
8 * Applied Research Laboratories, The University of Texas at Austin
9 *
10 * See file CREDITS for list of people who contributed to this
11 * project.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26 * MA 02111-1307 USA
27 */
28
29#include <common.h>
30#include <mpc824x.h>
31#include <asm/processor.h>
32#include <asm/io.h>
33#include <pci.h>
34
35#define SAVE_SZ 32
36
37
38int checkboard(void)
39{
40 ulong busfreq = get_bus_freq(0);
41 char buf[32];
42
43 printf("Board: UTX8245 Local Bus at %s MHz\n", strmhz(buf, busfreq));
44 return 0;
45}
46
47
48long int initdram(int board_type)
49{
50#if 1
51 int i, cnt;
52 volatile uchar *base = CFG_SDRAM_BASE;
53 volatile ulong *addr;
54 ulong save[SAVE_SZ];
55 ulong val, ret = 0;
56
57 for (i=0; i<SAVE_SZ; i++) {save[i] = 0;} /* clear table */
58
59 for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1)
60 {
61 addr = (volatile ulong *)base + cnt;
62 save[i++] = *addr;
63 *addr = ~cnt;
64 }
65
66 addr = (volatile ulong *)base;
67 save[i] = *addr;
68 *addr = 0;
69
70 if (*addr != 0)
71 {
72 *addr = save[i];
73 goto Done;
74 }
75
76 for (cnt = 1; cnt < CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1)
77 {
78 addr = (volatile ulong *)base + cnt;
79 val = *addr;
80 *addr = save[--i];
81 if (val != ~cnt)
82 {
83 ulong new_bank0_end = cnt * sizeof(long) - 1;
84 ulong mear1 = mpc824x_mpc107_getreg(MEAR1);
85 ulong emear1 = mpc824x_mpc107_getreg(EMEAR1);
86 mear1 = (mear1 & 0xFFFFFF00) |
87 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
88 emear1 = (emear1 & 0xFFFFFF00) |
89 ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
90 mpc824x_mpc107_setreg(MEAR1, mear1);
91 mpc824x_mpc107_setreg(EMEAR1, emear1);
92
93 ret = cnt * sizeof(long);
94 goto Done;
95 }
96 }
97
98 ret = CFG_MAX_RAM_SIZE;
99Done:
100 return ret;
101#else
102 return (CFG_MAX_RAM_SIZE);
103#endif
104
105}
106
107
108/*
109 * Initialize PCI Devices, report devices found.
110 */
111
112static struct pci_config_table pci_utx8245_config_table[] = {
113#ifndef CONFIG_PCI_PNP
114 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
115 pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
116 PCI_ENET0_MEMADDR,
117 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
118 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
119 pci_cfgfunc_config_device, { PCI_FIREWIRE_IOADDR,
120 PCI_FIREWIRE_MEMADDR,
121 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER }},
122#endif /*CONFIG_PCI_PNP*/
123 { }
124};
125
126
127static void pci_utx8245_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
128{
129 if (PCI_DEV(dev) == 11)
130 /* assign serial interrupt line 9 (int25) to FireWire */
131 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, 25);
132
133 else if (PCI_DEV(dev) == 12)
134 /* assign serial interrupt line 8 (int24) to Ethernet */
135 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, 24);
136}
137
138static struct pci_controller utx8245_hose = {
139#ifndef CONFIG_PCI_PNP
140 config_table: pci_utx8245_config_table,
141 fixup_irq: pci_utx8245_fixup_irq,
142 write_byte: pci_hose_write_config_byte
143#endif /*CONFIG_PCI_PNP*/
144};
145
146void pci_init (void)
147{
148 pci_mpc824x_init(&utx8245_hose);
149
150 icache_enable();
151}
152