integrator.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
  4. */
  5. #include <linux/types.h>
  6. #include <linux/kernel.h>
  7. #include <linux/init.h>
  8. #include <linux/device.h>
  9. #include <linux/export.h>
  10. #include <linux/spinlock.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/irq.h>
  13. #include <linux/memblock.h>
  14. #include <linux/sched.h>
  15. #include <linux/smp.h>
  16. #include <linux/amba/bus.h>
  17. #include <linux/amba/serial.h>
  18. #include <linux/io.h>
  19. #include <linux/stat.h>
  20. #include <linux/of.h>
  21. #include <linux/of_address.h>
  22. #include <linux/pgtable.h>
  23. #include <asm/mach-types.h>
  24. #include <asm/mach/time.h>
  25. #include "integrator-hardware.h"
  26. #include "integrator-cm.h"
  27. #include "integrator.h"
  28. static DEFINE_RAW_SPINLOCK(cm_lock);
  29. static void __iomem *cm_base;
  30. /**
  31. * cm_get - get the value from the CM_CTRL register
  32. */
  33. u32 cm_get(void)
  34. {
  35. return readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
  36. }
  37. /**
  38. * cm_control - update the CM_CTRL register.
  39. * @mask: bits to change
  40. * @set: bits to set
  41. */
  42. void cm_control(u32 mask, u32 set)
  43. {
  44. unsigned long flags;
  45. u32 val;
  46. raw_spin_lock_irqsave(&cm_lock, flags);
  47. val = readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET) & ~mask;
  48. writel(val | set, cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
  49. raw_spin_unlock_irqrestore(&cm_lock, flags);
  50. }
  51. void cm_clear_irqs(void)
  52. {
  53. /* disable core module IRQs */
  54. writel(0xffffffffU, cm_base + INTEGRATOR_HDR_IC_OFFSET +
  55. IRQ_ENABLE_CLEAR);
  56. }
  57. static const struct of_device_id cm_match[] = {
  58. { .compatible = "arm,core-module-integrator"},
  59. { },
  60. };
  61. void cm_init(void)
  62. {
  63. struct device_node *cm = of_find_matching_node(NULL, cm_match);
  64. if (!cm) {
  65. pr_crit("no core module node found in device tree\n");
  66. return;
  67. }
  68. cm_base = of_iomap(cm, 0);
  69. if (!cm_base) {
  70. pr_crit("could not remap core module\n");
  71. return;
  72. }
  73. cm_clear_irqs();
  74. }
  75. /*
  76. * We need to stop things allocating the low memory; ideally we need a
  77. * better implementation of GFP_DMA which does not assume that DMA-able
  78. * memory starts at zero.
  79. */
  80. void __init integrator_reserve(void)
  81. {
  82. memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
  83. }