]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - sys/arm/mv/kirkwood/db88f6xxx.c
Copy head to stable/8 as part of 8.0 Release cycle.
[FreeBSD/stable/8.git] / sys / arm / mv / kirkwood / db88f6xxx.c
1 /*-
2  * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
3  * All rights reserved.
4  *
5  * Developed by Semihalf.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. Neither the name of MARVELL nor the names of contributors
16  *    may be used to endorse or promote products derived from this software
17  *    without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29  * SUCH DAMAGE.
30  */
31
32 #include <sys/cdefs.h>
33 __FBSDID("$FreeBSD$");
34
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/bus.h>
38 #include <sys/kernel.h>
39
40 #include <vm/vm.h>
41 #include <vm/pmap.h>
42
43 #include <machine/bus.h>
44 #include <machine/pte.h>
45 #include <machine/pmap.h>
46 #include <machine/vmparam.h>
47
48 #include <arm/mv/mvreg.h>
49 #include <arm/mv/mvvar.h>
50 #include <arm/mv/mvwin.h>
51
52 /*
53  * Virtual address space layout:
54  * -----------------------------
55  * 0x0000_0000 - 0xbfff_ffff    : user process
56  *
57  * 0xc040_0000 - virtual_avail  : kernel reserved (text, data, page tables
58  *                              : structures, ARM stacks etc.)
59  * virtual_avail - 0xefff_ffff  : KVA (virtual_avail is typically < 0xc0a0_0000)
60  * 0xf000_0000 - 0xf0ff_ffff    : no-cache allocation area (16MB)
61  * 0xf100_0000 - 0xf10f_ffff    : SoC integrated devices registers range (1MB)
62  * 0xf110_0000 - 0xf11f_ffff    : PCI-Express I/O space (1MB)
63  * 0xf120_0000 - 0xf12f_ffff    : unused (1MB)
64  * 0xf130_0000 - 0xf52f_ffff    : PCI-Express memory space (64MB)
65  * 0xf930_0000 - 0xfffe_ffff    : unused (~172MB)
66  * 0xffff_0000 - 0xffff_0fff    : 'high' vectors page (4KB)
67  * 0xffff_1000 - 0xffff_1fff    : ARM_TP_ADDRESS/RAS page (4KB)
68  * 0xffff_2000 - 0xffff_ffff    : unused (~55KB)
69  */
70
71 const struct pmap_devmap *pmap_devmap_bootstrap_table;
72 vm_offset_t pmap_bootstrap_lastaddr;
73
74 /* Static device mappings. */
75 static const struct pmap_devmap pmap_devmap[] = {
76         /*
77          * Map the on-board devices VA == PA so that we can access them
78          * with the MMU on or off.
79          */
80         { /* SoC integrated peripherals registers range */
81                 MV_BASE,
82                 MV_PHYS_BASE,
83                 MV_SIZE,
84                 VM_PROT_READ | VM_PROT_WRITE,
85                 PTE_NOCACHE,
86         },
87         { /* PCIE I/O */
88                 MV_PCIE_IO_BASE,
89                 MV_PCIE_IO_PHYS_BASE,
90                 MV_PCIE_IO_SIZE,
91                 VM_PROT_READ | VM_PROT_WRITE,
92                 PTE_NOCACHE,
93         },
94         { /* PCIE Memory */
95                 MV_PCIE_MEM_BASE,
96                 MV_PCIE_MEM_PHYS_BASE,
97                 MV_PCIE_MEM_SIZE,
98                 VM_PROT_READ | VM_PROT_WRITE,
99                 PTE_NOCACHE,
100         },
101         { 0, 0, 0, 0, 0, }
102 };
103
104 const struct gpio_config mv_gpio_config[] = {
105         { -1, -1, -1 }
106 };
107
108 int
109 platform_pmap_init(void)
110 {
111
112         pmap_bootstrap_lastaddr = MV_BASE - ARM_NOCACHE_KVA_SIZE;
113         pmap_devmap_bootstrap_table = &pmap_devmap[0];
114
115         return (0);
116 }
117
118 void
119 platform_mpp_init(void)
120 {
121
122         /*
123          * MPP configuration for DB-88F6281-BP and DB-88F6281-BP-A
124          *
125          * MPP[0]:  NF_IO[2]
126          * MPP[1]:  NF_IO[3]
127          * MPP[2]:  NF_IO[4]
128          * MPP[3]:  NF_IO[5]
129          * MPP[4]:  NF_IO[6]
130          * MPP[5]:  NF_IO[7]
131          * MPP[6]:  SYSRST_OUTn
132          * MPP[7]:  SPI_SCn
133          * MPP[8]:  TW_SDA
134          * MPP[9]:  TW_SCK
135          * MPP[10]: UA0_TXD
136          * MPP[11]: UA0_RXD
137          * MPP[12]: SD_CLK
138          * MPP[13]: SD_CMD
139          * MPP[14]: SD_D[0]
140          * MPP[15]: SD_D[1]
141          * MPP[16]: SD_D[2]
142          * MPP[17]: SD_D[3]
143          * MPP[18]: NF_IO[0]
144          * MPP[19]: NF_IO[1]
145          * MPP[20]: SATA1_AC
146          * MPP[21]: SATA0_AC
147          *
148          * Others:  GPIO
149          */
150         bus_space_write_4(obio_tag, MV_MPP_BASE, MPP_CONTROL0, 0x21111111);
151         bus_space_write_4(obio_tag, MV_MPP_BASE, MPP_CONTROL1, 0x11113311);
152         bus_space_write_4(obio_tag, MV_MPP_BASE, MPP_CONTROL2, 0x00551111);
153         bus_space_write_4(obio_tag, MV_MPP_BASE, MPP_CONTROL3, 0x00000000);
154         bus_space_write_4(obio_tag, MV_MPP_BASE, MPP_CONTROL4, 0x00000000);
155         bus_space_write_4(obio_tag, MV_MPP_BASE, MPP_CONTROL5, 0x00000000);
156         bus_space_write_4(obio_tag, MV_MPP_BASE, MPP_CONTROL6, 0x00000000);
157 }
158
159 static void
160 platform_identify(void *dummy)
161 {
162
163         soc_identify();
164
165         /*
166          * XXX Board identification e.g. read out from FPGA or similar should
167          * go here
168          */
169 }
170 SYSINIT(platform_identify, SI_SUB_CPU, SI_ORDER_SECOND, platform_identify, NULL);