blob: 6b6c5dc559189150afdd0da453203dd434f5a8e1 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +09002/*
3 * Copyright (C) 2009, 2011 Renesas Solutions Corp.
4 * Copyright (C) 2009 Kuninori Morimoto <morimoto.kuninori@renesas.com>
5 * Copyright (C) 2011 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +09006 */
7
8#include <common.h>
9#include <command.h>
10#include <asm/io.h>
11#include <asm/processor.h>
12#include <i2c.h>
13#include <netdev.h>
14
15/* USB power management register */
16#define UPONCR0 0xA40501D4
17
18int checkboard(void)
19{
20 puts("BOARD: ecovec\n");
21 return 0;
22}
23
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +090024static void debug_led(u8 led)
25{
26 /* PDGR[0-4] is debug LED */
27 outb((inb(PGDR) & ~0x0F) | (led & 0x0F), PGDR);
28}
29
30int board_late_init(void)
31{
32 u8 mac[6];
Wolfgang Denk79c363f2014-11-06 14:03:03 +010033 char env_mac[18];
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +090034
35 udelay(1000);
36
37 /* SH-Eth (PLCR, PNCR, PXCR, PSELx )*/
38 outw(inw(PLCR) & ~0xFFF0, PLCR);
39 outw(inw(PNCR) & ~0x000F, PNCR);
40 outw(inw(PXCR) & ~0x0FC0, PXCR);
41 outw((inw(PSELB) & ~0x030F) | 0x020A, PSELB);
42 outw((inw(PSELC) & ~0x0307) | 0x0207, PSELC);
43 outw((inw(PSELE) & ~0x00c0) | 0x0080, PSELE);
44
45 debug_led(1 << 3);
46
47 outl(inl(MSTPCR2) & ~0x10000000, MSTPCR2);
48
Nobuhiro Iwamatsu12240102013-10-29 13:33:51 +090049 i2c_set_bus_num(1); /* Use I2C 1 */
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +090050
51 /* Read MAC address */
52 i2c_read(0x50, 0x10, 0, mac, 6);
53
54 /* Set MAC address */
55 sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
56 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
Simon Glass6a38e412017-08-03 12:22:09 -060057 env_set("ethaddr", env_mac);
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +090058
59 debug_led(0x0F);
60
61 return 0;
62}
63
64int board_init(void)
65{
66
67 /* LED (PTG) */
Baruch Siach61d6b382014-03-17 16:14:53 +020068 outw((inw(PGCR) & ~0xFF) | 0x55, PGCR);
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +090069 outw((inw(HIZCRA) & ~0x02), HIZCRA);
70
71 debug_led(1 << 0);
72
73 /* SCIF0 (PTF, PTM) */
74 outw(inw(PFCR) & ~0x30, PFCR);
75 outw(inw(PMCR) & ~0x0C, PMCR);
76 outw((inw(PSELA) & ~0x40) | 0x40, PSELA);
77
78 debug_led(1 << 1);
79
80 /* RMII (PTA) */
81 outw((inw(PACR) & ~0x0C) | 0x04, PACR);
82 outb((inb(PADR) & ~0x02) | 0x02, PADR);
83
84 debug_led(1 << 2);
85
86 /* USB host */
87 outw((inw(PBCR) & ~0x300) | 0x100, PBCR);
88 outb((inb(PBDR) & ~0x10) | 0x10, PBDR);
Baruch Siachea39bb02014-03-17 16:14:54 +020089 outl(inl(MSTPCR2) & ~0x100000, MSTPCR2);
Nobuhiro Iwamatsu45befad2011-11-15 12:29:06 +090090 outw(0x0600, UPONCR0);
91
92 debug_led(1 << 3);
93
94 /* debug switch */
95 outw((inw(PVCR) & ~0x03) | 0x02 , PVCR);
96
97 return 0;
98}