probe.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * arch/sh/kernel/cpu/sh2/probe.c
  3. *
  4. * CPU Subtype Probing for SH-2.
  5. *
  6. * Copyright (C) 2002 Paul Mundt
  7. *
  8. * This file is subject to the terms and conditions of the GNU General Public
  9. * License. See the file "COPYING" in the main directory of this archive
  10. * for more details.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/of_fdt.h>
  14. #include <linux/smp.h>
  15. #include <linux/io.h>
  16. #include <asm/processor.h>
  17. #include <asm/cache.h>
  18. #if defined(CONFIG_CPU_J2)
  19. extern u32 __iomem *j2_ccr_base;
  20. static int __init scan_cache(unsigned long node, const char *uname,
  21. int depth, void *data)
  22. {
  23. if (!of_flat_dt_is_compatible(node, "jcore,cache"))
  24. return 0;
  25. j2_ccr_base = (u32 __iomem *)of_flat_dt_translate_address(node);
  26. return 1;
  27. }
  28. #endif
  29. void __ref cpu_probe(void)
  30. {
  31. #if defined(CONFIG_CPU_SUBTYPE_SH7619)
  32. boot_cpu_data.type = CPU_SH7619;
  33. boot_cpu_data.dcache.ways = 4;
  34. boot_cpu_data.dcache.way_incr = (1<<12);
  35. boot_cpu_data.dcache.sets = 256;
  36. boot_cpu_data.dcache.entry_shift = 4;
  37. boot_cpu_data.dcache.linesz = L1_CACHE_BYTES;
  38. boot_cpu_data.dcache.flags = 0;
  39. #endif
  40. #if defined(CONFIG_CPU_J2)
  41. #if defined(CONFIG_SMP)
  42. unsigned cpu = hard_smp_processor_id();
  43. #else
  44. unsigned cpu = 0;
  45. #endif
  46. if (cpu == 0) of_scan_flat_dt(scan_cache, NULL);
  47. if (j2_ccr_base) __raw_writel(0x80000303, j2_ccr_base + 4*cpu);
  48. if (cpu != 0) return;
  49. boot_cpu_data.type = CPU_J2;
  50. /* These defaults are appropriate for the original/current
  51. * J2 cache. Once there is a proper framework for getting cache
  52. * info from device tree, we should switch to that. */
  53. boot_cpu_data.dcache.ways = 1;
  54. boot_cpu_data.dcache.sets = 256;
  55. boot_cpu_data.dcache.entry_shift = 5;
  56. boot_cpu_data.dcache.linesz = 32;
  57. boot_cpu_data.dcache.flags = 0;
  58. boot_cpu_data.flags |= CPU_HAS_CAS_L;
  59. #else
  60. /*
  61. * SH-2 doesn't have separate caches
  62. */
  63. boot_cpu_data.dcache.flags |= SH_CACHE_COMBINED;
  64. #endif
  65. boot_cpu_data.icache = boot_cpu_data.dcache;
  66. boot_cpu_data.family = CPU_FAMILY_SH2;
  67. }