http://downloads.netgear.com/files/GPL/GPL_Source_V361j_DM111PSP_series_consumer_rele...
[bcm963xx.git] / kernel / linux / arch / arm / mach-footbridge / mm.c
1 /*
2  *  linux/arch/arm/mach-footbridge/mm.c
3  *
4  *  Copyright (C) 1998-2000 Russell King, Dave Gilbert.
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  *  Extra MM routines for the EBSA285 architecture
11  */
12 #include <linux/config.h>
13 #include <linux/kernel.h>
14 #include <linux/mm.h>
15 #include <linux/init.h>
16  
17 #include <asm/pgtable.h>
18 #include <asm/page.h>
19 #include <asm/io.h>
20 #include <asm/hardware/dec21285.h>
21 #include <asm/mach-types.h>
22
23 #include <asm/mach/map.h>
24
25 /*
26  * Common mapping for all systems.  Note that the outbound write flush is
27  * commented out since there is a "No Fix" problem with it.  Not mapping
28  * it means that we have extra bullet protection on our feet.
29  */
30 static struct map_desc fb_common_io_desc[] __initdata = {
31  { ARMCSR_BASE,  DC21285_ARMCSR_BASE,       ARMCSR_SIZE,  MT_DEVICE },
32  { XBUS_BASE,    0x40000000,                XBUS_SIZE,    MT_DEVICE }
33 };
34
35 /*
36  * The mapping when the footbridge is in host mode.  We don't map any of
37  * this when we are in add-in mode.
38  */
39 static struct map_desc ebsa285_host_io_desc[] __initdata = {
40 #if defined(CONFIG_ARCH_FOOTBRIDGE) && defined(CONFIG_FOOTBRIDGE_HOST)
41  { PCIMEM_BASE,  DC21285_PCI_MEM,           PCIMEM_SIZE,  MT_DEVICE },
42  { PCICFG0_BASE, DC21285_PCI_TYPE_0_CONFIG, PCICFG0_SIZE, MT_DEVICE },
43  { PCICFG1_BASE, DC21285_PCI_TYPE_1_CONFIG, PCICFG1_SIZE, MT_DEVICE },
44  { PCIIACK_BASE, DC21285_PCI_IACK,          PCIIACK_SIZE, MT_DEVICE },
45  { PCIO_BASE,    DC21285_PCI_IO,            PCIO_SIZE,    MT_DEVICE }
46 #endif
47 };
48
49 /*
50  * The CO-ebsa285 mapping.
51  */
52 static struct map_desc co285_io_desc[] __initdata = {
53 #ifdef CONFIG_ARCH_CO285
54  { PCIO_BASE,    DC21285_PCI_IO,            PCIO_SIZE,    MT_DEVICE },
55  { PCIMEM_BASE,  DC21285_PCI_MEM,           PCIMEM_SIZE,  MT_DEVICE }
56 #endif
57 };
58
59 void __init footbridge_map_io(void)
60 {
61         /*
62          * Set up the common mapping first; we need this to
63          * determine whether we're in host mode or not.
64          */
65         iotable_init(fb_common_io_desc, ARRAY_SIZE(fb_common_io_desc));
66
67         /*
68          * Now, work out what we've got to map in addition on this
69          * platform.
70          */
71         if (machine_is_co285())
72                 iotable_init(co285_io_desc, ARRAY_SIZE(co285_io_desc));
73         if (footbridge_cfn_mode())
74                 iotable_init(ebsa285_host_io_desc, ARRAY_SIZE(ebsa285_host_io_desc));
75 }
76
77 #ifdef CONFIG_FOOTBRIDGE_ADDIN
78
79 /*
80  * These two functions convert virtual addresses to PCI addresses and PCI
81  * addresses to virtual addresses.  Note that it is only legal to use these
82  * on memory obtained via get_zeroed_page or kmalloc.
83  */
84 unsigned long __virt_to_bus(unsigned long res)
85 {
86         WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
87
88         return (res - PAGE_OFFSET) + (*CSR_PCISDRAMBASE & 0xfffffff0);
89 }
90 EXPORT_SYMBOL(__virt_to_bus);
91
92 unsigned long __bus_to_virt(unsigned long res)
93 {
94         res -= (*CSR_PCISDRAMBASE & 0xfffffff0);
95         res += PAGE_OFFSET;
96
97         WARN_ON(res < PAGE_OFFSET || res >= (unsigned long)high_memory);
98
99         return res;
100 }
101 EXPORT_SYMBOL(__bus_to_virt);
102
103 #endif