sc520_car.S 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * (C) Copyright 2010-2011
  3. * Graeme Russ, <graeme.russ@gmail.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. #include <config.h>
  24. #include <asm/processor-flags.h>
  25. #include <asm/arch/sc520.h>
  26. #include <generated/asm-offsets.h>
  27. .section .text
  28. .globl car_init
  29. car_init:
  30. /*
  31. * How to enable Cache-As-RAM for the AMD Elan SC520:
  32. * 1. Turn off the CPU Cache (may not be strictly required)
  33. * 2. Set code execution PAR (usually the BOOTCS region) to be
  34. * non-cachable
  35. * 3. Create a Cachable PAR Region for an area of memory which is
  36. * a) NOT where the code is being executed
  37. * b) NOT SDRAM (Controller not initialised yet)
  38. * c) WILL response to read requests
  39. * The easiest way to do this is to create a second BOOTCS
  40. * PAR mappnig with an address != the PAR in step 2
  41. * 4. Issue a wbinvd to invalidate the CPU cache
  42. * 5. Turn on the CPU Cache
  43. * 6. Read 16kB from the cached PAR region setup in step 3
  44. * 7. Turn off the CPU Cache (but DO NOT issue a wbinvd)
  45. *
  46. * The following code uses PAR2 as the cached PAR (PAR0 and PAR1
  47. * are avoided as these are the only two PARs which can be used
  48. * as PCI BUS Memory regions which the board might require)
  49. *
  50. * The configuration of PAR2 must be set in the board configuration
  51. * file as CONFIG_SYS_SC520_CAR_PAR
  52. */
  53. /* Configure Cache-As-RAM PAR */
  54. movl $CONFIG_SYS_SC520_CAR_PAR, %eax
  55. movl $(SC520_MMCR_BASE + GENERATED_SC520_PAR2), %edi
  56. movl %eax, (%edi)
  57. /* Trash the cache then turn it on */
  58. wbinvd
  59. movl %cr0, %eax
  60. andl $~(X86_CR0_NW | X86_CR0_CD), %eax
  61. movl %eax, %cr0
  62. /*
  63. * The cache is now enabled and empty. Map a region of memory to
  64. * it by reading that region.
  65. */
  66. movl $CONFIG_SYS_CAR_ADDR, %esi
  67. movl $CONFIG_SYS_CAR_SIZE, %ecx
  68. shrl $2, %ecx /* we are reading longs */
  69. cld
  70. rep lodsl
  71. /* Turn off the cache, but don't trash it */
  72. movl %cr0, %eax
  73. orl $(X86_CR0_NW | X86_CR0_CD), %eax
  74. movl %eax, %cr0
  75. /* Clear the CAR region */
  76. xorl %eax, %eax
  77. movl $CONFIG_SYS_CAR_ADDR, %edi
  78. movl $CONFIG_SYS_CAR_SIZE, %ecx
  79. shrl $2, %ecx /* we are writing longs */
  80. rep stosl
  81. /*
  82. * Done - We should now have CONFIG_SYS_CAR_SIZE bytes of
  83. * Cache-As-RAM
  84. */
  85. jmp car_init_ret