summaryrefslogtreecommitdiffstats
path: root/board/amcc/acadia/acadia.c
blob: c8aaad2d785ee72f37ce30a2d79783079750a688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
 * (C) Copyright 2007
 * Stefan Roese, DENX Software Engineering, sr@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <common.h>
#include <asm/processor.h>

extern void board_pll_init_f(void);

/* Some specific Acadia Defines */
#define CPLD_BASE	0x80000000

void liveoak_gpio_init(void)
{
	/*
	 * GPIO0 setup (select GPIO or alternate function)
	 */
       	out32(GPIO0_OSRL, CFG_GPIO0_OSRL);
       	out32(GPIO0_OSRH, CFG_GPIO0_OSRH);	/* output select */
       	out32(GPIO0_ISR1L, CFG_GPIO0_ISR1L);
       	out32(GPIO0_ISR1H, CFG_GPIO0_ISR1H);	/* input select */
       	out32(GPIO0_TSRL, CFG_GPIO0_TSRL);
       	out32(GPIO0_TSRH, CFG_GPIO0_TSRH);	/* three-state select */
       	out32(GPIO0_TCR, CFG_GPIO0_TCR);  /* enable output driver for outputs */

	/*
	 * Ultra (405EZ) was nice enough to add another GPIO controller
	 */
	out32(GPIO1_OSRH, CFG_GPIO1_OSRH);	/* output select */
	out32(GPIO1_OSRL, CFG_GPIO1_OSRL);
	out32(GPIO1_ISR1H, CFG_GPIO1_ISR1H);	/* input select */
	out32(GPIO1_ISR1L, CFG_GPIO1_ISR1L);
	out32(GPIO1_TSRH, CFG_GPIO1_TSRH);	/* three-state select */
	out32(GPIO1_TSRL, CFG_GPIO1_TSRL);
	out32(GPIO1_TCR, CFG_GPIO1_TCR);  /* enable output driver for outputs */
}

#if 0 /* test-only: not called at all??? */
void ext_bus_cntlr_init(void)
{
#if (defined(EBC_PB4AP) && defined(EBC_PB4CR) && !(CFG_INIT_DCACHE_CS == 4))
       	mtebc(pb4ap, EBC_PB4AP);
       	mtebc(pb4cr, EBC_PB4CR);
#endif
}
#endif

int board_early_init_f(void)
{
	unsigned int reg;

#if 0 /* test-only */
	/*
	 * If CRAM memory and SPI/NAND boot, and if the CRAM memory is
	 * already initialized by the pre-loader then we can't reinitialize
	 * CPR registers, GPIO registers and EBC registers as this will
	 * have the effect of un-initializing CRAM.
	 */
	spr_reg = (volatile unsigned long) mfspr(SPRG7);
	if (spr_reg != LOAK_CRAM) { /* != CRAM */
		board_pll_init_f();
		liveoak_gpio_init();
		ext_bus_cntlr_init();

		mtebc(pb1ap, CFG_EBC_PB1AP);
		mtebc(pb1cr, CFG_EBC_PB1CR);

		mtebc(pb2ap, CFG_EBC_PB2AP);
		mtebc(pb2cr, CFG_EBC_PB2CR);
	}
#else
	board_pll_init_f();
	liveoak_gpio_init();
/*	ext_bus_cntlr_init(); */
#endif

#if 0 /* test-only (orig) */
	/*
	 * If we boot from NAND Flash, we are running in
	 * RAM, so disable the EBC_CS0 so that it goes back
	 * to the NOR Flash.  It will be enabled later
	 * for the NAND Flash on EBC_CS1
	 */
	mfsdr(sdrultra0, reg);
	mtsdr(sdrultra0, reg & ~SDR_ULTRA0_CSNSEL0);
#endif
#if 0 /* test-only */
	/* configure for NAND */
	mfsdr(sdrultra0, reg);
	reg &= ~SDR_ULTRA0_CSN_MASK;
	reg |= SDR_ULTRA0_CSNSEL0 >> CFG_NAND_CS;
	mtsdr(sdrultra0, reg & ~SDR_ULTRA0_CSNSEL0);
#endif

	/* USB Host core needs this bit set */
	mfsdr(sdrultra1, reg);
	mtsdr(sdrultra1, reg | SDR_ULTRA1_LEDNENABLE);

	mtdcr(uicsr, 0xFFFFFFFF);	/* clear all ints */
	mtdcr(uicer, 0x00000000);	/* disable all ints */
	mtdcr(uiccr, 0x00000010);
	mtdcr(uicpr, 0xFE7FFFF0);	/* set int polarities */
	mtdcr(uictr, 0x00000010);	/* set int trigger levels */
	mtdcr(uicsr, 0xFFFFFFFF);	/* clear all ints */

	return 0;
}

int misc_init_f(void)
{
	/* Set EPLD to take PHY out of reset */
	out8(CPLD_BASE + 0x05, 0x00);
	udelay(100000);

	return 0;
}

/*
 * Check Board Identity:
 */
int checkboard(void)
{
	char *s = getenv("serial#");

	printf("Board: Acadia - AMCC PPC405EZ Evaluation Board");
	if (s != NULL) {
		puts(", serial# ");
		puts(s);
	}
	putc('\n');

	return (0);
}
OpenPOWER on IntegriCloud