blob: 9c6deeabcfd9b4b3f51c179ef34003244a29ae58 [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 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Stefan Roesefdf21b12007-03-21 13:39:57 +01006 */
7
8#include <common.h>
9#include <asm/processor.h>
10
11extern void board_pll_init_f(void);
12
Stefan Roese1e088bf2007-04-18 12:07:47 +020013static void acadia_gpio_init(void)
Stefan Roesefdf21b12007-03-21 13:39:57 +010014{
15 /*
16 * GPIO0 setup (select GPIO or alternate function)
17 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020018 out32(GPIO0_OSRL, CONFIG_SYS_GPIO0_OSRL);
19 out32(GPIO0_OSRH, CONFIG_SYS_GPIO0_OSRH); /* output select */
20 out32(GPIO0_ISR1L, CONFIG_SYS_GPIO0_ISR1L);
21 out32(GPIO0_ISR1H, CONFIG_SYS_GPIO0_ISR1H); /* input select */
22 out32(GPIO0_TSRL, CONFIG_SYS_GPIO0_TSRL);
23 out32(GPIO0_TSRH, CONFIG_SYS_GPIO0_TSRH); /* three-state select */
24 out32(GPIO0_TCR, CONFIG_SYS_GPIO0_TCR); /* enable output driver for outputs */
Stefan Roesefdf21b12007-03-21 13:39:57 +010025
26 /*
27 * Ultra (405EZ) was nice enough to add another GPIO controller
28 */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020029 out32(GPIO1_OSRH, CONFIG_SYS_GPIO1_OSRH); /* output select */
30 out32(GPIO1_OSRL, CONFIG_SYS_GPIO1_OSRL);
31 out32(GPIO1_ISR1H, CONFIG_SYS_GPIO1_ISR1H); /* input select */
32 out32(GPIO1_ISR1L, CONFIG_SYS_GPIO1_ISR1L);
33 out32(GPIO1_TSRH, CONFIG_SYS_GPIO1_TSRH); /* three-state select */
34 out32(GPIO1_TSRL, CONFIG_SYS_GPIO1_TSRL);
35 out32(GPIO1_TCR, CONFIG_SYS_GPIO1_TCR); /* enable output driver for outputs */
Stefan Roesefdf21b12007-03-21 13:39:57 +010036}
Stefan Roesefdf21b12007-03-21 13:39:57 +010037
38int board_early_init_f(void)
39{
40 unsigned int reg;
41
Stefan Roese80d99a42007-06-19 16:42:31 +020042#if !defined(CONFIG_NAND_U_BOOT)
Stefan Roese1e088bf2007-04-18 12:07:47 +020043 /* don't reinit PLL when booting via I2C bootstrap option */
Stefan Roese918010a2009-09-09 16:25:29 +020044 mfsdr(SDR0_PINSTP, reg);
Stefan Roese1e088bf2007-04-18 12:07:47 +020045 if (reg != 0xf0000000)
46 board_pll_init_f();
Stefan Roese80d99a42007-06-19 16:42:31 +020047#endif
Stefan Roese1e088bf2007-04-18 12:07:47 +020048
49 acadia_gpio_init();
Stefan Roesefdf21b12007-03-21 13:39:57 +010050
Stefan Roesed2f223e2007-05-24 08:22:09 +020051 /* Configure 405EZ for NAND usage */
Stefan Roese918010a2009-09-09 16:25:29 +020052 mtsdr(SDR0_NAND0, SDR_NAND0_NDEN | SDR_NAND0_NDAREN | SDR_NAND0_NDRBEN);
53 mfsdr(SDR0_ULTRA0, reg);
Stefan Roese23d8d342007-06-06 11:42:13 +020054 reg &= ~SDR_ULTRA0_CSN_MASK;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020055 reg |= (SDR_ULTRA0_CSNSEL0 >> CONFIG_SYS_NAND_CS) |
Stefan Roese23d8d342007-06-06 11:42:13 +020056 SDR_ULTRA0_NDGPIOBP |
57 SDR_ULTRA0_EBCRDYEN |
58 SDR_ULTRA0_NFSRSTEN;
Stefan Roese918010a2009-09-09 16:25:29 +020059 mtsdr(SDR0_ULTRA0, reg);
Stefan Roesed2f223e2007-05-24 08:22:09 +020060
Stefan Roesefdf21b12007-03-21 13:39:57 +010061 /* USB Host core needs this bit set */
Stefan Roese918010a2009-09-09 16:25:29 +020062 mfsdr(SDR0_ULTRA1, reg);
63 mtsdr(SDR0_ULTRA1, reg | SDR_ULTRA1_LEDNENABLE);
Stefan Roesefdf21b12007-03-21 13:39:57 +010064
Stefan Roese707fd362009-09-24 09:55:50 +020065 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
66 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
67 mtdcr(UIC0CR, 0x00000010);
68 mtdcr(UIC0PR, 0xFE7FFFF0); /* set int polarities */
69 mtdcr(UIC0TR, 0x00000010); /* set int trigger levels */
70 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
Stefan Roesefdf21b12007-03-21 13:39:57 +010071
72 return 0;
73}
74
75int misc_init_f(void)
76{
77 /* Set EPLD to take PHY out of reset */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020078 out8(CONFIG_SYS_CPLD_BASE + 0x05, 0x00);
Stefan Roesefdf21b12007-03-21 13:39:57 +010079 udelay(100000);
80
81 return 0;
82}
83
84/*
85 * Check Board Identity:
86 */
87int checkboard(void)
88{
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +000089 char buf[64];
90 int i = getenv_f("serial#", buf, sizeof(buf));
Stefan Roesed2f223e2007-05-24 08:22:09 +020091 u8 rev;
92
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020093 rev = in8(CONFIG_SYS_CPLD_BASE + 0);
Stefan Roesed2f223e2007-05-24 08:22:09 +020094 printf("Board: Acadia - AMCC PPC405EZ Evaluation Board, Rev. %X", rev);
Stefan Roesefdf21b12007-03-21 13:39:57 +010095
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +000096 if (i > 0) {
Stefan Roesefdf21b12007-03-21 13:39:57 +010097 puts(", serial# ");
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +000098 puts(buf);
Stefan Roesefdf21b12007-03-21 13:39:57 +010099 }
100 putc('\n');
101
102 return (0);
103}