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 <asm/mach-types.h>
29 #include <asm/mach/time.h>
30 #include <asm/pgtable.h>
36 static DEFINE_RAW_SPINLOCK(cm_lock
);
37 static void __iomem
*cm_base
;
40 * cm_get - get the value from the CM_CTRL register
44 return readl(cm_base
+ INTEGRATOR_HDR_CTRL_OFFSET
);
48 * cm_control - update the CM_CTRL register.
49 * @mask: bits to change
52 void cm_control(u32 mask
, u32 set
)
57 raw_spin_lock_irqsave(&cm_lock
, flags
);
58 val
= readl(cm_base
+ INTEGRATOR_HDR_CTRL_OFFSET
) & ~mask
;
59 writel(val
| set
, cm_base
+ INTEGRATOR_HDR_CTRL_OFFSET
);
60 raw_spin_unlock_irqrestore(&cm_lock
, flags
);
63 static const char *integrator_arch_str(u32 id
)
65 switch ((id
>> 16) & 0xff) {
67 return "ASB little-endian";
69 return "AHB little-endian";
71 return "AHB-Lite system bus, bi-endian";
75 return "AHB system bus, ASB processor bus";
81 static const char *integrator_fpga_str(u32 id
)
83 switch ((id
>> 12) & 0xf) {
91 return "EPM7256AE (Altera PLD)";
97 void cm_clear_irqs(void)
99 /* disable core module IRQs */
100 writel(0xffffffffU
, cm_base
+ INTEGRATOR_HDR_IC_OFFSET
+
104 static const struct of_device_id cm_match
[] = {
105 { .compatible
= "arm,core-module-integrator"},
111 struct device_node
*cm
= of_find_matching_node(NULL
, cm_match
);
115 pr_crit("no core module node found in device tree\n");
118 cm_base
= of_iomap(cm
, 0);
120 pr_crit("could not remap core module\n");
124 val
= readl(cm_base
+ INTEGRATOR_HDR_ID_OFFSET
);
125 pr_info("Detected ARM core module:\n");
126 pr_info(" Manufacturer: %02x\n", (val
>> 24));
127 pr_info(" Architecture: %s\n", integrator_arch_str(val
));
128 pr_info(" FPGA: %s\n", integrator_fpga_str(val
));
129 pr_info(" Build: %02x\n", (val
>> 4) & 0xFF);
130 pr_info(" Rev: %c\n", ('A' + (val
& 0x03)));
134 * We need to stop things allocating the low memory; ideally we need a
135 * better implementation of GFP_DMA which does not assume that DMA-able
136 * memory starts at zero.
138 void __init
integrator_reserve(void)
140 memblock_reserve(PHYS_OFFSET
, __pa(swapper_pg_dir
) - PHYS_OFFSET
);
144 * To reset, we hit the on-board reset register in the system FPGA
146 void integrator_restart(enum reboot_mode mode
, const char *cmd
)
148 cm_control(CM_CTRL_RESET
, CM_CTRL_RESET
);
151 static u32 integrator_id
;
153 static ssize_t
intcp_get_manf(struct device
*dev
,
154 struct device_attribute
*attr
,
157 return sprintf(buf
, "%02x\n", integrator_id
>> 24);
160 static struct device_attribute intcp_manf_attr
=
161 __ATTR(manufacturer
, S_IRUGO
, intcp_get_manf
, NULL
);
163 static ssize_t
intcp_get_arch(struct device
*dev
,
164 struct device_attribute
*attr
,
167 return sprintf(buf
, "%s\n", integrator_arch_str(integrator_id
));
170 static struct device_attribute intcp_arch_attr
=
171 __ATTR(architecture
, S_IRUGO
, intcp_get_arch
, NULL
);
173 static ssize_t
intcp_get_fpga(struct device
*dev
,
174 struct device_attribute
*attr
,
177 return sprintf(buf
, "%s\n", integrator_fpga_str(integrator_id
));
180 static struct device_attribute intcp_fpga_attr
=
181 __ATTR(fpga
, S_IRUGO
, intcp_get_fpga
, NULL
);
183 static ssize_t
intcp_get_build(struct device
*dev
,
184 struct device_attribute
*attr
,
187 return sprintf(buf
, "%02x\n", (integrator_id
>> 4) & 0xFF);
190 static struct device_attribute intcp_build_attr
=
191 __ATTR(build
, S_IRUGO
, intcp_get_build
, NULL
);
195 void integrator_init_sysfs(struct device
*parent
, u32 id
)
198 device_create_file(parent
, &intcp_manf_attr
);
199 device_create_file(parent
, &intcp_arch_attr
);
200 device_create_file(parent
, &intcp_fpga_attr
);
201 device_create_file(parent
, &intcp_build_attr
);