core.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 <mach/hardware.h>
  26. #include <mach/platform.h>
  27. #include <mach/cm.h>
  28. #include <mach/irqs.h>
  29. #include <asm/mach-types.h>
  30. #include <asm/mach/time.h>
  31. #include <asm/pgtable.h>
  32. #include "common.h"
  33. static DEFINE_RAW_SPINLOCK(cm_lock);
  34. /**
  35. * cm_get - get the value from the CM_CTRL register
  36. */
  37. u32 cm_get(void)
  38. {
  39. return readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
  40. }
  41. /**
  42. * cm_control - update the CM_CTRL register.
  43. * @mask: bits to change
  44. * @set: bits to set
  45. */
  46. void cm_control(u32 mask, u32 set)
  47. {
  48. unsigned long flags;
  49. u32 val;
  50. raw_spin_lock_irqsave(&cm_lock, flags);
  51. val = readl(CM_CTRL) & ~mask;
  52. writel(val | set, CM_CTRL);
  53. raw_spin_unlock_irqrestore(&cm_lock, flags);
  54. }
  55. EXPORT_SYMBOL(cm_control);
  56. /*
  57. * We need to stop things allocating the low memory; ideally we need a
  58. * better implementation of GFP_DMA which does not assume that DMA-able
  59. * memory starts at zero.
  60. */
  61. void __init integrator_reserve(void)
  62. {
  63. memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
  64. }
  65. /*
  66. * To reset, we hit the on-board reset register in the system FPGA
  67. */
  68. void integrator_restart(enum reboot_mode mode, const char *cmd)
  69. {
  70. cm_control(CM_CTRL_RESET, CM_CTRL_RESET);
  71. }
  72. static u32 integrator_id;
  73. static ssize_t intcp_get_manf(struct device *dev,
  74. struct device_attribute *attr,
  75. char *buf)
  76. {
  77. return sprintf(buf, "%02x\n", integrator_id >> 24);
  78. }
  79. static struct device_attribute intcp_manf_attr =
  80. __ATTR(manufacturer, S_IRUGO, intcp_get_manf, NULL);
  81. static ssize_t intcp_get_arch(struct device *dev,
  82. struct device_attribute *attr,
  83. char *buf)
  84. {
  85. const char *arch;
  86. switch ((integrator_id >> 16) & 0xff) {
  87. case 0x00:
  88. arch = "ASB little-endian";
  89. break;
  90. case 0x01:
  91. arch = "AHB little-endian";
  92. break;
  93. case 0x03:
  94. arch = "AHB-Lite system bus, bi-endian";
  95. break;
  96. case 0x04:
  97. arch = "AHB";
  98. break;
  99. default:
  100. arch = "Unknown";
  101. break;
  102. }
  103. return sprintf(buf, "%s\n", arch);
  104. }
  105. static struct device_attribute intcp_arch_attr =
  106. __ATTR(architecture, S_IRUGO, intcp_get_arch, NULL);
  107. static ssize_t intcp_get_fpga(struct device *dev,
  108. struct device_attribute *attr,
  109. char *buf)
  110. {
  111. const char *fpga;
  112. switch ((integrator_id >> 12) & 0xf) {
  113. case 0x01:
  114. fpga = "XC4062";
  115. break;
  116. case 0x02:
  117. fpga = "XC4085";
  118. break;
  119. case 0x04:
  120. fpga = "EPM7256AE (Altera PLD)";
  121. break;
  122. default:
  123. fpga = "Unknown";
  124. break;
  125. }
  126. return sprintf(buf, "%s\n", fpga);
  127. }
  128. static struct device_attribute intcp_fpga_attr =
  129. __ATTR(fpga, S_IRUGO, intcp_get_fpga, NULL);
  130. static ssize_t intcp_get_build(struct device *dev,
  131. struct device_attribute *attr,
  132. char *buf)
  133. {
  134. return sprintf(buf, "%02x\n", (integrator_id >> 4) & 0xFF);
  135. }
  136. static struct device_attribute intcp_build_attr =
  137. __ATTR(build, S_IRUGO, intcp_get_build, NULL);
  138. void integrator_init_sysfs(struct device *parent, u32 id)
  139. {
  140. integrator_id = id;
  141. device_create_file(parent, &intcp_manf_attr);
  142. device_create_file(parent, &intcp_arch_attr);
  143. device_create_file(parent, &intcp_fpga_attr);
  144. device_create_file(parent, &intcp_build_attr);
  145. }