Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 27 | extern void board_pll_init_f(void); |
| 28 | |
Stefan Roese | 1e088bf | 2007-04-18 12:07:47 +0200 | [diff] [blame] | 29 | static void acadia_gpio_init(void) |
Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 30 | { |
| 31 | /* |
| 32 | * GPIO0 setup (select GPIO or alternate function) |
| 33 | */ |
| 34 | out32(GPIO0_OSRL, CFG_GPIO0_OSRL); |
| 35 | out32(GPIO0_OSRH, CFG_GPIO0_OSRH); /* output select */ |
| 36 | out32(GPIO0_ISR1L, CFG_GPIO0_ISR1L); |
| 37 | out32(GPIO0_ISR1H, CFG_GPIO0_ISR1H); /* input select */ |
| 38 | out32(GPIO0_TSRL, CFG_GPIO0_TSRL); |
| 39 | out32(GPIO0_TSRH, CFG_GPIO0_TSRH); /* three-state select */ |
| 40 | out32(GPIO0_TCR, CFG_GPIO0_TCR); /* enable output driver for outputs */ |
| 41 | |
| 42 | /* |
| 43 | * Ultra (405EZ) was nice enough to add another GPIO controller |
| 44 | */ |
| 45 | out32(GPIO1_OSRH, CFG_GPIO1_OSRH); /* output select */ |
| 46 | out32(GPIO1_OSRL, CFG_GPIO1_OSRL); |
| 47 | out32(GPIO1_ISR1H, CFG_GPIO1_ISR1H); /* input select */ |
| 48 | out32(GPIO1_ISR1L, CFG_GPIO1_ISR1L); |
| 49 | out32(GPIO1_TSRH, CFG_GPIO1_TSRH); /* three-state select */ |
| 50 | out32(GPIO1_TSRL, CFG_GPIO1_TSRL); |
| 51 | out32(GPIO1_TCR, CFG_GPIO1_TCR); /* enable output driver for outputs */ |
| 52 | } |
Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 53 | |
| 54 | int board_early_init_f(void) |
| 55 | { |
| 56 | unsigned int reg; |
| 57 | |
Stefan Roese | 1e088bf | 2007-04-18 12:07:47 +0200 | [diff] [blame] | 58 | /* don't reinit PLL when booting via I2C bootstrap option */ |
| 59 | mfsdr(SDR_PINSTP, reg); |
| 60 | if (reg != 0xf0000000) |
| 61 | board_pll_init_f(); |
| 62 | |
| 63 | acadia_gpio_init(); |
Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 64 | |
Stefan Roese | d2f223e | 2007-05-24 08:22:09 +0200 | [diff] [blame] | 65 | /* Configure 405EZ for NAND usage */ |
Stefan Roese | 23d8d34 | 2007-06-06 11:42:13 +0200 | [diff] [blame] | 66 | mtsdr(sdrnand0, SDR_NAND0_NDEN | SDR_NAND0_NDAREN | SDR_NAND0_NDRBEN); |
| 67 | mfsdr(sdrultra0, reg); |
| 68 | reg &= ~SDR_ULTRA0_CSN_MASK; |
| 69 | reg |= (SDR_ULTRA0_CSNSEL0 >> CFG_NAND_CS) | |
| 70 | SDR_ULTRA0_NDGPIOBP | |
| 71 | SDR_ULTRA0_EBCRDYEN | |
| 72 | SDR_ULTRA0_NFSRSTEN; |
| 73 | mtsdr(sdrultra0, reg); |
Stefan Roese | d2f223e | 2007-05-24 08:22:09 +0200 | [diff] [blame] | 74 | |
Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 75 | /* USB Host core needs this bit set */ |
| 76 | mfsdr(sdrultra1, reg); |
| 77 | mtsdr(sdrultra1, reg | SDR_ULTRA1_LEDNENABLE); |
| 78 | |
| 79 | mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 80 | mtdcr(uicer, 0x00000000); /* disable all ints */ |
| 81 | mtdcr(uiccr, 0x00000010); |
| 82 | mtdcr(uicpr, 0xFE7FFFF0); /* set int polarities */ |
| 83 | mtdcr(uictr, 0x00000010); /* set int trigger levels */ |
| 84 | mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 85 | |
| 86 | return 0; |
| 87 | } |
| 88 | |
| 89 | int misc_init_f(void) |
| 90 | { |
| 91 | /* Set EPLD to take PHY out of reset */ |
Stefan Roese | f6c7b76 | 2007-03-24 15:45:34 +0100 | [diff] [blame] | 92 | out8(CFG_CPLD_BASE + 0x05, 0x00); |
Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 93 | udelay(100000); |
| 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | /* |
| 99 | * Check Board Identity: |
| 100 | */ |
| 101 | int checkboard(void) |
| 102 | { |
| 103 | char *s = getenv("serial#"); |
Stefan Roese | d2f223e | 2007-05-24 08:22:09 +0200 | [diff] [blame] | 104 | u8 rev; |
| 105 | |
| 106 | rev = in8(CFG_CPLD_BASE + 0); |
| 107 | printf("Board: Acadia - AMCC PPC405EZ Evaluation Board, Rev. %X", rev); |
Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 108 | |
Stefan Roese | fdf21b1 | 2007-03-21 13:39:57 +0100 | [diff] [blame] | 109 | if (s != NULL) { |
| 110 | puts(", serial# "); |
| 111 | puts(s); |
| 112 | } |
| 113 | putc('\n'); |
| 114 | |
| 115 | return (0); |
| 116 | } |