jadecpu.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * (c) 2010 Graf-Syteco, Matthias Weisser
  3. * <weisserm@arcor.de>
  4. *
  5. * (C) Copyright 2007, mycable GmbH
  6. * Carsten Schneider <cs@mycable.de>, Alexander Bigga <ab@mycable.de>
  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. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <netdev.h>
  25. #include <asm/io.h>
  26. #include <asm/arch/mb86r0x.h>
  27. DECLARE_GLOBAL_DATA_PTR;
  28. /*
  29. * Miscellaneous platform dependent initialisations
  30. */
  31. int board_init(void)
  32. {
  33. struct mb86r0x_ccnt * ccnt = (struct mb86r0x_ccnt *)
  34. MB86R0x_CCNT_BASE;
  35. /* We select mode 0 for group 2 and mode 1 for group 4 */
  36. writel(0x00000010, &ccnt->cmux_md);
  37. gd->flags = 0;
  38. gd->bd->bi_arch_number = MACH_TYPE_JADECPU;
  39. gd->bd->bi_boot_params = PHYS_SDRAM + PHYS_SDRAM_SIZE - 0x10000;
  40. icache_enable();
  41. return 0;
  42. }
  43. static void setup_display_power(uint32_t pwr_bit, char *pwm_opts,
  44. unsigned long pwm_base)
  45. {
  46. struct mb86r0x_gpio *gpio = (struct mb86r0x_gpio *)
  47. MB86R0x_GPIO_BASE;
  48. struct mb86r0x_pwm *pwm = (struct mb86r0x_pwm *) pwm_base;
  49. const char *e;
  50. writel(readl(&gpio->gpdr2) | pwr_bit, &gpio->gpdr2);
  51. e = getenv(pwm_opts);
  52. if (e != NULL) {
  53. const char *s;
  54. uint32_t freq, init;
  55. freq = 0;
  56. init = 0;
  57. s = strchr(e, 'f');
  58. if (s != NULL)
  59. freq = simple_strtol(s + 2, NULL, 0);
  60. s = strchr(e, 'i');
  61. if (s != NULL)
  62. init = simple_strtol(s + 2, NULL, 0);
  63. if (freq > 0) {
  64. writel(CONFIG_MB86R0x_IOCLK / 1000 / freq,
  65. &pwm->bcr);
  66. writel(1002, &pwm->tpr);
  67. writel(1, &pwm->pr);
  68. writel(init * 10 + 1, &pwm->dr);
  69. writel(1, &pwm->cr);
  70. writel(1, &pwm->sr);
  71. }
  72. }
  73. }
  74. int board_late_init(void)
  75. {
  76. struct mb86r0x_gpio *gpio = (struct mb86r0x_gpio *)
  77. MB86R0x_GPIO_BASE;
  78. uint32_t in_word;
  79. #ifdef CONFIG_VIDEO_MB86R0xGDC
  80. /* Check if we have valid display settings and turn on power if so */
  81. /* Display 0 */
  82. if (getenv("gs_dsp_0_param") || getenv("videomode"))
  83. setup_display_power((1 << 3), "gs_dsp_0_pwm",
  84. MB86R0x_PWM0_BASE);
  85. /* The corresponding GPIO is always an output */
  86. writel(readl(&gpio->gpddr2) | (1 << 3), &gpio->gpddr2);
  87. /* Display 1 */
  88. if (getenv("gs_dsp_1_param") || getenv("videomode1"))
  89. setup_display_power((1 << 4), "gs_dsp_1_pwm",
  90. MB86R0x_PWM1_BASE);
  91. /* The corresponding GPIO is always an output */
  92. writel(readl(&gpio->gpddr2) | (1 << 4), &gpio->gpddr2);
  93. #endif /* CONFIG_VIDEO_MB86R0xGDC */
  94. /* 5V enable */
  95. writel(readl(&gpio->gpdr1) & ~(1 << 5), &gpio->gpdr1);
  96. writel(readl(&gpio->gpddr1) | (1 << 5), &gpio->gpddr1);
  97. /* We have special boot options if told by GPIOs */
  98. in_word = readl(&gpio->gpdr1);
  99. if ((in_word & 0xC0) == 0xC0) {
  100. setenv("stdin", "serial");
  101. setenv("stdout", "serial");
  102. setenv("stderr", "serial");
  103. setenv("preboot", "run gs_slow_boot");
  104. } else if ((in_word & 0xC0) != 0) {
  105. setenv("stdout", "vga");
  106. setenv("gs_bootcmd", "mw.l 0x40000000 0 1024; usb start;"
  107. "fatls usb 0; fatload usb 0 0x40000000 mcq5resq.bin;"
  108. "bootelf 0x40000000; bootelf 0x10080000");
  109. setenv("preboot", "run gs_slow_boot");
  110. } else {
  111. setenv("stdin", "serial");
  112. setenv("stdout", "serial");
  113. setenv("stderr", "serial");
  114. if (getenv("gs_devel")) {
  115. setenv("preboot", "run gs_slow_boot");
  116. } else {
  117. setenv("gs_bootcmd", "bootelf 0x10080000");
  118. setenv("preboot", "run gs_fast_boot");
  119. }
  120. }
  121. return 0;
  122. }
  123. int misc_init_r(void)
  124. {
  125. return 0;
  126. }
  127. /*
  128. * DRAM configuration
  129. */
  130. int dram_init(void)
  131. {
  132. /* dram_init must store complete ramsize in gd->ram_size */
  133. gd->ram_size = get_ram_size((volatile void *)PHYS_SDRAM,
  134. PHYS_SDRAM_SIZE);
  135. return 0;
  136. }
  137. void dram_init_banksize(void)
  138. {
  139. gd->bd->bi_dram[0].start = PHYS_SDRAM;
  140. gd->bd->bi_dram[0].size = gd->ram_size;
  141. }
  142. int board_eth_init(bd_t *bis)
  143. {
  144. int rc = 0;
  145. #ifdef CONFIG_SMC911X
  146. rc = smc911x_initialize(0, CONFIG_SMC911X_BASE);
  147. #endif
  148. return rc;
  149. }