Merge branch 'docs-move' of git://git.kernel.org/pub/scm/linux/kernel/git/rdunlap...
[pandora-kernel.git] / arch / arm / mach-loki / common.c
1 /*
2  * arch/arm/mach-loki/common.c
3  *
4  * Core functions for Marvell Loki (88RC8480) SoCs
5  *
6  * This file is licensed under the terms of the GNU General Public
7  * License version 2.  This program is licensed "as is" without any
8  * warranty of any kind, whether express or implied.
9  */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/serial_8250.h>
15 #include <linux/mbus.h>
16 #include <linux/dma-mapping.h>
17 #include <asm/page.h>
18 #include <asm/timex.h>
19 #include <asm/mach/map.h>
20 #include <asm/mach/time.h>
21 #include <mach/bridge-regs.h>
22 #include <mach/loki.h>
23 #include <plat/orion_nand.h>
24 #include <plat/time.h>
25 #include <plat/common.h>
26 #include "common.h"
27
28 /*****************************************************************************
29  * I/O Address Mapping
30  ****************************************************************************/
31 static struct map_desc loki_io_desc[] __initdata = {
32         {
33                 .virtual        = LOKI_REGS_VIRT_BASE,
34                 .pfn            = __phys_to_pfn(LOKI_REGS_PHYS_BASE),
35                 .length         = LOKI_REGS_SIZE,
36                 .type           = MT_DEVICE,
37         },
38 };
39
40 void __init loki_map_io(void)
41 {
42         iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
43 }
44
45
46 /*****************************************************************************
47  * GE00
48  ****************************************************************************/
49 void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
50 {
51         writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
52
53         orion_ge00_init(eth_data, &loki_mbus_dram_info,
54                         GE0_PHYS_BASE, IRQ_LOKI_GBE_A_INT,
55                         0, LOKI_TCLK);
56 }
57
58
59 /*****************************************************************************
60  * GE01
61  ****************************************************************************/
62 void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
63 {
64         writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
65
66         orion_ge01_init(eth_data, &loki_mbus_dram_info,
67                         GE1_PHYS_BASE, IRQ_LOKI_GBE_B_INT,
68                         0, LOKI_TCLK);
69 }
70
71
72 /*****************************************************************************
73  * SAS/SATA
74  ****************************************************************************/
75 static struct resource loki_sas_resources[] = {
76         {
77                 .name   = "mvsas0 mem",
78                 .start  = SAS0_PHYS_BASE,
79                 .end    = SAS0_PHYS_BASE + 0x01ff,
80                 .flags  = IORESOURCE_MEM,
81         }, {
82                 .name   = "mvsas0 irq",
83                 .start  = IRQ_LOKI_SAS_A,
84                 .end    = IRQ_LOKI_SAS_A,
85                 .flags  = IORESOURCE_IRQ,
86         }, {
87                 .name   = "mvsas1 mem",
88                 .start  = SAS1_PHYS_BASE,
89                 .end    = SAS1_PHYS_BASE + 0x01ff,
90                 .flags  = IORESOURCE_MEM,
91         }, {
92                 .name   = "mvsas1 irq",
93                 .start  = IRQ_LOKI_SAS_B,
94                 .end    = IRQ_LOKI_SAS_B,
95                 .flags  = IORESOURCE_IRQ,
96         },
97 };
98
99 static struct platform_device loki_sas = {
100         .name           = "mvsas",
101         .id             = 0,
102         .dev            = {
103                 .coherent_dma_mask      = DMA_BIT_MASK(32),
104         },
105         .num_resources  = ARRAY_SIZE(loki_sas_resources),
106         .resource       = loki_sas_resources,
107 };
108
109 void __init loki_sas_init(void)
110 {
111         writel(0x8300f707, DDR_REG(0x1424));
112         platform_device_register(&loki_sas);
113 }
114
115
116 /*****************************************************************************
117  * UART0
118  ****************************************************************************/
119 void __init loki_uart0_init(void)
120 {
121         orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
122                          IRQ_LOKI_UART0, LOKI_TCLK);
123 }
124
125 /*****************************************************************************
126  * UART1
127  ****************************************************************************/
128 void __init loki_uart1_init(void)
129 {
130         orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
131                          IRQ_LOKI_UART1, LOKI_TCLK);
132 }
133
134
135 /*****************************************************************************
136  * Time handling
137  ****************************************************************************/
138 void __init loki_init_early(void)
139 {
140         orion_time_set_base(TIMER_VIRT_BASE);
141 }
142
143 static void loki_timer_init(void)
144 {
145         orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
146                         IRQ_LOKI_BRIDGE, LOKI_TCLK);
147 }
148
149 struct sys_timer loki_timer = {
150         .init = loki_timer_init,
151 };
152
153
154 /*****************************************************************************
155  * General
156  ****************************************************************************/
157 void __init loki_init(void)
158 {
159         printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
160
161         loki_setup_cpu_mbus();
162 }