core.c 2.2 KB

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