/*
 * (C) Copyright 2000
 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

/*
 * 09-18-2001 Andreas Heppel, Sysgo RTS GmbH <aheppel@sysgo.de>
 *		We use the GPIO device on the ns87308 chip to read the bus speed
 */

#include <ppcboot.h>
#include <asm/processor.h>
#include "ns87308.h"


/* Access functions for the Machine State Register */
static __inline__ unsigned long get_msr(void)
{
    unsigned long msr;

    asm volatile("mfmsr %0" : "=r" (msr) :);
    return msr;
}

static __inline__ void set_msr(unsigned long msr)
{
    asm volatile("mtmsr %0" : : "r" (msr));
}

/* ------------------------------------------------------------------------- */

ulong get_bus_freq (ulong ignore)
{
	/*
	 * The GPIO Port 1 on BAB750 reflects the bus speed.
	 */
    volatile struct GPIO *gpio = (struct GPIO *)(CFG_ISA_IO + GPIO_BASE);

	unsigned char data = gpio->dta1;
	
	if (data & 0x02)
		return 66000000;
	
	return 83000000;
}

/* ------------------------------------------------------------------------- */


