[ARM] Orion: programable address map support
[sfrench/cifs-2.6.git] / arch / arm / mach-orion / common.c
1 /*
2  * arch/arm/mach-orion/common.c
3  *
4  * Core functions for Marvell Orion System On Chip
5  *
6  * Maintainer: Tzachi Perelstein <tzachi@marvell.com>
7  *
8  * This file is licensed under  the terms of the GNU General Public
9  * License version 2. This program is licensed "as is" without any
10  * warranty of any kind, whether express or implied.
11  */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <asm/page.h>
16 #include <asm/timex.h>
17 #include <asm/mach/map.h>
18 #include <asm/arch/orion.h>
19 #include "common.h"
20
21 /*****************************************************************************
22  * I/O Address Mapping
23  ****************************************************************************/
24 static struct map_desc orion_io_desc[] __initdata = {
25         {
26                 .virtual        = ORION_REGS_BASE,
27                 .pfn            = __phys_to_pfn(ORION_REGS_BASE),
28                 .length         = ORION_REGS_SIZE,
29                 .type           = MT_DEVICE
30         },
31         {
32                 .virtual        = ORION_PCIE_IO_BASE,
33                 .pfn            = __phys_to_pfn(ORION_PCIE_IO_BASE),
34                 .length         = ORION_PCIE_IO_SIZE,
35                 .type           = MT_DEVICE
36         },
37         {
38                 .virtual        = ORION_PCI_IO_BASE,
39                 .pfn            = __phys_to_pfn(ORION_PCI_IO_BASE),
40                 .length         = ORION_PCI_IO_SIZE,
41                 .type           = MT_DEVICE
42         },
43         {
44                 .virtual        = ORION_PCIE_WA_BASE,
45                 .pfn            = __phys_to_pfn(ORION_PCIE_WA_BASE),
46                 .length         = ORION_PCIE_WA_SIZE,
47                 .type           = MT_DEVICE
48         },
49 };
50
51 void __init orion_map_io(void)
52 {
53         iotable_init(orion_io_desc, ARRAY_SIZE(orion_io_desc));
54 }
55
56 /*****************************************************************************
57  * General
58  ****************************************************************************/
59
60 /*
61  * Identify device ID and rev from PCIE configuration header space '0'.
62  */
63 static void orion_id(u32 *dev, u32 *rev, char **dev_name)
64 {
65         orion_pcie_id(dev, rev);
66
67         if (*dev == MV88F5281_DEV_ID) {
68                 if (*rev == MV88F5281_REV_D2) {
69                         *dev_name = "MV88F5281-D2";
70                 } else if (*rev == MV88F5281_REV_D1) {
71                         *dev_name = "MV88F5281-D1";
72                 } else {
73                         *dev_name = "MV88F5281-Rev-Unsupported";
74                 }
75         } else if (*dev == MV88F5182_DEV_ID) {
76                 if (*rev == MV88F5182_REV_A2) {
77                         *dev_name = "MV88F5182-A2";
78                 } else {
79                         *dev_name = "MV88F5182-Rev-Unsupported";
80                 }
81         } else {
82                 *dev_name = "Device-Unknown";
83         }
84 }
85
86 void __init orion_init(void)
87 {
88         char *dev_name;
89         u32 dev, rev;
90
91         orion_id(&dev, &rev, &dev_name);
92         printk(KERN_INFO "Orion ID: %s. TCLK=%d.\n", dev_name, ORION_TCLK);
93
94         /*
95          * Setup Orion address map
96          */
97         orion_setup_cpu_wins();
98         orion_setup_usb_wins();
99         orion_setup_eth_wins();
100         orion_setup_pci_wins();
101         orion_setup_pcie_wins();
102         if (dev == MV88F5182_DEV_ID)
103                 orion_setup_sata_wins();
104 }