2 * linux/arch/arm/mach-integrator/core.c
4 * Copyright (C) 2000-2003 Deep Blue Solutions Ltd
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.
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>
24 #include <linux/stat.h>
26 #include <linux/of_address.h>
28 #include <mach/hardware.h>
29 #include <mach/platform.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/time.h>
33 #include <asm/pgtable.h>
38 static DEFINE_RAW_SPINLOCK(cm_lock);
39 static void __iomem *cm_base;
42 * cm_get - get the value from the CM_CTRL register
46 return readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
50 * cm_control - update the CM_CTRL register.
51 * @mask: bits to change
54 void cm_control(u32 mask, u32 set)
59 raw_spin_lock_irqsave(&cm_lock, flags);
60 val = readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET) & ~mask;
61 writel(val | set, cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
62 raw_spin_unlock_irqrestore(&cm_lock, flags);
65 static const char *integrator_arch_str(u32 id)
67 switch ((id >> 16) & 0xff) {
69 return "ASB little-endian";
71 return "AHB little-endian";
73 return "AHB-Lite system bus, bi-endian";
77 return "AHB system bus, ASB processor bus";
83 static const char *integrator_fpga_str(u32 id)
85 switch ((id >> 12) & 0xf) {
93 return "EPM7256AE (Altera PLD)";
99 void cm_clear_irqs(void)
101 /* disable core module IRQs */
102 writel(0xffffffffU, cm_base + INTEGRATOR_HDR_IC_OFFSET +
106 static const struct of_device_id cm_match[] = {
107 { .compatible = "arm,core-module-integrator"},
113 struct device_node *cm = of_find_matching_node(NULL, cm_match);
117 pr_crit("no core module node found in device tree\n");
120 cm_base = of_iomap(cm, 0);
122 pr_crit("could not remap core module\n");
126 val = readl(cm_base + INTEGRATOR_HDR_ID_OFFSET);
127 pr_info("Detected ARM core module:\n");
128 pr_info(" Manufacturer: %02x\n", (val >> 24));
129 pr_info(" Architecture: %s\n", integrator_arch_str(val));
130 pr_info(" FPGA: %s\n", integrator_fpga_str(val));
131 pr_info(" Build: %02x\n", (val >> 4) & 0xFF);
132 pr_info(" Rev: %c\n", ('A' + (val & 0x03)));
136 * We need to stop things allocating the low memory; ideally we need a
137 * better implementation of GFP_DMA which does not assume that DMA-able
138 * memory starts at zero.
140 void __init integrator_reserve(void)
142 memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
146 * To reset, we hit the on-board reset register in the system FPGA
148 void integrator_restart(enum reboot_mode mode, const char *cmd)
150 cm_control(CM_CTRL_RESET, CM_CTRL_RESET);
153 static u32 integrator_id;
155 static ssize_t intcp_get_manf(struct device *dev,
156 struct device_attribute *attr,
159 return sprintf(buf, "%02x\n", integrator_id >> 24);
162 static struct device_attribute intcp_manf_attr =
163 __ATTR(manufacturer, S_IRUGO, intcp_get_manf, NULL);
165 static ssize_t intcp_get_arch(struct device *dev,
166 struct device_attribute *attr,
169 return sprintf(buf, "%s\n", integrator_arch_str(integrator_id));
172 static struct device_attribute intcp_arch_attr =
173 __ATTR(architecture, S_IRUGO, intcp_get_arch, NULL);
175 static ssize_t intcp_get_fpga(struct device *dev,
176 struct device_attribute *attr,
179 return sprintf(buf, "%s\n", integrator_fpga_str(integrator_id));
182 static struct device_attribute intcp_fpga_attr =
183 __ATTR(fpga, S_IRUGO, intcp_get_fpga, NULL);
185 static ssize_t intcp_get_build(struct device *dev,
186 struct device_attribute *attr,
189 return sprintf(buf, "%02x\n", (integrator_id >> 4) & 0xFF);
192 static struct device_attribute intcp_build_attr =
193 __ATTR(build, S_IRUGO, intcp_get_build, NULL);
197 void integrator_init_sysfs(struct device *parent, u32 id)
200 device_create_file(parent, &intcp_manf_attr);
201 device_create_file(parent, &intcp_arch_attr);
202 device_create_file(parent, &intcp_fpga_attr);
203 device_create_file(parent, &intcp_build_attr);