alt.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /*
  2. * board/renesas/alt/alt.c
  3. *
  4. * Copyright (C) 2014 Renesas Electronics Corporation
  5. *
  6. * SPDX-License-Identifier: GPL-2.0
  7. */
  8. #include <common.h>
  9. #include <malloc.h>
  10. #include <asm/processor.h>
  11. #include <asm/mach-types.h>
  12. #include <asm/io.h>
  13. #include <asm/errno.h>
  14. #include <asm/arch/sys_proto.h>
  15. #include <asm/gpio.h>
  16. #include <asm/arch/rmobile.h>
  17. #include <asm/arch/rcar-mstp.h>
  18. #include <asm/arch/mmc.h>
  19. #include <netdev.h>
  20. #include <miiphy.h>
  21. #include <i2c.h>
  22. #include <div64.h>
  23. #include "qos.h"
  24. DECLARE_GLOBAL_DATA_PTR;
  25. #define CLK2MHZ(clk) (clk / 1000 / 1000)
  26. void s_init(void)
  27. {
  28. struct rcar_rwdt *rwdt = (struct rcar_rwdt *)RWDT_BASE;
  29. struct rcar_swdt *swdt = (struct rcar_swdt *)SWDT_BASE;
  30. /* Watchdog init */
  31. writel(0xA5A5A500, &rwdt->rwtcsra);
  32. writel(0xA5A5A500, &swdt->swtcsra);
  33. /* QoS */
  34. qos_init();
  35. }
  36. #define TMU0_MSTP125 (1 << 25)
  37. #define SCIF2_MSTP719 (1 << 19)
  38. #define ETHER_MSTP813 (1 << 13)
  39. #define IIC1_MSTP323 (1 << 23)
  40. #define MMC0_MSTP315 (1 << 15)
  41. int board_early_init_f(void)
  42. {
  43. /* TMU */
  44. mstp_clrbits_le32(MSTPSR1, SMSTPCR1, TMU0_MSTP125);
  45. /* SCIF2 */
  46. mstp_clrbits_le32(MSTPSR7, SMSTPCR7, SCIF2_MSTP719);
  47. /* ETHER */
  48. mstp_clrbits_le32(MSTPSR8, SMSTPCR8, ETHER_MSTP813);
  49. /* IIC1 / sh-i2c ch1 */
  50. mstp_clrbits_le32(MSTPSR3, SMSTPCR3, IIC1_MSTP323);
  51. #ifdef CONFIG_SH_MMCIF
  52. /* MMC */
  53. mstp_clrbits_le32(MSTPSR3, SMSTPCR3, MMC0_MSTP315);
  54. #endif
  55. return 0;
  56. }
  57. int board_init(void)
  58. {
  59. /* adress of boot parameters */
  60. gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
  61. /* Init PFC controller */
  62. r8a7794_pinmux_init();
  63. /* Ether Enable */
  64. gpio_request(GPIO_FN_ETH_CRS_DV, NULL);
  65. gpio_request(GPIO_FN_ETH_RX_ER, NULL);
  66. gpio_request(GPIO_FN_ETH_RXD0, NULL);
  67. gpio_request(GPIO_FN_ETH_RXD1, NULL);
  68. gpio_request(GPIO_FN_ETH_LINK, NULL);
  69. gpio_request(GPIO_FN_ETH_REFCLK, NULL);
  70. gpio_request(GPIO_FN_ETH_MDIO, NULL);
  71. gpio_request(GPIO_FN_ETH_TXD1, NULL);
  72. gpio_request(GPIO_FN_ETH_TX_EN, NULL);
  73. gpio_request(GPIO_FN_ETH_MAGIC, NULL);
  74. gpio_request(GPIO_FN_ETH_TXD0, NULL);
  75. gpio_request(GPIO_FN_ETH_MDC, NULL);
  76. gpio_request(GPIO_FN_IRQ8, NULL);
  77. /* PHY reset */
  78. gpio_request(GPIO_GP_1_24, NULL);
  79. gpio_direction_output(GPIO_GP_1_24, 0);
  80. mdelay(20);
  81. gpio_set_value(GPIO_GP_1_24, 1);
  82. udelay(1);
  83. return 0;
  84. }
  85. #define CXR24 0xEE7003C0 /* MAC address high register */
  86. #define CXR25 0xEE7003C8 /* MAC address low register */
  87. int board_eth_init(bd_t *bis)
  88. {
  89. #ifdef CONFIG_SH_ETHER
  90. int ret = -ENODEV;
  91. u32 val;
  92. unsigned char enetaddr[6];
  93. ret = sh_eth_initialize(bis);
  94. if (!eth_getenv_enetaddr("ethaddr", enetaddr))
  95. return ret;
  96. /* Set Mac address */
  97. val = enetaddr[0] << 24 | enetaddr[1] << 16 |
  98. enetaddr[2] << 8 | enetaddr[3];
  99. writel(val, CXR24);
  100. val = enetaddr[4] << 8 | enetaddr[5];
  101. writel(val, CXR25);
  102. return ret;
  103. #else
  104. return 0;
  105. #endif
  106. }
  107. int board_mmc_init(bd_t *bis)
  108. {
  109. int ret = 0;
  110. #ifdef CONFIG_SH_MMCIF
  111. gpio_request(GPIO_GP_4_31, NULL);
  112. gpio_set_value(GPIO_GP_4_31, 1);
  113. ret = mmcif_mmc_init();
  114. #endif
  115. return ret;
  116. }
  117. int dram_init(void)
  118. {
  119. gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
  120. return 0;
  121. }
  122. const struct rmobile_sysinfo sysinfo = {
  123. CONFIG_RMOBILE_BOARD_STRING
  124. };
  125. void reset_cpu(ulong addr)
  126. {
  127. u8 val;
  128. i2c_set_bus_num(1); /* PowerIC connected to ch1 */
  129. i2c_read(CONFIG_SYS_I2C_POWERIC_ADDR, 0x13, 1, &val, 1);
  130. val |= 0x02;
  131. i2c_write(CONFIG_SYS_I2C_POWERIC_ADDR, 0x13, 1, &val, 1);
  132. }