ecovec.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  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>
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <asm/io.h>
  10. #include <asm/processor.h>
  11. #include <i2c.h>
  12. #include <netdev.h>
  13. /* USB power management register */
  14. #define UPONCR0 0xA40501D4
  15. int checkboard(void)
  16. {
  17. puts("BOARD: ecovec\n");
  18. return 0;
  19. }
  20. static void debug_led(u8 led)
  21. {
  22. /* PDGR[0-4] is debug LED */
  23. outb((inb(PGDR) & ~0x0F) | (led & 0x0F), PGDR);
  24. }
  25. int board_late_init(void)
  26. {
  27. u8 mac[6];
  28. char env_mac[18];
  29. udelay(1000);
  30. /* SH-Eth (PLCR, PNCR, PXCR, PSELx )*/
  31. outw(inw(PLCR) & ~0xFFF0, PLCR);
  32. outw(inw(PNCR) & ~0x000F, PNCR);
  33. outw(inw(PXCR) & ~0x0FC0, PXCR);
  34. outw((inw(PSELB) & ~0x030F) | 0x020A, PSELB);
  35. outw((inw(PSELC) & ~0x0307) | 0x0207, PSELC);
  36. outw((inw(PSELE) & ~0x00c0) | 0x0080, PSELE);
  37. debug_led(1 << 3);
  38. outl(inl(MSTPCR2) & ~0x10000000, MSTPCR2);
  39. i2c_set_bus_num(1); /* Use I2C 1 */
  40. /* Read MAC address */
  41. i2c_read(0x50, 0x10, 0, mac, 6);
  42. /* Set MAC address */
  43. sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
  44. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  45. env_set("ethaddr", env_mac);
  46. debug_led(0x0F);
  47. return 0;
  48. }
  49. int board_init(void)
  50. {
  51. /* LED (PTG) */
  52. outw((inw(PGCR) & ~0xFF) | 0x55, PGCR);
  53. outw((inw(HIZCRA) & ~0x02), HIZCRA);
  54. debug_led(1 << 0);
  55. /* SCIF0 (PTF, PTM) */
  56. outw(inw(PFCR) & ~0x30, PFCR);
  57. outw(inw(PMCR) & ~0x0C, PMCR);
  58. outw((inw(PSELA) & ~0x40) | 0x40, PSELA);
  59. debug_led(1 << 1);
  60. /* RMII (PTA) */
  61. outw((inw(PACR) & ~0x0C) | 0x04, PACR);
  62. outb((inb(PADR) & ~0x02) | 0x02, PADR);
  63. debug_led(1 << 2);
  64. /* USB host */
  65. outw((inw(PBCR) & ~0x300) | 0x100, PBCR);
  66. outb((inb(PBDR) & ~0x10) | 0x10, PBDR);
  67. outl(inl(MSTPCR2) & ~0x100000, MSTPCR2);
  68. outw(0x0600, UPONCR0);
  69. debug_led(1 << 3);
  70. /* debug switch */
  71. outw((inw(PVCR) & ~0x03) | 0x02 , PVCR);
  72. return 0;
  73. }