sc520_car.S 2.8 KB

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