#include "PalmType.h"
#include "PalmChip.h"

void Run_33Mhz()
{
	XBYTE[PLL_BYPASS] &= 0xfe;
//	XBYTE[PLL_CONWS] = 0x1f; // 16 wait state
//	XBYTE[PLL_CONWS] = 0x11; // 2 wait state
	XBYTE[PLL_CONWS] = 0x0; // 0 wait state
	XBYTE[PLL1_SUP] = 0xa;	// 12MHz * (11/4) = 33MHz
	XBYTE[PLL1_SDN] = 0x3;
	XBYTE[PLL1_MODE] = 0x6;
	XBYTE[PLL_CTRL] &= 0xfe;

    while(!(XBYTE[PLL_CTRL] & 0x10));
	XBYTE[PLL_BYPASS] |= 0x01;	// use PLL1 as system clock 

//	XBYTE[SDRAM_REFL] = 0x02;			// reset sdram refresh rate 
//	XBYTE[SDRAM_REFH] = 0x02;
}

// 40/33 = 1.212
/*
void Run_40Mhz()
{
	XBYTE[PLL_CONWS] = 0x10; // 1 wait state
//	XBYTE[PLL_CONWS] = 0x1f; // 16 wait state
	XBYTE[PLL_BYPASS] &= 0xfe;
	XBYTE[PLL1_SUP] = 0x9;	// 12MHz * (10/3) = 40MHz
	XBYTE[PLL1_SDN] = 0x2;
	XBYTE[PLL1_MODE] = 0x6;
	XBYTE[PLL_CTRL] &= 0xfe;

    while(!(XBYTE[PLL_CTRL] & 0x10));
	XBYTE[PLL_BYPASS] |= 0x01;	// use PLL1 as system clock 

//	XBYTE[SDRAM_REFL] = 0x70;			// reset sdram refresh rate 
//	XBYTE[SDRAM_REFH] = 0x02;
}
*/

// 47/33 = 1.424
void Run_47Mhz()
{
	XBYTE[PLL_CONWS] = 0x11; // 2 wait state
	XBYTE[PLL_BYPASS] &= 0xfe;
	XBYTE[PLL1_SUP] = 46;	// 12MHz * (47/12) = 47MHz
	XBYTE[PLL1_SDN] = 11;
	XBYTE[PLL1_MODE] = 0x0f;
	XBYTE[PLL_CTRL] &= 0xfe;

    while(!(XBYTE[PLL_CTRL] & 0x10));
	XBYTE[PLL_BYPASS] |= 0x01;	// use PLL1 as system clock 

//	XBYTE[SDRAM_REFL] = 0xdd;			// reset sdram refresh rate 
//	XBYTE[SDRAM_REFH] = 0x02;
}



