ecovec.c 2.0 KB

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