2
* Copyright 2009-2011 eXMeritus, A Boeing Company
3
* Copyright 2007-2009 Freescale Semiconductor, Inc.
5
* See file CREDITS for list of people who contributed to this
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.
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.
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,
27
#include <asm/processor.h>
29
#include <asm/cache.h>
30
#include <asm/immap_85xx.h>
31
#include <asm/fsl_pci.h>
32
#include <asm/fsl_ddr_sdram.h>
36
#include <linux/ctype.h>
37
#include <fdt_support.h>
40
#include <asm/fsl_law.h>
48
DECLARE_GLOBAL_DATA_PTR;
52
unsigned int gpio_high = 0;
53
unsigned int gpio_low = 0;
54
unsigned int gpio_in = 0;
57
puts("Board: HWW-1U-1A ");
60
* First just figure out which CPU we're on, then use that to
61
* configure the lists of other GPIOs to be programmed.
63
mpc85xx_gpio_set_in(GPIO_CPU_ID);
64
if (hww1u1a_is_cpu_a()) {
67
/* We want to turn on some LEDs */
68
gpio_high |= GPIO_CPUA_CPU_READY;
69
gpio_low |= GPIO_CPUA_DEBUG_LED1;
70
gpio_low |= GPIO_CPUA_DEBUG_LED2;
72
/* Disable the unused transmitters */
73
gpio_low |= GPIO_CPUA_TDIS1A;
74
gpio_high |= GPIO_CPUA_TDIS1B;
75
gpio_low |= GPIO_CPUA_TDIS2A;
76
gpio_high |= GPIO_CPUA_TDIS2B;
80
/* We want to turn on some LEDs */
81
gpio_high |= GPIO_CPUB_CPU_READY;
82
gpio_low |= GPIO_CPUB_DEBUG_LED1;
83
gpio_low |= GPIO_CPUB_DEBUG_LED2;
85
/* Enable the appropriate receivers */
86
gpio_high |= GPIO_CPUB_RMUX_SEL0A;
87
gpio_high |= GPIO_CPUB_RMUX_SEL0B;
88
gpio_low |= GPIO_CPUB_RMUX_SEL1A;
89
gpio_low |= GPIO_CPUB_RMUX_SEL1B;
92
/* These GPIOs are common */
93
gpio_in |= IRQ_I2CINT | IRQ_FANINT | IRQ_DIMM_EVENT;
94
gpio_low |= GPIO_RS422_RE;
95
gpio_high |= GPIO_RS422_DE;
97
/* Ok, now go ahead and program all of those in one go */
98
mpc85xx_gpio_set(gpio_high|gpio_low|gpio_in,
103
* If things have been taken out of reset early (for example, by one
104
* of the BDI3000 debuggers), then we need to put them back in reset
105
* and delay a while before we continue.
107
if (mpc85xx_gpio_get(GPIO_RESETS)) {
108
ccsr_ddr_t *ddr = (ccsr_ddr_t *)CONFIG_SYS_MPC85xx_DDR_ADDR;
110
puts("Debugger detected... extra device reset enabled!\n");
112
/* Put stuff into reset and disable the DDR controller */
113
mpc85xx_gpio_set_low(GPIO_RESETS);
114
out_be32(&ddr->sdram_cfg, 0x00000000);
116
puts(" Waiting 1 sec for reset...");
117
for (i = 0; i < 10; i++) {
124
/* Now bring everything back out of reset again */
125
mpc85xx_gpio_set_high(GPIO_RESETS);
130
* This little shell function just returns whether or not it's CPU A.
131
* It can be used to select the right device-tree when booting, etc.
133
int do_hww1u1a_test_cpu_a(cmd_tbl_t *cmdtp, int flag,
134
int argc, char * const argv[])
139
if (hww1u1a_is_cpu_a())
145
test_cpu_a, 1, 0, do_hww1u1a_test_cpu_a,
146
"Test if this is CPU A (versus B) on the eXMeritus HWW-1U-1A board",
150
/* Create a prompt-like string: "uboot@HOSTNAME% " */
151
#define PROMPT_PREFIX "uboot@exm"
152
#define PROMPT_SUFFIX "% "
154
/* This function returns a PS1 prompt based on the serial number */
155
static char *hww1u1a_prompt;
156
const char *hww1u1a_get_ps1(void)
158
unsigned long len, i, j;
159
const char *serialnr;
161
/* If our prompt was already set, just use that */
163
return hww1u1a_prompt;
165
/* Use our serial number if present, otherwise a default */
166
serialnr = getenv("serial#");
167
if (!serialnr || !serialnr[0])
168
serialnr = "999999-X";
171
* We will turn the serial number into a hostname by:
172
* (A) Delete all non-alphanumerics.
173
* (B) Lowercase all letters.
175
* (D) Suffix "a" for CPU A and "b" for CPU B.
177
for (i = 0, len = 0; serialnr[i]; i++) {
178
if (isalnum(serialnr[i]))
182
len += sizeof(PROMPT_PREFIX PROMPT_SUFFIX) + 1; /* Includes NUL */
183
hww1u1a_prompt = malloc(len);
185
return PROMPT_PREFIX "UNKNOWN(ENOMEM)" PROMPT_SUFFIX;
187
/* Now actually fill it in */
190
/* Handle the prefix */
191
for (j = 0; j < sizeof(PROMPT_PREFIX) - 1; j++)
192
hww1u1a_prompt[i++] = PROMPT_PREFIX[j];
194
/* Now the serial# part of the hostname */
195
for (j = 0; serialnr[j]; j++)
196
if (isalnum(serialnr[j]))
197
hww1u1a_prompt[i++] = tolower(serialnr[j]);
199
/* Now the CPU id ("a" or "b") */
200
hww1u1a_prompt[i++] = hww1u1a_is_cpu_a() ? 'a' : 'b';
202
/* Finally the suffix */
203
for (j = 0; j < sizeof(PROMPT_SUFFIX); j++)
204
hww1u1a_prompt[i++] = PROMPT_SUFFIX[j];
206
/* This should all have added up, but just in case */
207
hww1u1a_prompt[len - 1] = '\0';
210
return hww1u1a_prompt;
213
void pci_init_board(void)
215
fsl_pcie_init_board(0);
218
int board_early_init_r(void)
220
const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
221
const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
224
* Remap bootflash region to caching-inhibited
225
* so that flash can be erased properly.
228
/* Flush d-cache and invalidate i-cache of any FLASH data */
232
/* invalidate existing TLB entry for FLASH */
233
disable_tlb(flash_esel);
235
set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
236
MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
237
0, flash_esel, BOOKE_PAGESZ_256M, 1);
242
int board_eth_init(bd_t *bis)
244
struct tsec_info_struct tsec_info[4];
245
struct fsl_pq_mdio_info mdio_info;
247
SET_STD_TSEC_INFO(tsec_info[0], 1);
248
SET_STD_TSEC_INFO(tsec_info[1], 2);
249
SET_STD_TSEC_INFO(tsec_info[2], 3);
251
if (hww1u1a_is_cpu_a())
252
tsec_info[2].phyaddr = TSEC3_PHY_ADDR_CPUA;
254
tsec_info[2].phyaddr = TSEC3_PHY_ADDR_CPUB;
256
mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
257
mdio_info.name = DEFAULT_MII_NAME;
258
fsl_pq_mdio_init(bis, &mdio_info);
260
tsec_eth_init(bis, tsec_info, 3);
261
return pci_eth_init(bis);
264
void ft_board_setup(void *blob, bd_t *bd)
269
ft_cpu_setup(blob, bd);
271
base = getenv_bootm_low();
272
size = getenv_bootm_size();
274
fdt_fixup_memory(blob, (u64)base, (u64)size);