2011-11-15 03:29:06 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2009, 2011 Renesas Solutions Corp.
|
|
|
|
* Copyright (C) 2009 Kuninori Morimoto <morimoto.kuninori@renesas.com>
|
|
|
|
* Copyright (C) 2011 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2011-11-15 03:29:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <i2c.h>
|
|
|
|
#include <netdev.h>
|
|
|
|
|
|
|
|
/* USB power management register */
|
|
|
|
#define UPONCR0 0xA40501D4
|
|
|
|
|
|
|
|
int checkboard(void)
|
|
|
|
{
|
|
|
|
puts("BOARD: ecovec\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void debug_led(u8 led)
|
|
|
|
{
|
|
|
|
/* PDGR[0-4] is debug LED */
|
|
|
|
outb((inb(PGDR) & ~0x0F) | (led & 0x0F), PGDR);
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_late_init(void)
|
|
|
|
{
|
|
|
|
u8 mac[6];
|
2014-11-06 13:03:03 +00:00
|
|
|
char env_mac[18];
|
2011-11-15 03:29:06 +00:00
|
|
|
|
|
|
|
udelay(1000);
|
|
|
|
|
|
|
|
/* SH-Eth (PLCR, PNCR, PXCR, PSELx )*/
|
|
|
|
outw(inw(PLCR) & ~0xFFF0, PLCR);
|
|
|
|
outw(inw(PNCR) & ~0x000F, PNCR);
|
|
|
|
outw(inw(PXCR) & ~0x0FC0, PXCR);
|
|
|
|
outw((inw(PSELB) & ~0x030F) | 0x020A, PSELB);
|
|
|
|
outw((inw(PSELC) & ~0x0307) | 0x0207, PSELC);
|
|
|
|
outw((inw(PSELE) & ~0x00c0) | 0x0080, PSELE);
|
|
|
|
|
|
|
|
debug_led(1 << 3);
|
|
|
|
|
|
|
|
outl(inl(MSTPCR2) & ~0x10000000, MSTPCR2);
|
|
|
|
|
2013-10-29 04:33:51 +00:00
|
|
|
i2c_set_bus_num(1); /* Use I2C 1 */
|
2011-11-15 03:29:06 +00:00
|
|
|
|
|
|
|
/* Read MAC address */
|
|
|
|
i2c_read(0x50, 0x10, 0, mac, 6);
|
|
|
|
|
|
|
|
/* Set MAC address */
|
|
|
|
sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
|
|
|
|
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("ethaddr", env_mac);
|
2011-11-15 03:29:06 +00:00
|
|
|
|
|
|
|
debug_led(0x0F);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* LED (PTG) */
|
2014-03-17 14:14:53 +00:00
|
|
|
outw((inw(PGCR) & ~0xFF) | 0x55, PGCR);
|
2011-11-15 03:29:06 +00:00
|
|
|
outw((inw(HIZCRA) & ~0x02), HIZCRA);
|
|
|
|
|
|
|
|
debug_led(1 << 0);
|
|
|
|
|
|
|
|
/* SCIF0 (PTF, PTM) */
|
|
|
|
outw(inw(PFCR) & ~0x30, PFCR);
|
|
|
|
outw(inw(PMCR) & ~0x0C, PMCR);
|
|
|
|
outw((inw(PSELA) & ~0x40) | 0x40, PSELA);
|
|
|
|
|
|
|
|
debug_led(1 << 1);
|
|
|
|
|
|
|
|
/* RMII (PTA) */
|
|
|
|
outw((inw(PACR) & ~0x0C) | 0x04, PACR);
|
|
|
|
outb((inb(PADR) & ~0x02) | 0x02, PADR);
|
|
|
|
|
|
|
|
debug_led(1 << 2);
|
|
|
|
|
|
|
|
/* USB host */
|
|
|
|
outw((inw(PBCR) & ~0x300) | 0x100, PBCR);
|
|
|
|
outb((inb(PBDR) & ~0x10) | 0x10, PBDR);
|
2014-03-17 14:14:54 +00:00
|
|
|
outl(inl(MSTPCR2) & ~0x100000, MSTPCR2);
|
2011-11-15 03:29:06 +00:00
|
|
|
outw(0x0600, UPONCR0);
|
|
|
|
|
|
|
|
debug_led(1 << 3);
|
|
|
|
|
|
|
|
/* debug switch */
|
|
|
|
outw((inw(PVCR) & ~0x03) | 0x02 , PVCR);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|