probe.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * arch/sh/kernel/cpu/sh3/probe.c
  4. *
  5. * CPU Subtype Probing for SH-3.
  6. *
  7. * Copyright (C) 1999, 2000 Niibe Yutaka
  8. * Copyright (C) 2002 Paul Mundt
  9. */
  10. #include <linux/init.h>
  11. #include <asm/processor.h>
  12. #include <asm/cache.h>
  13. #include <asm/io.h>
  14. void cpu_probe(void)
  15. {
  16. unsigned long addr0, addr1, data0, data1, data2, data3;
  17. jump_to_uncached();
  18. /*
  19. * Check if the entry shadows or not.
  20. * When shadowed, it's 128-entry system.
  21. * Otherwise, it's 256-entry system.
  22. */
  23. addr0 = CACHE_OC_ADDRESS_ARRAY + (3 << 12);
  24. addr1 = CACHE_OC_ADDRESS_ARRAY + (1 << 12);
  25. /* First, write back & invalidate */
  26. data0 = __raw_readl(addr0);
  27. __raw_writel(data0&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr0);
  28. data1 = __raw_readl(addr1);
  29. __raw_writel(data1&~(SH_CACHE_VALID|SH_CACHE_UPDATED), addr1);
  30. /* Next, check if there's shadow or not */
  31. data0 = __raw_readl(addr0);
  32. data0 ^= SH_CACHE_VALID;
  33. __raw_writel(data0, addr0);
  34. data1 = __raw_readl(addr1);
  35. data2 = data1 ^ SH_CACHE_VALID;
  36. __raw_writel(data2, addr1);
  37. data3 = __raw_readl(addr0);
  38. /* Lastly, invaliate them. */
  39. __raw_writel(data0&~SH_CACHE_VALID, addr0);
  40. __raw_writel(data2&~SH_CACHE_VALID, addr1);
  41. back_to_cached();
  42. boot_cpu_data.dcache.ways = 4;
  43. boot_cpu_data.dcache.entry_shift = 4;
  44. boot_cpu_data.dcache.linesz = L1_CACHE_BYTES;
  45. boot_cpu_data.dcache.flags = 0;
  46. /*
  47. * 7709A/7729 has 16K cache (256-entry), while 7702 has only
  48. * 2K(direct) 7702 is not supported (yet)
  49. */
  50. if (data0 == data1 && data2 == data3) { /* Shadow */
  51. boot_cpu_data.dcache.way_incr = (1 << 11);
  52. boot_cpu_data.dcache.entry_mask = 0x7f0;
  53. boot_cpu_data.dcache.sets = 128;
  54. boot_cpu_data.type = CPU_SH7708;
  55. boot_cpu_data.flags |= CPU_HAS_MMU_PAGE_ASSOC;
  56. } else { /* 7709A or 7729 */
  57. boot_cpu_data.dcache.way_incr = (1 << 12);
  58. boot_cpu_data.dcache.entry_mask = 0xff0;
  59. boot_cpu_data.dcache.sets = 256;
  60. boot_cpu_data.type = CPU_SH7729;
  61. #if defined(CONFIG_CPU_SUBTYPE_SH7706)
  62. boot_cpu_data.type = CPU_SH7706;
  63. #endif
  64. #if defined(CONFIG_CPU_SUBTYPE_SH7710)
  65. boot_cpu_data.type = CPU_SH7710;
  66. #endif
  67. #if defined(CONFIG_CPU_SUBTYPE_SH7712)
  68. boot_cpu_data.type = CPU_SH7712;
  69. #endif
  70. #if defined(CONFIG_CPU_SUBTYPE_SH7720)
  71. boot_cpu_data.type = CPU_SH7720;
  72. #endif
  73. #if defined(CONFIG_CPU_SUBTYPE_SH7721)
  74. boot_cpu_data.type = CPU_SH7721;
  75. #endif
  76. #if defined(CONFIG_CPU_SUBTYPE_SH7705)
  77. boot_cpu_data.type = CPU_SH7705;
  78. #if defined(CONFIG_SH7705_CACHE_32KB)
  79. boot_cpu_data.dcache.way_incr = (1 << 13);
  80. boot_cpu_data.dcache.entry_mask = 0x1ff0;
  81. boot_cpu_data.dcache.sets = 512;
  82. __raw_writel(CCR_CACHE_32KB, CCR3_REG);
  83. #else
  84. __raw_writel(CCR_CACHE_16KB, CCR3_REG);
  85. #endif
  86. #endif
  87. }
  88. /*
  89. * SH-3 doesn't have separate caches
  90. */
  91. boot_cpu_data.dcache.flags |= SH_CACHE_COMBINED;
  92. boot_cpu_data.icache = boot_cpu_data.dcache;
  93. boot_cpu_data.family = CPU_FAMILY_SH3;
  94. }