1183840Sraj/*-
2183840Sraj * Copyright (C) 2008 MARVELL INTERNATIONAL LTD.
3183840Sraj * All rights reserved.
4183840Sraj *
5183840Sraj * Developed by Semihalf.
6183840Sraj *
7183840Sraj * Redistribution and use in source and binary forms, with or without
8183840Sraj * modification, are permitted provided that the following conditions
9183840Sraj * are met:
10183840Sraj * 1. Redistributions of source code must retain the above copyright
11183840Sraj *    notice, this list of conditions and the following disclaimer.
12183840Sraj * 2. Redistributions in binary form must reproduce the above copyright
13183840Sraj *    notice, this list of conditions and the following disclaimer in the
14183840Sraj *    documentation and/or other materials provided with the distribution.
15183840Sraj * 3. Neither the name of MARVELL nor the names of contributors
16183840Sraj *    may be used to endorse or promote products derived from this software
17183840Sraj *    without specific prior written permission.
18183840Sraj *
19183840Sraj * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20183840Sraj * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21183840Sraj * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22183840Sraj * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
23183840Sraj * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24183840Sraj * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25183840Sraj * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26183840Sraj * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27183840Sraj * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28183840Sraj * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29183840Sraj * SUCH DAMAGE.
30183840Sraj */
31183840Sraj
32183840Sraj#include <sys/cdefs.h>
33183840Sraj__FBSDID("$FreeBSD$");
34183840Sraj
35183840Sraj#include <sys/param.h>
36183840Sraj#include <sys/systm.h>
37183840Sraj#include <sys/bus.h>
38183840Sraj
39183840Sraj#include <machine/bus.h>
40183840Sraj
41183840Sraj#include <arm/mv/mvreg.h>
42183840Sraj#include <arm/mv/mvvar.h>
43194072Smarcel#include <arm/mv/mvwin.h>
44183840Sraj
45186909Srajstruct resource_spec mv_gpio_res[] = {
46183840Sraj	{ SYS_RES_MEMORY,	0,	RF_ACTIVE },
47183840Sraj	{ SYS_RES_IRQ,		0,	RF_ACTIVE },
48183840Sraj	{ SYS_RES_IRQ,		1,	RF_ACTIVE },
49183840Sraj	{ SYS_RES_IRQ,		2,	RF_ACTIVE },
50183840Sraj	{ SYS_RES_IRQ,		3,	RF_ACTIVE },
51183840Sraj	{ SYS_RES_IRQ,		4,	RF_ACTIVE },
52183840Sraj	{ SYS_RES_IRQ,		5,	RF_ACTIVE },
53183840Sraj	{ SYS_RES_IRQ,		6,	RF_ACTIVE },
54183840Sraj	{ -1, 0 }
55183840Sraj};
56183840Sraj
57186909Srajconst struct decode_win xor_win_tbl[] = {
58209131Sraj	{ 0 },
59186909Sraj};
60186909Srajconst struct decode_win *xor_wins = xor_win_tbl;
61209131Srajint xor_wins_no = 0;
62186909Sraj
63186899Srajuint32_t
64186899Srajget_tclk(void)
65186899Sraj{
66186899Sraj	uint32_t dev, rev;
67186899Sraj
68186899Sraj	/*
69186899Sraj	 * On Kirkwood TCLK is not configurable and depends on silicon
70186899Sraj	 * revision:
71204764Sraj	 * - A0 and A1 have TCLK hardcoded to 200 MHz.
72186899Sraj	 * - Z0 and others have TCLK hardcoded to 166 MHz.
73186899Sraj	 */
74186899Sraj	soc_id(&dev, &rev);
75204764Sraj	if (dev == MV_DEV_88F6281 && (rev == 2 || rev == 3))
76186899Sraj		return (TCLK_200MHZ);
77238873Shrs	if (dev == MV_DEV_88F6282)
78238873Shrs		return (TCLK_200MHZ);
79186899Sraj
80186899Sraj	return (TCLK_166MHZ);
81186899Sraj}
82