ecovec.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. #include <common.h>
  22. #include <command.h>
  23. #include <asm/io.h>
  24. #include <asm/processor.h>
  25. #include <i2c.h>
  26. #include <netdev.h>
  27. /* USB power management register */
  28. #define UPONCR0 0xA40501D4
  29. int checkboard(void)
  30. {
  31. puts("BOARD: ecovec\n");
  32. return 0;
  33. }
  34. int dram_init(void)
  35. {
  36. DECLARE_GLOBAL_DATA_PTR;
  37. gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
  38. gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
  39. printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024));
  40. return 0;
  41. }
  42. static void debug_led(u8 led)
  43. {
  44. /* PDGR[0-4] is debug LED */
  45. outb((inb(PGDR) & ~0x0F) | (led & 0x0F), PGDR);
  46. }
  47. int board_late_init(void)
  48. {
  49. u8 mac[6];
  50. char env_mac[17];
  51. udelay(1000);
  52. /* SH-Eth (PLCR, PNCR, PXCR, PSELx )*/
  53. outw(inw(PLCR) & ~0xFFF0, PLCR);
  54. outw(inw(PNCR) & ~0x000F, PNCR);
  55. outw(inw(PXCR) & ~0x0FC0, PXCR);
  56. outw((inw(PSELB) & ~0x030F) | 0x020A, PSELB);
  57. outw((inw(PSELC) & ~0x0307) | 0x0207, PSELC);
  58. outw((inw(PSELE) & ~0x00c0) | 0x0080, PSELE);
  59. debug_led(1 << 3);
  60. outl(inl(MSTPCR2) & ~0x10000000, MSTPCR2);
  61. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  62. i2c_set_bus_num(CONFIG_SYS_I2C_MODULE); /* Use I2C 1 */
  63. /* Read MAC address */
  64. i2c_read(0x50, 0x10, 0, mac, 6);
  65. /* Set MAC address */
  66. sprintf(env_mac, "%02X:%02X:%02X:%02X:%02X:%02X",
  67. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  68. setenv("ethaddr", env_mac);
  69. debug_led(0x0F);
  70. return 0;
  71. }
  72. int board_init(void)
  73. {
  74. /* LED (PTG) */
  75. outw((inw(PGCR) & ~0xFF) | 0x66, PGCR);
  76. outw((inw(HIZCRA) & ~0x02), HIZCRA);
  77. debug_led(1 << 0);
  78. /* SCIF0 (PTF, PTM) */
  79. outw(inw(PFCR) & ~0x30, PFCR);
  80. outw(inw(PMCR) & ~0x0C, PMCR);
  81. outw((inw(PSELA) & ~0x40) | 0x40, PSELA);
  82. debug_led(1 << 1);
  83. /* RMII (PTA) */
  84. outw((inw(PACR) & ~0x0C) | 0x04, PACR);
  85. outb((inb(PADR) & ~0x02) | 0x02, PADR);
  86. debug_led(1 << 2);
  87. /* USB host */
  88. outw((inw(PBCR) & ~0x300) | 0x100, PBCR);
  89. outb((inb(PBDR) & ~0x10) | 0x10, PBDR);
  90. outl(inl(MSTPCR2) & 0x100000, MSTPCR2);
  91. outw(0x0600, UPONCR0);
  92. debug_led(1 << 3);
  93. /* debug switch */
  94. outw((inw(PVCR) & ~0x03) | 0x02 , PVCR);
  95. return 0;
  96. }