mem.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * (C) Copyright 2010
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * Author :
  6. * Mansoor Ahamed <mansoor.ahamed@ti.com>
  7. *
  8. * Initial Code from:
  9. * Manikandan Pillai <mani.pillai@ti.com>
  10. * Richard Woodruff <r-woodruff2@ti.com>
  11. * Syed Mohammed Khasim <khasim@ti.com>
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License as
  15. * published by the Free Software Foundation; either version 2 of
  16. * the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  26. * MA 02111-1307 USA
  27. */
  28. #include <common.h>
  29. #include <asm/io.h>
  30. #include <asm/arch/cpu.h>
  31. #include <asm/arch/mem.h>
  32. #include <asm/arch/sys_proto.h>
  33. #include <command.h>
  34. struct gpmc *gpmc_cfg;
  35. #if defined(CONFIG_CMD_NAND)
  36. static const u32 gpmc_m_nand[GPMC_MAX_REG] = {
  37. M_NAND_GPMC_CONFIG1,
  38. M_NAND_GPMC_CONFIG2,
  39. M_NAND_GPMC_CONFIG3,
  40. M_NAND_GPMC_CONFIG4,
  41. M_NAND_GPMC_CONFIG5,
  42. M_NAND_GPMC_CONFIG6, 0
  43. };
  44. #endif
  45. void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
  46. u32 size)
  47. {
  48. writel(0, &cs->config7);
  49. sdelay(1000);
  50. /* Delay for settling */
  51. writel(gpmc_config[0], &cs->config1);
  52. writel(gpmc_config[1], &cs->config2);
  53. writel(gpmc_config[2], &cs->config3);
  54. writel(gpmc_config[3], &cs->config4);
  55. writel(gpmc_config[4], &cs->config5);
  56. writel(gpmc_config[5], &cs->config6);
  57. /* Enable the config */
  58. writel((((size & 0xF) << 8) | ((base >> 24) & 0x3F) |
  59. (1 << 6)), &cs->config7);
  60. sdelay(2000);
  61. }
  62. /*****************************************************
  63. * gpmc_init(): init gpmc bus
  64. * Init GPMC for x16, MuxMode (SDRAM in x32).
  65. * This code can only be executed from SRAM or SDRAM.
  66. *****************************************************/
  67. void gpmc_init(void)
  68. {
  69. /* putting a blanket check on GPMC based on ZeBu for now */
  70. gpmc_cfg = (struct gpmc *)GPMC_BASE;
  71. #ifdef CONFIG_CMD_NAND
  72. const u32 *gpmc_config = NULL;
  73. u32 base = 0;
  74. u32 size = 0;
  75. #endif
  76. /* global settings */
  77. writel(0x00000008, &gpmc_cfg->sysconfig);
  78. writel(0x00000100, &gpmc_cfg->irqstatus);
  79. writel(0x00000200, &gpmc_cfg->irqenable);
  80. writel(0x00000012, &gpmc_cfg->config);
  81. /*
  82. * Disable the GPMC0 config set by ROM code
  83. */
  84. writel(0, &gpmc_cfg->cs[0].config7);
  85. sdelay(1000);
  86. #ifdef CONFIG_CMD_NAND
  87. gpmc_config = gpmc_m_nand;
  88. base = PISMO1_NAND_BASE;
  89. size = PISMO1_NAND_SIZE;
  90. enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
  91. #endif
  92. }