soc.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * (C) Copyright 2007
  3. * Sascha Hauer, Pengutronix
  4. *
  5. * (C) Copyright 2009 Freescale Semiconductor, Inc.
  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 <asm/arch/imx-regs.h>
  27. #include <asm/arch/clock.h>
  28. #include <asm/arch/sys_proto.h>
  29. #include <asm/errno.h>
  30. #include <asm/io.h>
  31. #if !(defined(CONFIG_MX51) || defined(CONFIG_MX53))
  32. #error "CPU_TYPE not defined"
  33. #endif
  34. u32 get_cpu_rev(void)
  35. {
  36. #ifdef CONFIG_MX51
  37. int system_rev = 0x51000;
  38. #else
  39. int system_rev = 0x53000;
  40. #endif
  41. int reg = __raw_readl(ROM_SI_REV);
  42. #if defined(CONFIG_MX51)
  43. switch (reg) {
  44. case 0x02:
  45. system_rev |= CHIP_REV_1_1;
  46. break;
  47. case 0x10:
  48. if ((__raw_readl(GPIO1_BASE_ADDR + 0x0) & (0x1 << 22)) == 0)
  49. system_rev |= CHIP_REV_2_5;
  50. else
  51. system_rev |= CHIP_REV_2_0;
  52. break;
  53. case 0x20:
  54. system_rev |= CHIP_REV_3_0;
  55. break;
  56. default:
  57. system_rev |= CHIP_REV_1_0;
  58. break;
  59. }
  60. #else
  61. if (reg < 0x20)
  62. system_rev |= CHIP_REV_1_0;
  63. else
  64. system_rev |= reg;
  65. #endif
  66. return system_rev;
  67. }
  68. #if defined(CONFIG_FEC_MXC)
  69. void imx_get_mac_from_fuse(unsigned char *mac)
  70. {
  71. int i;
  72. struct iim_regs *iim = (struct iim_regs *)IMX_IIM_BASE;
  73. struct fuse_bank *bank = &iim->bank[1];
  74. struct fuse_bank1_regs *fuse =
  75. (struct fuse_bank1_regs *)bank->fuse_regs;
  76. for (i = 0; i < 6; i++)
  77. mac[i] = readl(&fuse->mac_addr[i]) & 0xff;
  78. }
  79. #endif
  80. void set_chipselect_size(int const cs_size)
  81. {
  82. unsigned int reg;
  83. struct iomuxc *iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
  84. reg = readl(&iomuxc_regs->gpr1);
  85. switch (cs_size) {
  86. case CS0_128:
  87. reg &= ~0x7; /* CS0=128MB, CS1=0, CS2=0, CS3=0 */
  88. reg |= 0x5;
  89. break;
  90. case CS0_64M_CS1_64M:
  91. reg &= ~0x3F; /* CS0=64MB, CS1=64MB, CS2=0, CS3=0 */
  92. reg |= 0x1B;
  93. break;
  94. case CS0_64M_CS1_32M_CS2_32M:
  95. reg &= ~0x1FF; /* CS0=64MB, CS1=32MB, CS2=32MB, CS3=0 */
  96. reg |= 0x4B;
  97. break;
  98. case CS0_32M_CS1_32M_CS2_32M_CS3_32M:
  99. reg &= ~0xFFF; /* CS0=32MB, CS1=32MB, CS2=32MB, CS3=32MB */
  100. reg |= 0x249;
  101. break;
  102. default:
  103. printf("Unknown chip select size: %d\n", cs_size);
  104. break;
  105. }
  106. writel(reg, &iomuxc_regs->gpr1);
  107. }