probe.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * arch/sh/kernel/cpu/sh5/probe.c
  3. *
  4. * CPU Subtype Probing for SH-5.
  5. *
  6. * Copyright (C) 2000, 2001 Paolo Alberelli
  7. * Copyright (C) 2003 - 2007 Paul Mundt
  8. *
  9. * This file is subject to the terms and conditions of the GNU General Public
  10. * License. See the file "COPYING" in the main directory of this archive
  11. * for more details.
  12. */
  13. #include <linux/init.h>
  14. #include <linux/io.h>
  15. #include <linux/string.h>
  16. #include <asm/processor.h>
  17. #include <asm/cache.h>
  18. int __init detect_cpu_and_cache_system(void)
  19. {
  20. unsigned long long cir;
  21. /* Do peeks in real mode to avoid having to set up a mapping for the
  22. WPC registers. On SH5-101 cut2, such a mapping would be exposed to
  23. an address translation erratum which would make it hard to set up
  24. correctly. */
  25. cir = peek_real_address_q(0x0d000008);
  26. if ((cir & 0xffff) == 0x5103) {
  27. boot_cpu_data.type = CPU_SH5_103;
  28. } else if (((cir >> 32) & 0xffff) == 0x51e2) {
  29. /* CPU.VCR aliased at CIR address on SH5-101 */
  30. boot_cpu_data.type = CPU_SH5_101;
  31. } else {
  32. boot_cpu_data.type = CPU_SH_NONE;
  33. }
  34. /*
  35. * First, setup some sane values for the I-cache.
  36. */
  37. boot_cpu_data.icache.ways = 4;
  38. boot_cpu_data.icache.sets = 256;
  39. boot_cpu_data.icache.linesz = L1_CACHE_BYTES;
  40. #if 0
  41. /*
  42. * FIXME: This can probably be cleaned up a bit as well.. for example,
  43. * do we really need the way shift _and_ the way_step_shift ?? Judging
  44. * by the existing code, I would guess no.. is there any valid reason
  45. * why we need to be tracking this around?
  46. */
  47. boot_cpu_data.icache.way_shift = 13;
  48. boot_cpu_data.icache.entry_shift = 5;
  49. boot_cpu_data.icache.set_shift = 4;
  50. boot_cpu_data.icache.way_step_shift = 16;
  51. boot_cpu_data.icache.asid_shift = 2;
  52. /*
  53. * way offset = cache size / associativity, so just don't factor in
  54. * associativity in the first place..
  55. */
  56. boot_cpu_data.icache.way_ofs = boot_cpu_data.icache.sets *
  57. boot_cpu_data.icache.linesz;
  58. boot_cpu_data.icache.asid_mask = 0x3fc;
  59. boot_cpu_data.icache.idx_mask = 0x1fe0;
  60. boot_cpu_data.icache.epn_mask = 0xffffe000;
  61. #endif
  62. boot_cpu_data.icache.flags = 0;
  63. /* A trivial starting point.. */
  64. memcpy(&boot_cpu_data.dcache,
  65. &boot_cpu_data.icache, sizeof(struct cache_info));
  66. return 0;
  67. }