ap_sh4a_4a.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * Copyright (C) 2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
  3. * Copyright (C) 2012 Renesas Solutions Corp.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #include <common.h>
  20. #include <asm/io.h>
  21. #include <asm/processor.h>
  22. #include <netdev.h>
  23. #include <i2c.h>
  24. DECLARE_GLOBAL_DATA_PTR;
  25. #define MODEMR (0xFFCC0020)
  26. #define MODEMR_MASK (0x6)
  27. #define MODEMR_533MHZ (0x2)
  28. int checkboard(void)
  29. {
  30. u32 r = readl(MODEMR);
  31. if ((r & MODEMR_MASK) & MODEMR_533MHZ)
  32. puts("CPU Clock: 533MHz\n");
  33. else
  34. puts("CPU Clock: 400MHz\n");
  35. puts("BOARD: Alpha Project. AP-SH4A-4A\n");
  36. return 0;
  37. }
  38. #define MSTPSR1 (0xFFC80044)
  39. #define MSTPCR1 (0xFFC80034)
  40. #define MSTPSR1_GETHER (1 << 14)
  41. /* IPSR3 */
  42. #define ET0_ETXD0 (0x4 << 3)
  43. #define ET0_GTX_CLK_A (0x4 << 6)
  44. #define ET0_ETXD1_A (0x4 << 9)
  45. #define ET0_ETXD2_A (0x4 << 12)
  46. #define ET0_ETXD3_A (0x4 << 15)
  47. #define ET0_ETXD4 (0x3 << 18)
  48. #define ET0_ETXD5_A (0x5 << 21)
  49. #define ET0_ETXD6_A (0x5 << 24)
  50. #define ET0_ETXD7 (0x4 << 27)
  51. #define IPSR3_ETH_ENABLE \
  52. (ET0_ETXD0 | ET0_GTX_CLK_A | ET0_ETXD1_A | ET0_ETXD2_A | \
  53. ET0_ETXD3_A | ET0_ETXD4 | ET0_ETXD5_A | ET0_ETXD6_A | ET0_ETXD7)
  54. /* IPSR4 */
  55. #define ET0_ERXD7 (0x4)
  56. #define ET0_RX_DV (0x4 << 3)
  57. #define ET0_RX_ER (0x4 << 6)
  58. #define ET0_CRS (0x4 << 9)
  59. #define ET0_COL (0x4 << 12)
  60. #define ET0_MDC (0x4 << 15)
  61. #define ET0_MDIO_A (0x3 << 18)
  62. #define ET0_LINK_A (0x3 << 20)
  63. #define ET0_PHY_INT_A (0x3 << 24)
  64. #define IPSR4_ETH_ENABLE \
  65. (ET0_ERXD7 | ET0_RX_DV | ET0_RX_ER | ET0_CRS | ET0_COL | \
  66. ET0_MDC | ET0_MDIO_A | ET0_LINK_A | ET0_PHY_INT_A)
  67. /* IPSR8 */
  68. #define ET0_ERXD0 (0x4 << 20)
  69. #define ET0_ERXD1 (0x4 << 23)
  70. #define ET0_ERXD2_A (0x3 << 26)
  71. #define ET0_ERXD3_A (0x3 << 28)
  72. #define IPSR8_ETH_ENABLE \
  73. (ET0_ERXD0 | ET0_ERXD1 | ET0_ERXD2_A | ET0_ERXD3_A)
  74. /* IPSR10 */
  75. #define RX4_D (0x1 << 22)
  76. #define TX4_D (0x1 << 23)
  77. #define IPSR10_SCIF_ENABLE (RX4_D | TX4_D)
  78. /* IPSR11 */
  79. #define ET0_ERXD4 (0x4 << 4)
  80. #define ET0_ERXD5 (0x4 << 7)
  81. #define ET0_ERXD6 (0x3 << 10)
  82. #define ET0_TX_EN (0x2 << 19)
  83. #define ET0_TX_ER (0x2 << 21)
  84. #define ET0_TX_CLK_A (0x4 << 23)
  85. #define ET0_RX_CLK_A (0x3 << 26)
  86. #define IPSR11_ETH_ENABLE \
  87. (ET0_ERXD4 | ET0_ERXD5 | ET0_ERXD6 | ET0_TX_EN | ET0_TX_ER | \
  88. ET0_TX_CLK_A | ET0_RX_CLK_A)
  89. #define GPSR1_INIT (0xFFFF7FFF)
  90. #define GPSR2_INIT (0x4005FEFF)
  91. #define GPSR3_INIT (0x2EFFFFFF)
  92. #define GPSR4_INIT (0xC7000000)
  93. int board_init(void)
  94. {
  95. u32 data;
  96. /* Set IPSR register */
  97. data = readl(IPSR3);
  98. data |= IPSR3_ETH_ENABLE;
  99. writel(~data, PMMR);
  100. writel(data, IPSR3);
  101. data = readl(IPSR4);
  102. data |= IPSR4_ETH_ENABLE;
  103. writel(~data, PMMR);
  104. writel(data, IPSR4);
  105. data = readl(IPSR8);
  106. data |= IPSR8_ETH_ENABLE;
  107. writel(~data, PMMR);
  108. writel(data, IPSR8);
  109. data = readl(IPSR10);
  110. data |= IPSR10_SCIF_ENABLE;
  111. writel(~data, PMMR);
  112. writel(data, IPSR10);
  113. data = readl(IPSR11);
  114. data |= IPSR11_ETH_ENABLE;
  115. writel(~data, PMMR);
  116. writel(data, IPSR11);
  117. /* GPIO select */
  118. data = GPSR1_INIT;
  119. writel(~data, PMMR);
  120. writel(data, GPSR1);
  121. data = GPSR2_INIT;
  122. writel(~data, PMMR);
  123. writel(data, GPSR2);
  124. data = GPSR3_INIT;
  125. writel(~data, PMMR);
  126. writel(data, GPSR3);
  127. data = GPSR4_INIT;
  128. writel(~data, PMMR);
  129. writel(data, GPSR4);
  130. data = 0x0;
  131. writel(~data, PMMR);
  132. writel(data, GPSR5);
  133. /* mode select */
  134. data = MODESEL2_INIT;
  135. writel(~data, PMMR);
  136. writel(data, MODESEL2);
  137. #if defined(CONFIG_SH_ETHER)
  138. u32 r = readl(MSTPSR1);
  139. if (r & MSTPSR1_GETHER)
  140. writel((r & ~MSTPSR1_GETHER), MSTPCR1);
  141. #endif
  142. return 0;
  143. }
  144. int board_late_init(void)
  145. {
  146. u8 mac[6];
  147. /* Read Mac Address and set*/
  148. i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
  149. i2c_set_bus_num(CONFIG_SYS_I2C_MODULE);
  150. /* Read MAC address */
  151. i2c_read(0x50, 0x0, 0, mac, 6);
  152. if (is_valid_ether_addr(mac))
  153. eth_setenv_enetaddr("ethaddr", mac);
  154. return 0;
  155. }
  156. int dram_init(void)
  157. {
  158. gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
  159. gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
  160. printf("DRAM: %dMB\n", CONFIG_SYS_SDRAM_SIZE / (1024 * 1024));
  161. return 0;
  162. }