orion.c revision 194072
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: head/sys/arm/mv/orion/orion.c 194072 2009-06-12 20:00:38Z marcel $");
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/bus.h>
38
39#include <machine/bus.h>
40
41#include <arm/mv/mvreg.h>
42#include <arm/mv/mvvar.h>
43#include <arm/mv/mvwin.h>
44
45extern const struct obio_pci_irq_map pci_irq_map[];
46
47struct obio_device obio_devices[] = {
48	{ "ic", MV_IC_BASE, MV_IC_SIZE,
49		{ -1 },
50		{ -1 },
51		CPU_PM_CTRL_NONE
52	},
53	{ "timer", MV_TIMERS_BASE, MV_TIMERS_SIZE,
54		{ MV_INT_BRIDGE, -1 },
55		{ -1 },
56		CPU_PM_CTRL_NONE
57	},
58	{ "gpio", MV_GPIO_BASE, MV_GPIO_SIZE,
59		{ MV_INT_GPIO7_0, MV_INT_GPIO15_8,
60		  MV_INT_GPIO23_16, MV_INT_GPIO31_24, -1 },
61		{ -1 },
62		CPU_PM_CTRL_NONE
63	},
64	{ "uart", MV_UART0_BASE, MV_UART_SIZE,
65		{ MV_INT_UART0, -1 },
66		{ -1 },
67		CPU_PM_CTRL_NONE
68	},
69	{ "uart", MV_UART1_BASE, MV_UART_SIZE,
70		{ MV_INT_UART1, -1 },
71		{ -1 },
72		CPU_PM_CTRL_NONE
73	},
74	{ "idma", MV_IDMA_BASE, MV_IDMA_SIZE,
75		{ MV_INT_IDMA_ERR, MV_INT_IDMA0, MV_INT_IDMA1,
76		  MV_INT_IDMA2, MV_INT_IDMA3, -1 },
77		{ -1 },
78		CPU_PM_CTRL_NONE
79	},
80	{ "ehci", MV_USB0_BASE, MV_USB_SIZE,
81		{ MV_INT_USB_BERR, MV_INT_USB_CI, -1 },
82		{ -1 },
83		CPU_PM_CTRL_NONE
84	},
85	{ "mge", MV_ETH0_BASE, MV_ETH_SIZE,
86		{ MV_INT_GBERX, MV_INT_GBETX, MV_INT_GBEMISC,
87		  MV_INT_GBESUM, MV_INT_GBEERR, -1 },
88		{ -1 },
89		CPU_PM_CTRL_NONE
90	},
91	{ "twsi", MV_TWSI_BASE, MV_TWSI_SIZE,
92		{ -1 }, { -1 },
93		CPU_PM_CTRL_NONE
94	},
95	{ NULL, 0, 0, { 0 } }
96};
97
98const struct obio_pci mv_pci_info[] = {
99	{ MV_TYPE_PCIE,
100		MV_PCIE_BASE,	MV_PCIE_SIZE,
101		MV_PCIE_IO_BASE, MV_PCIE_IO_SIZE,	4, 0x51,
102		MV_PCIE_MEM_BASE, MV_PCIE_MEM_SIZE,	4, 0x59,
103		NULL, MV_INT_PEX0
104	},
105
106	{ MV_TYPE_PCI,
107		MV_PCI_BASE, MV_PCI_SIZE,
108		MV_PCI_IO_BASE, MV_PCI_IO_SIZE,		3, 0x51,
109		MV_PCI_MEM_BASE, MV_PCI_MEM_SIZE,	3, 0x59,
110		pci_irq_map, -1
111	},
112
113	{ 0, 0, 0 }
114};
115
116struct resource_spec mv_gpio_res[] = {
117	{ SYS_RES_MEMORY,	0,	RF_ACTIVE },
118	{ SYS_RES_IRQ,		0,	RF_ACTIVE },
119	{ SYS_RES_IRQ,		1,	RF_ACTIVE },
120	{ SYS_RES_IRQ,		2,	RF_ACTIVE },
121	{ SYS_RES_IRQ,		3,	RF_ACTIVE },
122	{ -1, 0 }
123};
124
125const struct decode_win cpu_win_tbl[] = {
126	/* Device bus BOOT */
127	{ 1, 0x0f, MV_DEV_BOOT_PHYS_BASE, MV_DEV_BOOT_SIZE, -1 },
128
129	/* Device bus CS0 */
130	{ 1, 0x1e, MV_DEV_CS0_PHYS_BASE, MV_DEV_CS0_SIZE, -1 },
131
132	/* Device bus CS1 */
133	{ 1, 0x1d, MV_DEV_CS1_PHYS_BASE, MV_DEV_CS1_SIZE, -1 },
134
135	/* Device bus CS2 */
136	{ 1, 0x1b, MV_DEV_CS2_PHYS_BASE, MV_DEV_CS2_SIZE, -1 },
137};
138const struct decode_win *cpu_wins = cpu_win_tbl;
139int cpu_wins_no = sizeof(cpu_win_tbl) / sizeof(struct decode_win);
140
141/*
142 * Note: the decode windows table for IDMA does not explicitly have DRAM
143 * entries, which are not statically defined: active DDR banks (== windows)
144 * are established in run time from actual DDR windows settings. All active
145 * DDR banks are mapped into IDMA decode windows, so at least one IDMA decode
146 * window is occupied by the DDR bank; in case when all (MV_WIN_DDR_MAX)
147 * DDR banks are active, the remaining available IDMA decode windows for other
148 * targets is only MV_WIN_IDMA_MAX - MV_WIN_DDR_MAX.
149 */
150const struct decode_win idma_win_tbl[] = {
151	/* PCIE MEM */
152	{ 4, 0x59, MV_PCIE_MEM_PHYS_BASE, MV_PCIE_MEM_SIZE, -1 },
153
154	/* PCI MEM */
155	{ 3, 0x59, MV_PCI_MEM_PHYS_BASE, MV_PCI_MEM_SIZE, -1 },
156
157	/* Device bus BOOT */
158	{ 1, 0x0f, MV_DEV_BOOT_PHYS_BASE, MV_DEV_BOOT_SIZE, -1 },
159
160	/* Device bus CS0 */
161	{ 1, 0x1e, MV_DEV_CS0_PHYS_BASE, MV_DEV_CS0_SIZE, -1 },
162
163	/* Device bus CS1 */
164	{ 1, 0x1d, MV_DEV_CS1_PHYS_BASE, MV_DEV_CS1_SIZE, -1 },
165
166	/* Device bus CS2 */
167	{ 1, 0x1b, MV_DEV_CS2_PHYS_BASE, MV_DEV_CS2_SIZE, -1 },
168};
169const struct decode_win *idma_wins = idma_win_tbl;
170int idma_wins_no = sizeof(idma_win_tbl) / sizeof(struct decode_win);
171
172uint32_t
173get_tclk(void)
174{
175	uint32_t sar;
176
177	/*
178	 * On Orion TCLK is can be configured to 150 MHz or 166 MHz.
179	 * Current setting is read from Sample At Reset register.
180	 */
181	sar = bus_space_read_4(obio_tag, MV_MPP_BASE, SAMPLE_AT_RESET);
182	sar = (sar & TCLK_MASK) >> TCLK_SHIFT;
183	switch (sar) {
184	case 1:
185		return (TCLK_150MHZ);
186	case 2:
187		return (TCLK_166MHZ);
188	default:
189		panic("Unknown TCLK settings!");
190	}
191}
192