Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
core.c
Go to the documentation of this file.
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/termios.h>
22 #include <linux/amba/bus.h>
23 #include <linux/amba/serial.h>
24 #include <linux/io.h>
25 
26 #include <mach/hardware.h>
27 #include <mach/platform.h>
28 #include <mach/cm.h>
29 #include <mach/irqs.h>
30 
31 #include <asm/mach-types.h>
32 #include <asm/mach/time.h>
33 #include <asm/pgtable.h>
34 
35 #include "common.h"
36 
37 #ifdef CONFIG_ATAGS
38 
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 }
44 
45 static AMBA_APB_DEVICE(rtc, "rtc", 0,
46  INTEGRATOR_RTC_BASE, INTEGRATOR_RTC_IRQ, NULL);
47 
48 static AMBA_APB_DEVICE(uart0, "uart0", 0,
49  INTEGRATOR_UART0_BASE, INTEGRATOR_UART0_IRQ, &integrator_uart_data);
50 
51 static AMBA_APB_DEVICE(uart1, "uart1", 0,
52  INTEGRATOR_UART1_BASE, INTEGRATOR_UART1_IRQ, &integrator_uart_data);
53 
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);
56 
57 static struct amba_device *amba_devs[] __initdata = {
58  &rtc_device,
59  &uart0_device,
60  &uart1_device,
61  &kmi0_device,
62  &kmi1_device,
63 };
64 
65 int __init integrator_init(bool is_cp)
66 {
67  int i;
68 
69  /*
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.
73  */
74  if (!is_cp) {
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  }
81 
82  for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
83  struct amba_device *d = amba_devs[i];
85  }
86 
87  return 0;
88 }
89 
90 #endif
91 
92 /*
93  * On the Integrator platform, the port RTS and DTR are provided by
94  * bits in the following SC_CTRLS register bits:
95  * RTS DTR
96  * UART0 7 6
97  * UART1 5 4
98  */
99 #define SC_CTRLC __io_address(INTEGRATOR_SC_CTRLC)
100 #define SC_CTRLS __io_address(INTEGRATOR_SC_CTRLS)
101 
102 static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *base, unsigned int mctrl)
103 {
104  unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
105  u32 phybase = dev->res.start;
106 
107  if (phybase == INTEGRATOR_UART0_BASE) {
108  /* UART0 */
109  rts_mask = 1 << 4;
110  dtr_mask = 1 << 5;
111  } else {
112  /* UART1 */
113  rts_mask = 1 << 6;
114  dtr_mask = 1 << 7;
115  }
116 
117  if (mctrl & TIOCM_RTS)
118  ctrlc |= rts_mask;
119  else
120  ctrls |= rts_mask;
121 
122  if (mctrl & TIOCM_DTR)
123  ctrlc |= dtr_mask;
124  else
125  ctrls |= dtr_mask;
126 
127  __raw_writel(ctrls, SC_CTRLS);
128  __raw_writel(ctrlc, SC_CTRLC);
129 }
130 
132  .set_mctrl = integrator_uart_set_mctrl,
133 };
134 
135 static DEFINE_RAW_SPINLOCK(cm_lock);
136 
142 void cm_control(u32 mask, u32 set)
143 {
144  unsigned long flags;
145  u32 val;
146 
147  raw_spin_lock_irqsave(&cm_lock, flags);
148  val = readl(CM_CTRL) & ~mask;
149  writel(val | set, CM_CTRL);
150  raw_spin_unlock_irqrestore(&cm_lock, flags);
151 }
152 
154 
155 /*
156  * We need to stop things allocating the low memory; ideally we need a
157  * better implementation of GFP_DMA which does not assume that DMA-able
158  * memory starts at zero.
159  */
161 {
163 }
164 
165 /*
166  * To reset, we hit the on-board reset register in the system FPGA
167  */
168 void integrator_restart(char mode, const char *cmd)
169 {
171 }