l2x0.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * l2 cache initialization for CSR SiRFprimaII
  3. *
  4. * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
  5. *
  6. * Licensed under GPLv2 or later.
  7. */
  8. #include <linux/init.h>
  9. #include <linux/kernel.h>
  10. #include <linux/io.h>
  11. #include <linux/errno.h>
  12. #include <linux/of.h>
  13. #include <linux/of_address.h>
  14. #include <asm/hardware/cache-l2x0.h>
  15. #include <mach/memory.h>
  16. #define L2X0_ADDR_FILTERING_START 0xC00
  17. #define L2X0_ADDR_FILTERING_END 0xC04
  18. static struct of_device_id l2x_ids[] = {
  19. { .compatible = "arm,pl310-cache" },
  20. };
  21. static int __init sirfsoc_of_l2x_init(void)
  22. {
  23. struct device_node *np;
  24. void __iomem *sirfsoc_l2x_base;
  25. np = of_find_matching_node(NULL, l2x_ids);
  26. if (!np)
  27. panic("unable to find compatible l2x node in dtb\n");
  28. sirfsoc_l2x_base = of_iomap(np, 0);
  29. if (!sirfsoc_l2x_base)
  30. panic("unable to map l2x cpu registers\n");
  31. of_node_put(np);
  32. if (!(readl_relaxed(sirfsoc_l2x_base + L2X0_CTRL) & 1)) {
  33. /*
  34. * set the physical memory windows L2 cache will cover
  35. */
  36. writel_relaxed(PLAT_PHYS_OFFSET + 1024 * 1024 * 1024,
  37. sirfsoc_l2x_base + L2X0_ADDR_FILTERING_END);
  38. writel_relaxed(PLAT_PHYS_OFFSET | 0x1,
  39. sirfsoc_l2x_base + L2X0_ADDR_FILTERING_START);
  40. writel_relaxed(0,
  41. sirfsoc_l2x_base + L2X0_TAG_LATENCY_CTRL);
  42. writel_relaxed(0,
  43. sirfsoc_l2x_base + L2X0_DATA_LATENCY_CTRL);
  44. }
  45. l2x0_init((void __iomem *)sirfsoc_l2x_base, 0x00040000,
  46. 0x00000000);
  47. return 0;
  48. }
  49. early_initcall(sirfsoc_of_l2x_init);