ap.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * (C) Copyright 2010-2011
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  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. /* Tegra AP (Application Processor) code */
  24. #include <common.h>
  25. #include <asm/io.h>
  26. #include <asm/arch/gp_padctrl.h>
  27. #include <asm/arch-tegra/ap.h>
  28. #include <asm/arch-tegra/clock.h>
  29. #include <asm/arch-tegra/fuse.h>
  30. #include <asm/arch-tegra/pmc.h>
  31. #include <asm/arch-tegra/scu.h>
  32. #include <asm/arch-tegra/tegra.h>
  33. #include <asm/arch-tegra/warmboot.h>
  34. int tegra_get_chip(void)
  35. {
  36. int rev;
  37. struct apb_misc_gp_ctlr *gp =
  38. (struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE;
  39. /*
  40. * This is undocumented, Chip ID is bits 15:8 of the register
  41. * APB_MISC + 0x804, and has value 0x20 for Tegra20, 0x30 for
  42. * Tegra30, and 0x35 for T114.
  43. */
  44. rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT;
  45. debug("%s: CHIPID is 0x%02X\n", __func__, rev);
  46. return rev;
  47. }
  48. int tegra_get_sku_info(void)
  49. {
  50. int sku_id;
  51. struct fuse_regs *fuse = (struct fuse_regs *)NV_PA_FUSE_BASE;
  52. sku_id = readl(&fuse->sku_info) & 0xff;
  53. debug("%s: SKU info byte is 0x%02X\n", __func__, sku_id);
  54. return sku_id;
  55. }
  56. int tegra_get_chip_sku(void)
  57. {
  58. uint sku_id, chip_id;
  59. chip_id = tegra_get_chip();
  60. sku_id = tegra_get_sku_info();
  61. switch (chip_id) {
  62. case CHIPID_TEGRA20:
  63. switch (sku_id) {
  64. case SKU_ID_T20_7:
  65. case SKU_ID_T20:
  66. return TEGRA_SOC_T20;
  67. case SKU_ID_T25SE:
  68. case SKU_ID_AP25:
  69. case SKU_ID_T25:
  70. case SKU_ID_AP25E:
  71. case SKU_ID_T25E:
  72. return TEGRA_SOC_T25;
  73. }
  74. break;
  75. case CHIPID_TEGRA30:
  76. switch (sku_id) {
  77. case SKU_ID_T33:
  78. case SKU_ID_T30:
  79. return TEGRA_SOC_T30;
  80. }
  81. break;
  82. case CHIPID_TEGRA114:
  83. switch (sku_id) {
  84. case SKU_ID_T114_ENG:
  85. case SKU_ID_T114_1:
  86. return TEGRA_SOC_T114;
  87. }
  88. break;
  89. }
  90. /* unknown chip/sku id */
  91. printf("%s: ERROR: UNKNOWN CHIP/SKU ID COMBO (0x%02X/0x%02X)\n",
  92. __func__, chip_id, sku_id);
  93. return TEGRA_SOC_UNKNOWN;
  94. }
  95. static void enable_scu(void)
  96. {
  97. struct scu_ctlr *scu = (struct scu_ctlr *)NV_PA_ARM_PERIPHBASE;
  98. u32 reg;
  99. /* Only enable the SCU on T20/T25 */
  100. if (tegra_get_chip() != CHIPID_TEGRA20)
  101. return;
  102. /* If SCU already setup/enabled, return */
  103. if (readl(&scu->scu_ctrl) & SCU_CTRL_ENABLE)
  104. return;
  105. /* Invalidate all ways for all processors */
  106. writel(0xFFFF, &scu->scu_inv_all);
  107. /* Enable SCU - bit 0 */
  108. reg = readl(&scu->scu_ctrl);
  109. reg |= SCU_CTRL_ENABLE;
  110. writel(reg, &scu->scu_ctrl);
  111. }
  112. static u32 get_odmdata(void)
  113. {
  114. /*
  115. * ODMDATA is stored in the BCT in IRAM by the BootROM.
  116. * The BCT start and size are stored in the BIT in IRAM.
  117. * Read the data @ bct_start + (bct_size - 12). This works
  118. * on T20 and T30 BCTs, which are locked down. If this changes
  119. * in new chips (T114, etc.), we can revisit this algorithm.
  120. */
  121. u32 bct_start, odmdata;
  122. bct_start = readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BCTPTR);
  123. odmdata = readl(bct_start + BCT_ODMDATA_OFFSET);
  124. return odmdata;
  125. }
  126. static void init_pmc_scratch(void)
  127. {
  128. struct pmc_ctlr *const pmc = (struct pmc_ctlr *)NV_PA_PMC_BASE;
  129. u32 odmdata;
  130. int i;
  131. /* SCRATCH0 is initialized by the boot ROM and shouldn't be cleared */
  132. for (i = 0; i < 23; i++)
  133. writel(0, &pmc->pmc_scratch1+i);
  134. /* ODMDATA is for kernel use to determine RAM size, LP config, etc. */
  135. odmdata = get_odmdata();
  136. writel(odmdata, &pmc->pmc_scratch20);
  137. }
  138. void s_init(void)
  139. {
  140. /* Init PMC scratch memory */
  141. init_pmc_scratch();
  142. enable_scu();
  143. /* init the cache */
  144. config_cache();
  145. }