1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-01 20:21:54 +02:00
xburst-tools/usb-boot/stage1/debug.c
xiangfu a3b9071e22 change the usbboot to ingenic-tools (host side code)
add usb-boot to keep the device code.
2009-04-11 15:04:25 +00:00

82 lines
1.5 KiB
C

#include "jz4750.h"
#include "configs.h"
extern fw_args_t * fw_args;
unsigned int check_sdram(unsigned int saddr, unsigned int size)
{
unsigned int addr,err = 0;
serial_puts("\nCheck SDRAM ... \n");
saddr += 0xa0000000;
size += saddr;
serial_put_hex(saddr);
serial_put_hex(size);
saddr &= 0xfffffffc; //must word align
for (addr = saddr; addr < size; addr += 4)
{
*(volatile unsigned int *)addr = addr;
if (*(volatile unsigned int *)addr != addr)
{
serial_put_hex(addr);
err = addr;
}
}
if (err)
serial_puts("Check SDRAM fail!\n");
else
serial_puts("Check SDRAM pass!\n");
return err;
}
void gpio_test(unsigned char ops, unsigned char pin)
{
__gpio_as_output(pin);
if (ops)
{
serial_puts("\nGPIO set ");
serial_put_hex(pin);
__gpio_set_pin(pin);
}
else
{
serial_puts("\nGPIO clear ");
serial_put_hex(pin);
__gpio_clear_pin(pin);
}
// __gpio_as_input(pin);
}
void do_debug()
{
switch (fw_args->debug_ops)
{
case 1: //sdram check
switch (CPU_ID)
{
case 0x4740:
gpio_init_4740();
serial_init();
sdram_init_4740();
break;
case 0x4750:
gpio_init_4750();
serial_init();
sdram_init_4750();
break;
default:;
}
REG8(USB_REG_INDEX) = 1;
REG32(USB_FIFO_EP1) = check_sdram(fw_args->start, fw_args->size);
REG32(USB_FIFO_EP1) = 0x0;
REG8(USB_REG_INCSR) |= USB_INCSR_INPKTRDY;
break;
case 2: //set gpio
gpio_test(1, fw_args->pin_num);
break;
case 3: //clear gpio
gpio_test(0, fw_args->pin_num);
break;
}
}