]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-integrator/core.c
dd85cc9d234c7d8d6515050a3a6ef028115bb713
[karo-tx-linux.git] / arch / arm / mach-integrator / core.c
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
26 #include <mach/hardware.h>
27 #include <mach/platform.h>
28 #include <mach/cm.h>
29
30 #include <asm/mach-types.h>
31 #include <asm/mach/time.h>
32 #include <asm/pgtable.h>
33
34 #include "common.h"
35
36 static DEFINE_RAW_SPINLOCK(cm_lock);
37
38 /**
39  * cm_get - get the value from the CM_CTRL register
40  */
41 u32 cm_get(void)
42 {
43         return readl(cm_base + INTEGRATOR_HDR_CTRL_OFFSET);
44 }
45
46 /**
47  * cm_control - update the CM_CTRL register.
48  * @mask: bits to change
49  * @set: bits to set
50  */
51 void cm_control(u32 mask, u32 set)
52 {
53         unsigned long flags;
54         u32 val;
55
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);
60 }
61
62 EXPORT_SYMBOL(cm_control);
63
64 /*
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.
68  */
69 void __init integrator_reserve(void)
70 {
71         memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
72 }
73
74 /*
75  * To reset, we hit the on-board reset register in the system FPGA
76  */
77 void integrator_restart(enum reboot_mode mode, const char *cmd)
78 {
79         cm_control(CM_CTRL_RESET, CM_CTRL_RESET);
80 }
81
82 static u32 integrator_id;
83
84 static ssize_t intcp_get_manf(struct device *dev,
85                               struct device_attribute *attr,
86                               char *buf)
87 {
88         return sprintf(buf, "%02x\n", integrator_id >> 24);
89 }
90
91 static struct device_attribute intcp_manf_attr =
92         __ATTR(manufacturer,  S_IRUGO, intcp_get_manf,  NULL);
93
94 static ssize_t intcp_get_arch(struct device *dev,
95                               struct device_attribute *attr,
96                               char *buf)
97 {
98         const char *arch;
99
100         switch ((integrator_id >> 16) & 0xff) {
101         case 0x00:
102                 arch = "ASB little-endian";
103                 break;
104         case 0x01:
105                 arch = "AHB little-endian";
106                 break;
107         case 0x03:
108                 arch = "AHB-Lite system bus, bi-endian";
109                 break;
110         case 0x04:
111                 arch = "AHB";
112                 break;
113         default:
114                 arch = "Unknown";
115                 break;
116         }
117
118         return sprintf(buf, "%s\n", arch);
119 }
120
121 static struct device_attribute intcp_arch_attr =
122         __ATTR(architecture,  S_IRUGO, intcp_get_arch,  NULL);
123
124 static ssize_t intcp_get_fpga(struct device *dev,
125                               struct device_attribute *attr,
126                               char *buf)
127 {
128         const char *fpga;
129
130         switch ((integrator_id >> 12) & 0xf) {
131         case 0x01:
132                 fpga = "XC4062";
133                 break;
134         case 0x02:
135                 fpga = "XC4085";
136                 break;
137         case 0x04:
138                 fpga = "EPM7256AE (Altera PLD)";
139                 break;
140         default:
141                 fpga = "Unknown";
142                 break;
143         }
144
145         return sprintf(buf, "%s\n", fpga);
146 }
147
148 static struct device_attribute intcp_fpga_attr =
149         __ATTR(fpga,  S_IRUGO, intcp_get_fpga,  NULL);
150
151 static ssize_t intcp_get_build(struct device *dev,
152                                struct device_attribute *attr,
153                                char *buf)
154 {
155         return sprintf(buf, "%02x\n", (integrator_id >> 4) & 0xFF);
156 }
157
158 static struct device_attribute intcp_build_attr =
159         __ATTR(build,  S_IRUGO, intcp_get_build,  NULL);
160
161
162
163 void integrator_init_sysfs(struct device *parent, u32 id)
164 {
165         integrator_id = 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);
170 }