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