kirkwood.c revision 238873
1178825Sdfr/*-
2178825Sdfr * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
3178825Sdfr * All rights reserved.
4178825Sdfr *
5178825Sdfr * Developed by Semihalf.
6178825Sdfr *
7178825Sdfr * Redistribution and use in source and binary forms, with or without
8178825Sdfr * modification, are permitted provided that the following conditions
9178825Sdfr * are met:
10178825Sdfr * 1. Redistributions of source code must retain the above copyright
11178825Sdfr *    notice, this list of conditions and the following disclaimer.
12178825Sdfr * 2. Redistributions in binary form must reproduce the above copyright
13178825Sdfr *    notice, this list of conditions and the following disclaimer in the
14178825Sdfr *    documentation and/or other materials provided with the distribution.
15178825Sdfr * 3. Neither the name of MARVELL nor the names of contributors
16178825Sdfr *    may be used to endorse or promote products derived from this software
17178825Sdfr *    without specific prior written permission.
18178825Sdfr *
19178825Sdfr * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20178825Sdfr * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21178825Sdfr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22178825Sdfr * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
23178825Sdfr * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24178825Sdfr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25178825Sdfr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26178825Sdfr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27178825Sdfr * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28178825Sdfr * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29178825Sdfr * SUCH DAMAGE.
30178825Sdfr */
31178825Sdfr
32178825Sdfr#include <sys/cdefs.h>
33178825Sdfr__FBSDID("$FreeBSD: head/sys/arm/mv/kirkwood/kirkwood.c 238873 2012-07-28 21:56:24Z hrs $");
34178825Sdfr
35178825Sdfr#include <sys/param.h>
36178825Sdfr#include <sys/systm.h>
37178825Sdfr#include <sys/bus.h>
38178825Sdfr
39178825Sdfr#include <machine/bus.h>
40178825Sdfr
41178825Sdfr#include <arm/mv/mvreg.h>
42178825Sdfr#include <arm/mv/mvvar.h>
43178825Sdfr#include <arm/mv/mvwin.h>
44178825Sdfr
45178825Sdfrstruct resource_spec mv_gpio_res[] = {
46178825Sdfr	{ SYS_RES_MEMORY,	0,	RF_ACTIVE },
47178825Sdfr	{ SYS_RES_IRQ,		0,	RF_ACTIVE },
48178825Sdfr	{ SYS_RES_IRQ,		1,	RF_ACTIVE },
49178825Sdfr	{ SYS_RES_IRQ,		2,	RF_ACTIVE },
50178825Sdfr	{ SYS_RES_IRQ,		3,	RF_ACTIVE },
51178825Sdfr	{ SYS_RES_IRQ,		4,	RF_ACTIVE },
52178825Sdfr	{ SYS_RES_IRQ,		5,	RF_ACTIVE },
53178825Sdfr	{ SYS_RES_IRQ,		6,	RF_ACTIVE },
54178825Sdfr	{ -1, 0 }
55178825Sdfr};
56178825Sdfr
57178825Sdfrconst struct decode_win xor_win_tbl[] = {
58178825Sdfr	{ 0 },
59178825Sdfr};
60178825Sdfrconst struct decode_win *xor_wins = xor_win_tbl;
61178825Sdfrint xor_wins_no = 0;
62178825Sdfr
63178825Sdfruint32_t
64178825Sdfrget_tclk(void)
65178825Sdfr{
66178825Sdfr	uint32_t dev, rev;
67178825Sdfr
68178825Sdfr	/*
69178825Sdfr	 * On Kirkwood TCLK is not configurable and depends on silicon
70178825Sdfr	 * revision:
71178825Sdfr	 * - A0 and A1 have TCLK hardcoded to 200 MHz.
72178825Sdfr	 * - Z0 and others have TCLK hardcoded to 166 MHz.
73178825Sdfr	 */
74178825Sdfr	soc_id(&dev, &rev);
75178825Sdfr	if (dev == MV_DEV_88F6281 && (rev == 2 || rev == 3))
76178825Sdfr		return (TCLK_200MHZ);
77178825Sdfr	if (dev == MV_DEV_88F6282)
78178825Sdfr		return (TCLK_200MHZ);
79178825Sdfr
80178825Sdfr	return (TCLK_166MHZ);
81178825Sdfr}
82178825Sdfr