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>
29 #include <mach/irqs.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/time.h>
33 #include <asm/pgtable.h>
39 #define INTEGRATOR_RTC_IRQ { IRQ_RTCINT }
40 #define INTEGRATOR_UART0_IRQ { IRQ_UARTINT0 }
41 #define INTEGRATOR_UART1_IRQ { IRQ_UARTINT1 }
42 #define KMI0_IRQ { IRQ_KMIINT0 }
43 #define KMI1_IRQ { IRQ_KMIINT1 }
45 static AMBA_APB_DEVICE(rtc, "rtc", 0,
46 INTEGRATOR_RTC_BASE, INTEGRATOR_RTC_IRQ, NULL);
48 static AMBA_APB_DEVICE(uart0, "uart0", 0,
49 INTEGRATOR_UART0_BASE, INTEGRATOR_UART0_IRQ, NULL);
51 static AMBA_APB_DEVICE(uart1, "uart1", 0,
52 INTEGRATOR_UART1_BASE, INTEGRATOR_UART1_IRQ, NULL);
54 static AMBA_APB_DEVICE(kmi0, "kmi0", 0, KMI0_BASE, KMI0_IRQ, NULL);
55 static AMBA_APB_DEVICE(kmi1, "kmi1", 0, KMI1_BASE, KMI1_IRQ, NULL);
57 static struct amba_device *amba_devs[] __initdata = {
65 int __init integrator_init(bool is_cp)
70 * The Integrator/AP lacks necessary AMBA PrimeCell IDs, so we need to
71 * hard-code them. The Integator/CP and forward have proper cell IDs.
72 * Else we leave them undefined to the bus driver can autoprobe them.
74 if (!is_cp && IS_ENABLED(CONFIG_ARCH_INTEGRATOR_AP)) {
75 rtc_device.periphid = 0x00041030;
76 uart0_device.periphid = 0x00041010;
77 uart1_device.periphid = 0x00041010;
78 kmi0_device.periphid = 0x00041050;
79 kmi1_device.periphid = 0x00041050;
80 uart0_device.dev.platform_data = &ap_uart_data;
81 uart1_device.dev.platform_data = &ap_uart_data;
84 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
85 struct amba_device *d = amba_devs[i];
86 amba_device_register(d, &iomem_resource);
94 static DEFINE_RAW_SPINLOCK(cm_lock);
97 * cm_control - update the CM_CTRL register.
98 * @mask: bits to change
101 void cm_control(u32 mask, u32 set)
106 raw_spin_lock_irqsave(&cm_lock, flags);
107 val = readl(CM_CTRL) & ~mask;
108 writel(val | set, CM_CTRL);
109 raw_spin_unlock_irqrestore(&cm_lock, flags);
112 EXPORT_SYMBOL(cm_control);
115 * We need to stop things allocating the low memory; ideally we need a
116 * better implementation of GFP_DMA which does not assume that DMA-able
117 * memory starts at zero.
119 void __init integrator_reserve(void)
121 memblock_reserve(PHYS_OFFSET, __pa(swapper_pg_dir) - PHYS_OFFSET);
125 * To reset, we hit the on-board reset register in the system FPGA
127 void integrator_restart(enum reboot_mode mode, const char *cmd)
129 cm_control(CM_CTRL_RESET, CM_CTRL_RESET);
132 static u32 integrator_id;
134 static ssize_t intcp_get_manf(struct device *dev,
135 struct device_attribute *attr,
138 return sprintf(buf, "%02x\n", integrator_id >> 24);
141 static struct device_attribute intcp_manf_attr =
142 __ATTR(manufacturer, S_IRUGO, intcp_get_manf, NULL);
144 static ssize_t intcp_get_arch(struct device *dev,
145 struct device_attribute *attr,
150 switch ((integrator_id >> 16) & 0xff) {
152 arch = "ASB little-endian";
155 arch = "AHB little-endian";
158 arch = "AHB-Lite system bus, bi-endian";
168 return sprintf(buf, "%s\n", arch);
171 static struct device_attribute intcp_arch_attr =
172 __ATTR(architecture, S_IRUGO, intcp_get_arch, NULL);
174 static ssize_t intcp_get_fpga(struct device *dev,
175 struct device_attribute *attr,
180 switch ((integrator_id >> 12) & 0xf) {
188 fpga = "EPM7256AE (Altera PLD)";
195 return sprintf(buf, "%s\n", fpga);
198 static struct device_attribute intcp_fpga_attr =
199 __ATTR(fpga, S_IRUGO, intcp_get_fpga, NULL);
201 static ssize_t intcp_get_build(struct device *dev,
202 struct device_attribute *attr,
205 return sprintf(buf, "%02x\n", (integrator_id >> 4) & 0xFF);
208 static struct device_attribute intcp_build_attr =
209 __ATTR(build, S_IRUGO, intcp_get_build, NULL);
213 void integrator_init_sysfs(struct device *parent, u32 id)
216 device_create_file(parent, &intcp_manf_attr);
217 device_create_file(parent, &intcp_arch_attr);
218 device_create_file(parent, &intcp_fpga_attr);
219 device_create_file(parent, &intcp_build_attr);