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 <mach/hardware.h>
27 #include <mach/platform.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/time.h>
32 #include <asm/pgtable.h>
36 static DEFINE_RAW_SPINLOCK(cm_lock);
39 * cm_get - get the value from the CM_CTRL register
43 return readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
47 * cm_control - update the CM_CTRL register.
48 * @mask: bits to change
51 void cm_control(u32 mask, u32 set)
56 raw_spin_lock_irqsave(&cm_lock, flags);
57 val = readl(CM_CTRL) & ~mask;
58 writel(val | set, CM_CTRL);
59 raw_spin_unlock_irqrestore(&cm_lock, flags);
62 EXPORT_SYMBOL(cm_control);
65 * We need to stop things allocating the low memory; ideally we need a
66 * better implementation of GFP_DMA which does not assume that DMA-able
67 * memory starts at zero.
69 void __init integrator_reserve(void)
71 memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
75 * To reset, we hit the on-board reset register in the system FPGA
77 void integrator_restart(enum reboot_mode mode, const char *cmd)
79 cm_control(CM_CTRL_RESET, CM_CTRL_RESET);
82 static u32 integrator_id;
84 static ssize_t intcp_get_manf(struct device *dev,
85 struct device_attribute *attr,
88 return sprintf(buf, "%02x\n", integrator_id >> 24);
91 static struct device_attribute intcp_manf_attr =
92 __ATTR(manufacturer, S_IRUGO, intcp_get_manf, NULL);
94 static ssize_t intcp_get_arch(struct device *dev,
95 struct device_attribute *attr,
100 switch ((integrator_id >> 16) & 0xff) {
102 arch = "ASB little-endian";
105 arch = "AHB little-endian";
108 arch = "AHB-Lite system bus, bi-endian";
118 return sprintf(buf, "%s\n", arch);
121 static struct device_attribute intcp_arch_attr =
122 __ATTR(architecture, S_IRUGO, intcp_get_arch, NULL);
124 static ssize_t intcp_get_fpga(struct device *dev,
125 struct device_attribute *attr,
130 switch ((integrator_id >> 12) & 0xf) {
138 fpga = "EPM7256AE (Altera PLD)";
145 return sprintf(buf, "%s\n", fpga);
148 static struct device_attribute intcp_fpga_attr =
149 __ATTR(fpga, S_IRUGO, intcp_get_fpga, NULL);
151 static ssize_t intcp_get_build(struct device *dev,
152 struct device_attribute *attr,
155 return sprintf(buf, "%02x\n", (integrator_id >> 4) & 0xFF);
158 static struct device_attribute intcp_build_attr =
159 __ATTR(build, S_IRUGO, intcp_get_build, NULL);
163 void integrator_init_sysfs(struct device *parent, u32 id)
166 device_create_file(parent, &intcp_manf_attr);
167 device_create_file(parent, &intcp_arch_attr);
168 device_create_file(parent, &intcp_fpga_attr);
169 device_create_file(parent, &intcp_build_attr);