blob: 68a99bd1ee92823aa36b54ebf204e47498c18fbb [file] [log] [blame]
Stefan Roesefdf21b12007-03-21 13:39:57 +01001/*
2 * (C) Copyright 2007
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <asm/processor.h>
26
27extern void board_pll_init_f(void);
28
Stefan Roese1e088bf2007-04-18 12:07:47 +020029static void acadia_gpio_init(void)
Stefan Roesefdf21b12007-03-21 13:39:57 +010030{
31 /*
32 * GPIO0 setup (select GPIO or alternate function)
33 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020034 out32(GPIO0_OSRL, CONFIG_SYS_GPIO0_OSRL);
35 out32(GPIO0_OSRH, CONFIG_SYS_GPIO0_OSRH); /* output select */
36 out32(GPIO0_ISR1L, CONFIG_SYS_GPIO0_ISR1L);
37 out32(GPIO0_ISR1H, CONFIG_SYS_GPIO0_ISR1H); /* input select */
38 out32(GPIO0_TSRL, CONFIG_SYS_GPIO0_TSRL);
39 out32(GPIO0_TSRH, CONFIG_SYS_GPIO0_TSRH); /* three-state select */
40 out32(GPIO0_TCR, CONFIG_SYS_GPIO0_TCR); /* enable output driver for outputs */
Stefan Roesefdf21b12007-03-21 13:39:57 +010041
42 /*
43 * Ultra (405EZ) was nice enough to add another GPIO controller
44 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020045 out32(GPIO1_OSRH, CONFIG_SYS_GPIO1_OSRH); /* output select */
46 out32(GPIO1_OSRL, CONFIG_SYS_GPIO1_OSRL);
47 out32(GPIO1_ISR1H, CONFIG_SYS_GPIO1_ISR1H); /* input select */
48 out32(GPIO1_ISR1L, CONFIG_SYS_GPIO1_ISR1L);
49 out32(GPIO1_TSRH, CONFIG_SYS_GPIO1_TSRH); /* three-state select */
50 out32(GPIO1_TSRL, CONFIG_SYS_GPIO1_TSRL);
51 out32(GPIO1_TCR, CONFIG_SYS_GPIO1_TCR); /* enable output driver for outputs */
Stefan Roesefdf21b12007-03-21 13:39:57 +010052}
Stefan Roesefdf21b12007-03-21 13:39:57 +010053
54int board_early_init_f(void)
55{
56 unsigned int reg;
57
Stefan Roese80d99a42007-06-19 16:42:31 +020058#if !defined(CONFIG_NAND_U_BOOT)
Stefan Roese1e088bf2007-04-18 12:07:47 +020059 /* don't reinit PLL when booting via I2C bootstrap option */
Stefan Roese918010a2009-09-09 16:25:29 +020060 mfsdr(SDR0_PINSTP, reg);
Stefan Roese1e088bf2007-04-18 12:07:47 +020061 if (reg != 0xf0000000)
62 board_pll_init_f();
Stefan Roese80d99a42007-06-19 16:42:31 +020063#endif
Stefan Roese1e088bf2007-04-18 12:07:47 +020064
65 acadia_gpio_init();
Stefan Roesefdf21b12007-03-21 13:39:57 +010066
Stefan Roesed2f223e2007-05-24 08:22:09 +020067 /* Configure 405EZ for NAND usage */
Stefan Roese918010a2009-09-09 16:25:29 +020068 mtsdr(SDR0_NAND0, SDR_NAND0_NDEN | SDR_NAND0_NDAREN | SDR_NAND0_NDRBEN);
69 mfsdr(SDR0_ULTRA0, reg);
Stefan Roese23d8d342007-06-06 11:42:13 +020070 reg &= ~SDR_ULTRA0_CSN_MASK;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020071 reg |= (SDR_ULTRA0_CSNSEL0 >> CONFIG_SYS_NAND_CS) |
Stefan Roese23d8d342007-06-06 11:42:13 +020072 SDR_ULTRA0_NDGPIOBP |
73 SDR_ULTRA0_EBCRDYEN |
74 SDR_ULTRA0_NFSRSTEN;
Stefan Roese918010a2009-09-09 16:25:29 +020075 mtsdr(SDR0_ULTRA0, reg);
Stefan Roesed2f223e2007-05-24 08:22:09 +020076
Stefan Roesefdf21b12007-03-21 13:39:57 +010077 /* USB Host core needs this bit set */
Stefan Roese918010a2009-09-09 16:25:29 +020078 mfsdr(SDR0_ULTRA1, reg);
79 mtsdr(SDR0_ULTRA1, reg | SDR_ULTRA1_LEDNENABLE);
Stefan Roesefdf21b12007-03-21 13:39:57 +010080
Stefan Roese707fd362009-09-24 09:55:50 +020081 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
82 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
83 mtdcr(UIC0CR, 0x00000010);
84 mtdcr(UIC0PR, 0xFE7FFFF0); /* set int polarities */
85 mtdcr(UIC0TR, 0x00000010); /* set int trigger levels */
86 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
Stefan Roesefdf21b12007-03-21 13:39:57 +010087
88 return 0;
89}
90
91int misc_init_f(void)
92{
93 /* Set EPLD to take PHY out of reset */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020094 out8(CONFIG_SYS_CPLD_BASE + 0x05, 0x00);
Stefan Roesefdf21b12007-03-21 13:39:57 +010095 udelay(100000);
96
97 return 0;
98}
99
100/*
101 * Check Board Identity:
102 */
103int checkboard(void)
104{
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +0000105 char buf[64];
106 int i = getenv_f("serial#", buf, sizeof(buf));
Stefan Roesed2f223e2007-05-24 08:22:09 +0200107 u8 rev;
108
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200109 rev = in8(CONFIG_SYS_CPLD_BASE + 0);
Stefan Roesed2f223e2007-05-24 08:22:09 +0200110 printf("Board: Acadia - AMCC PPC405EZ Evaluation Board, Rev. %X", rev);
Stefan Roesefdf21b12007-03-21 13:39:57 +0100111
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +0000112 if (i > 0) {
Stefan Roesefdf21b12007-03-21 13:39:57 +0100113 puts(", serial# ");
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +0000114 puts(buf);
Stefan Roesefdf21b12007-03-21 13:39:57 +0100115 }
116 putc('\n');
117
118 return (0);
119}