3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
6 * Thomas Langer, Ralph Hempel
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/addrspace.h>
32 #include <asm/danube.h>
33 #include <asm/reboot.h>
35 #if defined(CONFIG_CMD_HTTPD)
38 #if defined(CONFIG_PCI)
41 #include "athrs26_phy.h"
43 extern ulong
ifx_get_ddr_hz(void);
44 extern ulong
ifx_get_cpuclk(void);
46 /* IDs and registers of known external switches */
47 void _machine_restart(void)
49 *DANUBE_RCU_RST_REQ
|=1<<30;
52 #ifdef CONFIG_SYS_RAMBOOT
53 phys_size_t
initdram(int board_type
)
55 return get_ram_size((long *)CONFIG_SYS_SDRAM_BASE
, CONFIG_SYS_MAX_RAM
);
57 #elif defined(CONFIG_USE_DDR_RAM)
58 phys_size_t
initdram(int board_type
)
60 return (CONFIG_SYS_MAX_RAM
);
64 static ulong
max_sdram_size(void) /* per Chip Select */
66 /* The only supported SDRAM data width is 16bit.
70 /* The only supported number of SDRAM banks is 4.
74 ulong cfgpb0
= *DANUBE_SDRAM_MC_CFGPB0
;
75 int cols
= cfgpb0
& 0xF;
76 int rows
= (cfgpb0
& 0xF0) >> 4;
77 ulong size
= (1 << (rows
+ cols
)) * CFG_DW
* CFG_NB
;
83 * Check memory range for valid RAM. A simple memory test determines
84 * the actually available RAM size between addresses `base' and
88 static long int dram_size(long int *base
, long int maxsize
)
90 volatile long int *addr
;
92 ulong save
[32]; /* to make test non-destructive */
95 for (cnt
= (maxsize
/ sizeof (long)) >> 1; cnt
> 0; cnt
>>= 1) {
96 addr
= base
+ cnt
; /* pointer arith! */
102 /* write 0 to base address */
107 /* check at base address */
108 if ((val
= *addr
) != 0) {
113 for (cnt
= 1; cnt
< maxsize
/ sizeof (long); cnt
<<= 1) {
114 addr
= base
+ cnt
; /* pointer arith! */
120 return (cnt
* sizeof (long));
126 phys_size_t
initdram(int board_type
)
128 int rows
, cols
, best_val
= *DANUBE_SDRAM_MC_CFGPB0
;
129 ulong size
, max_size
= 0;
132 /* load t9 into our_address */
133 asm volatile ("move %0, $25" : "=r" (our_address
) :);
135 /* Can't probe for RAM size unless we are running from Flash.
136 * find out whether running from DRAM or Flash.
138 if (CPHYSADDR(our_address
) < CPHYSADDR(PHYS_FLASH_1
))
140 return max_sdram_size();
143 for (cols
= 0x8; cols
<= 0xC; cols
++)
145 for (rows
= 0xB; rows
<= 0xD; rows
++)
147 *DANUBE_SDRAM_MC_CFGPB0
= (0x14 << 8) |
149 size
= get_ram_size((long *)CONFIG_SYS_SDRAM_BASE
,
154 best_val
= *DANUBE_SDRAM_MC_CFGPB0
;
160 *DANUBE_SDRAM_MC_CFGPB0
= best_val
;
165 int checkboard (void)
167 unsigned long chipid
= *DANUBE_MPS_CHIPID
;
170 puts ("Board: ARV75DW22 - Easybox 803\n");
173 part_num
= DANUBE_MPS_CHIPID_PARTNUM_GET(chipid
);
179 puts("Danube/Twinpass/Vinax-VE ");
182 printf ("unknown, chip part number 0x%03X ", part_num
);
185 printf ("V1.%ld, ", DANUBE_MPS_CHIPID_VERSION_GET(chipid
));
187 printf("DDR Speed %ld MHz, ", ifx_get_ddr_hz()/1000000);
188 printf("CPU Speed %ld MHz\n", ifx_get_cpuclk()/1000000);
193 #ifdef CONFIG_SKIP_LOWLEVEL_INIT
194 int board_early_init_f(void)
196 #ifdef CONFIG_EBU_ADDSEL0
197 (*DANUBE_EBU_ADDSEL0
) = CONFIG_EBU_ADDSEL0
;
199 #ifdef CONFIG_EBU_ADDSEL1
200 (*DANUBE_EBU_ADDSEL1
) = CONFIG_EBU_ADDSEL1
;
202 #ifdef CONFIG_EBU_ADDSEL2
203 (*DANUBE_EBU_ADDSEL2
) = CONFIG_EBU_ADDSEL2
;
205 #ifdef CONFIG_EBU_ADDSEL3
206 (*DANUBE_EBU_ADDSEL3
) = CONFIG_EBU_ADDSEL3
;
208 #ifdef CONFIG_EBU_BUSCON0
209 (*DANUBE_EBU_BUSCON0
) = CONFIG_EBU_BUSCON0
;
211 #ifdef CONFIG_EBU_BUSCON1
212 (*DANUBE_EBU_BUSCON1
) = CONFIG_EBU_BUSCON1
;
214 #ifdef CONFIG_EBU_BUSCON2
215 (*DANUBE_EBU_BUSCON2
) = CONFIG_EBU_BUSCON2
;
217 #ifdef CONFIG_EBU_BUSCON3
218 (*DANUBE_EBU_BUSCON3
) = CONFIG_EBU_BUSCON3
;
223 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
226 #ifdef CONFIG_EXTRA_SWITCH
227 static int external_switch_init(void)
229 // switch reset pin on arv752
230 *DANUBE_GPIO_P1_ALTSEL0
&= ~8;
231 *DANUBE_GPIO_P1_ALTSEL1
&= ~8;
232 *DANUBE_GPIO_P1_OD
|= 8;
233 *DANUBE_GPIO_P1_DIR
|= 8;
234 *DANUBE_GPIO_P1_OUT
|= 8;
236 puts("initializing ar8216 switch... ");
237 if (athrs26_phy_setup(0)==0) {
238 printf("initialized\n");
241 puts("failed ... \n");
244 #endif /* CONFIG_EXTRA_SWITCH */
246 int board_eth_init(bd_t
*bis
)
248 #if defined(CONFIG_IFX_ETOP)
250 if (!eth_getenv_enetaddr("ethaddr", enetaddr
))
251 eth_setenv_enetaddr("ethaddr", (uchar
*)0xb03f0016);
253 *DANUBE_PMU_PWDCR
&= 0xFFFFEFDF;
254 *DANUBE_PMU_PWDCR
&=~(1<<DANUBE_PMU_DMA_SHIFT
);/*enable DMA from PMU*/
256 if (lq_eth_initialize(bis
))
259 *DANUBE_RCU_RST_REQ
|=1;
261 *DANUBE_RCU_RST_REQ
&=(unsigned long)~1;
264 #ifdef CONFIG_EXTRA_SWITCH
265 if (external_switch_init()<0)
267 #endif /* CONFIG_EXTRA_SWITCH */
268 #endif /* CONFIG_IFX_ETOP */
273 #if defined(CONFIG_CMD_HTTPD)
274 int do_http_upgrade(const unsigned char *data
, const ulong size
)
278 if(getenv ("ram_addr") == NULL
)
280 if(getenv ("kernel_addr") == NULL
)
282 /* check the image */
283 if(run_command("imi ${ram_addr}", 0) < 0) {
286 /* write the image to the flash */
287 puts("http ugrade ...\n");
288 sprintf(buf
, "era ${kernel_addr} +0x%lx; cp.b ${ram_addr} ${kernel_addr} 0x%lx", size
, size
);
289 return run_command(buf
, 0);
292 int do_http_progress(const int state
)
294 /* toggle LED's here */
296 case HTTP_PROGRESS_START
:
297 puts("http start\n");
299 case HTTP_PROGRESS_TIMEOUT
:
302 case HTTP_PROGRESS_UPLOAD_READY
:
303 puts("http upload ready\n");
305 case HTTP_PROGRESS_UGRADE_READY
:
306 puts("http ugrade ready\n");
308 case HTTP_PROGRESS_UGRADE_FAILED
:
309 puts("http ugrade failed\n");
315 unsigned long do_http_tmp_address(void)
317 char *s
= getenv ("ram_addr");
319 ulong tmp
= simple_strtoul (s
, NULL
, 16);
322 return 0 /*0x80a00000*/;