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> 40209131Sraj#include <machine/fdt.h> 41183840Sraj 42183840Sraj#include <arm/mv/mvreg.h> 43183840Sraj#include <arm/mv/mvvar.h> 44194072Smarcel#include <arm/mv/mvwin.h> 45183840Sraj 46186909Srajstruct resource_spec mv_gpio_res[] = { 47183840Sraj { SYS_RES_MEMORY, 0, RF_ACTIVE }, 48183840Sraj { SYS_RES_IRQ, 0, RF_ACTIVE }, 49183840Sraj { SYS_RES_IRQ, 1, RF_ACTIVE }, 50183840Sraj { SYS_RES_IRQ, 2, RF_ACTIVE }, 51183840Sraj { SYS_RES_IRQ, 3, RF_ACTIVE }, 52183840Sraj { -1, 0 } 53183840Sraj}; 54183840Sraj 55183840Srajconst struct decode_win idma_win_tbl[] = { 56209131Sraj { 0 }, 57183840Sraj}; 58183840Srajconst struct decode_win *idma_wins = idma_win_tbl; 59209131Srajint idma_wins_no = 0; 60186899Sraj 61186909Srajconst struct decode_win xor_win_tbl[] = { 62209131Sraj { 0 }, 63186909Sraj}; 64186909Srajconst struct decode_win *xor_wins = xor_win_tbl; 65209131Srajint xor_wins_no = 0; 66186909Sraj 67186899Srajuint32_t 68186899Srajget_tclk(void) 69186899Sraj{ 70186899Sraj uint32_t sar; 71186899Sraj 72186899Sraj /* 73186899Sraj * On Discovery TCLK is can be configured to 166 MHz or 200 MHz. 74186899Sraj * Current setting is read from Sample At Reset register. 75186899Sraj */ 76209131Sraj sar = bus_space_read_4(fdtbus_bs_tag, MV_MPP_BASE, SAMPLE_AT_RESET_HI); 77186899Sraj sar = (sar & TCLK_MASK) >> TCLK_SHIFT; 78186899Sraj 79186899Sraj switch (sar) { 80186899Sraj case 0: 81186899Sraj return (TCLK_166MHZ); 82186899Sraj case 1: 83186899Sraj return (TCLK_200MHZ); 84186899Sraj default: 85186899Sraj panic("Unknown TCLK settings!"); 86186899Sraj } 87186899Sraj} 88