mvblm7.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright (C) Freescale Semiconductor, Inc. 2006. All rights reserved.
  3. *
  4. * (C) Copyright 2008
  5. * Andre Schwarz, Matrix Vision GmbH, andre.schwarz@matrix-vision.de
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <ioports.h>
  27. #include <mpc83xx.h>
  28. #include <asm/mpc8349_pci.h>
  29. #include <pci.h>
  30. #include <spi.h>
  31. #include <asm/mmu.h>
  32. #if defined(CONFIG_OF_LIBFDT)
  33. #include <libfdt.h>
  34. #endif
  35. #include "mvblm7.h"
  36. int fixed_sdram(void)
  37. {
  38. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  39. u32 msize = 0;
  40. u32 ddr_size;
  41. u32 ddr_size_log2;
  42. msize = CONFIG_SYS_DDR_SIZE;
  43. for (ddr_size = msize << 20, ddr_size_log2 = 0;
  44. (ddr_size > 1);
  45. ddr_size = ddr_size >> 1, ddr_size_log2++) {
  46. if (ddr_size & 1)
  47. return -1;
  48. }
  49. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
  50. im->sysconf.ddrlaw[0].ar = LAWAR_EN | ((ddr_size_log2 - 1) &
  51. LAWAR_SIZE);
  52. im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
  53. im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
  54. im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
  55. im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
  56. im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
  57. im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
  58. im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
  59. im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
  60. im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
  61. im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
  62. im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
  63. udelay(300);
  64. im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
  65. return CONFIG_SYS_DDR_SIZE;
  66. }
  67. phys_size_t initdram(int board_type)
  68. {
  69. volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
  70. u32 msize = 0;
  71. if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
  72. return -1;
  73. im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
  74. msize = fixed_sdram();
  75. /* return total bus RAM size(bytes) */
  76. return msize * 1024 * 1024;
  77. }
  78. int checkboard(void)
  79. {
  80. puts("Board: Matrix Vision mvBlueLYNX-M7\n");
  81. return 0;
  82. }
  83. u8 *dhcp_vendorex_prep(u8 *e)
  84. {
  85. char *ptr;
  86. /* DHCP vendor-class-identifier = 60 */
  87. ptr = getenv("dhcp_vendor-class-identifier");
  88. if (ptr) {
  89. *e++ = 60;
  90. *e++ = strlen(ptr);
  91. while (*ptr)
  92. *e++ = *ptr++;
  93. }
  94. /* DHCP_CLIENT_IDENTIFIER = 61 */
  95. ptr = getenv("dhcp_client_id");
  96. if (ptr) {
  97. *e++ = 61;
  98. *e++ = strlen(ptr);
  99. while (*ptr)
  100. *e++ = *ptr++;
  101. }
  102. return e;
  103. }
  104. u8 *dhcp_vendorex_proc(u8 *popt)
  105. {
  106. return NULL;
  107. }
  108. #ifdef CONFIG_HARD_SPI
  109. int spi_cs_is_valid(unsigned int bus, unsigned int cs)
  110. {
  111. return bus == 0 && cs == 0;
  112. }
  113. void spi_cs_activate(struct spi_slave *slave)
  114. {
  115. volatile gpio83xx_t *iopd = &((immap_t *)CONFIG_SYS_IMMR)->gpio[0];
  116. iopd->dat &= ~MVBLM7_MMC_CS;
  117. }
  118. void spi_cs_deactivate(struct spi_slave *slave)
  119. {
  120. volatile gpio83xx_t *iopd = &((immap_t *)CONFIG_SYS_IMMR)->gpio[0];
  121. iopd->dat |= ~MVBLM7_MMC_CS;
  122. }
  123. #endif
  124. #if defined(CONFIG_OF_BOARD_SETUP)
  125. void ft_board_setup(void *blob, bd_t *bd)
  126. {
  127. ft_cpu_setup(blob, bd);
  128. #ifdef CONFIG_PCI
  129. ft_pci_setup(blob, bd);
  130. #endif
  131. }
  132. #endif