kmeter1.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright (C) 2006 Freescale Semiconductor, Inc.
  3. * Dave Liu <daveliu@freescale.com>
  4. *
  5. * Copyright (C) 2007 Logic Product Development, Inc.
  6. * Peter Barada <peterb@logicpd.com>
  7. *
  8. * Copyright (C) 2007 MontaVista Software, Inc.
  9. * Anton Vorontsov <avorontsov@ru.mvista.com>
  10. *
  11. * (C) Copyright 2008
  12. * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. */
  19. #include <common.h>
  20. #include <ioports.h>
  21. #include <mpc83xx.h>
  22. #include <i2c.h>
  23. #include <miiphy.h>
  24. #include <asm/io.h>
  25. #include <asm/mmu.h>
  26. #include <pci.h>
  27. #include <libfdt.h>
  28. #include "../common/common.h"
  29. const qe_iop_conf_t qe_iop_conf_tab[] = {
  30. /* port pin dir open_drain assign */
  31. /* MDIO */
  32. {0, 1, 3, 0, 2}, /* MDIO */
  33. {0, 2, 1, 0, 1}, /* MDC */
  34. /* UCC4 - UEC */
  35. {1, 14, 1, 0, 1}, /* TxD0 */
  36. {1, 15, 1, 0, 1}, /* TxD1 */
  37. {1, 20, 2, 0, 1}, /* RxD0 */
  38. {1, 21, 2, 0, 1}, /* RxD1 */
  39. {1, 18, 1, 0, 1}, /* TX_EN */
  40. {1, 26, 2, 0, 1}, /* RX_DV */
  41. {1, 27, 2, 0, 1}, /* RX_ER */
  42. {1, 24, 2, 0, 1}, /* COL */
  43. {1, 25, 2, 0, 1}, /* CRS */
  44. {2, 15, 2, 0, 1}, /* TX_CLK - CLK16 */
  45. {2, 16, 2, 0, 1}, /* RX_CLK - CLK17 */
  46. /* DUART - UART2 */
  47. {5, 0, 1, 0, 2}, /* UART2_SOUT */
  48. {5, 2, 1, 0, 1}, /* UART2_RTS */
  49. {5, 3, 2, 0, 2}, /* UART2_SIN */
  50. {5, 1, 2, 0, 3}, /* UART2_CTS */
  51. /* END of table */
  52. {0, 0, 0, 0, QE_IOP_TAB_END},
  53. };
  54. int board_early_init_r (void)
  55. {
  56. void *reg = (void *)(CONFIG_SYS_IMMR + 0x14a8);
  57. u32 val;
  58. /*
  59. * Because of errata in the UCCs, we have to write to the reserved
  60. * registers to slow the clocks down.
  61. */
  62. val = in_be32 (reg);
  63. /* UCC1 */
  64. val |= 0x00003000;
  65. /* UCC2 */
  66. val |= 0x0c000000;
  67. out_be32 (reg, val);
  68. /* enable the PHY on the PIGGY */
  69. setbits (8, (void *)(CONFIG_SYS_PIGGY_BASE + 0x10003), 0x01);
  70. return 0;
  71. }
  72. int fixed_sdram(void)
  73. {
  74. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  75. u32 msize = 0;
  76. u32 ddr_size;
  77. u32 ddr_size_log2;
  78. msize = CONFIG_SYS_DDR_SIZE;
  79. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  80. (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
  81. if (ddr_size & 1)
  82. return -1;
  83. }
  84. im->sysconf.ddrlaw[0].ar =
  85. LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
  86. im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
  87. im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
  88. im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  89. im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  90. im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  91. im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  92. im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
  93. im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
  94. im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
  95. im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
  96. im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  97. im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
  98. udelay (200);
  99. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  100. return msize;
  101. }
  102. phys_size_t initdram (int board_type)
  103. {
  104. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  105. extern void ddr_enable_ecc (unsigned int dram_size);
  106. #endif
  107. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  108. u32 msize = 0;
  109. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
  110. return -1;
  111. /* DDR SDRAM - Main SODIMM */
  112. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
  113. msize = fixed_sdram ();
  114. #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
  115. /*
  116. * Initialize DDR ECC byte
  117. */
  118. ddr_enable_ecc (msize * 1024 * 1024);
  119. #endif
  120. /* return total bus SDRAM size(bytes) -- DDR */
  121. return (msize * 1024 * 1024);
  122. }
  123. int checkboard (void)
  124. {
  125. puts ("Board: Keymile kmeter1");
  126. if (ethernet_present ())
  127. puts (" with PIGGY.");
  128. puts ("\n");
  129. return 0;
  130. }
  131. #if defined(CONFIG_OF_BOARD_SETUP)
  132. void ft_board_setup (void *blob, bd_t *bd)
  133. {
  134. ft_cpu_setup (blob, bd);
  135. }
  136. #endif