mirror of
git://projects.qi-hardware.com/iris.git
synced 2025-02-28 22:57:55 +02:00
clockcheck
This commit is contained in:
parent
bfc65c7e9a
commit
d136712524
@ -255,6 +255,8 @@ void init ():
|
||||
GPIO_GPDIR (GPIO_USB_CLK_EN_PORT) |= 1 << GPIO_USB_CLK_EN
|
||||
GPIO_GPDR (GPIO_USB_CLK_EN_PORT) |= 1 << GPIO_USB_CLK_EN
|
||||
|
||||
dbg_send (cpm_get_pllout ())
|
||||
|
||||
// Start the operating system timer.
|
||||
unsigned latch = (JZ_EXTAL + (HZ>>1)) / HZ
|
||||
ost_set_mode (0, OST_TCSR_UIE | OST_TCSR_CKS_EXTAL)
|
||||
|
102
mips/jz4730.hhp
102
mips/jz4730.hhp
@ -3888,6 +3888,108 @@ static __inline__ void cpm_select_msc_clk (bool type):
|
||||
#define cpm_stop_uprt() (CPM_MSCR |= (1 << CPM_MSCR_MSTP_UPRT))
|
||||
#define cpm_stop_all() (CPM_MSCR = 0xffffffff)
|
||||
|
||||
static __inline__ unsigned cpm_get_pllout ():
|
||||
unsigned int nf, nr, no, pllout
|
||||
unsigned long plcr = CPM_PLCR1
|
||||
unsigned long od[4] = {1, 2, 2, 4}
|
||||
if plcr & CPM_PLCR1_PLL1EN:
|
||||
nf = (plcr & CPM_PLCR1_PLL1FD_MASK) >> CPM_PLCR1_PLL1FD_BIT
|
||||
nr = (plcr & CPM_PLCR1_PLL1RD_MASK) >> CPM_PLCR1_PLL1RD_BIT
|
||||
no = od[((plcr & CPM_PLCR1_PLL1OD_MASK) >> CPM_PLCR1_PLL1OD_BIT)]
|
||||
pllout = (JZ_EXTAL) / ((nr + 2) * no) * (nf + 2)
|
||||
else:
|
||||
pllout = JZ_EXTAL
|
||||
return pllout
|
||||
|
||||
static __inline__ unsigned cpm_get_iclk ():
|
||||
unsigned int iclk
|
||||
int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}
|
||||
unsigned long cfcr = CPM_CFCR
|
||||
unsigned long plcr = CPM_PLCR1
|
||||
if plcr & CPM_PLCR1_PLL1EN:
|
||||
iclk = cpm_get_pllout () / div[(cfcr & CPM_CFCR_IFR_MASK) >> CPM_CFCR_IFR_BIT]
|
||||
else:
|
||||
iclk = JZ_EXTAL
|
||||
return iclk
|
||||
|
||||
static __inline__ unsigned cpm_get_sclk ():
|
||||
unsigned int sclk
|
||||
int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}
|
||||
unsigned long cfcr = CPM_CFCR
|
||||
unsigned long plcr = CPM_PLCR1
|
||||
if plcr & CPM_PLCR1_PLL1EN:
|
||||
sclk = cpm_get_pllout () / div[(cfcr & CPM_CFCR_SFR_MASK) >> CPM_CFCR_SFR_BIT]
|
||||
else:
|
||||
sclk = JZ_EXTAL
|
||||
return sclk
|
||||
|
||||
static __inline__ unsigned cpm_get_mclk ():
|
||||
unsigned int mclk
|
||||
int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}
|
||||
unsigned long cfcr = CPM_CFCR
|
||||
unsigned long plcr = CPM_PLCR1
|
||||
if plcr & CPM_PLCR1_PLL1EN:
|
||||
mclk = cpm_get_pllout () / div[(cfcr & CPM_CFCR_MFR_MASK) >> CPM_CFCR_MFR_BIT]
|
||||
else
|
||||
mclk = JZ_EXTAL
|
||||
return mclk
|
||||
|
||||
static __inline__ unsigned cpm_get_pclk ():
|
||||
unsigned int devclk
|
||||
int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}
|
||||
unsigned long cfcr = CPM_CFCR
|
||||
unsigned long plcr = CPM_PLCR1
|
||||
if plcr & CPM_PLCR1_PLL1EN:
|
||||
devclk = cpm_get_pllout () / div[(cfcr & CPM_CFCR_PFR_MASK) >> CPM_CFCR_PFR_BIT]
|
||||
else:
|
||||
devclk = JZ_EXTAL
|
||||
return devclk
|
||||
|
||||
static __inline__ unsigned cpm_get_lcdclk ():
|
||||
unsigned int lcdclk
|
||||
unsigned long cfcr = CPM_CFCR
|
||||
unsigned long plcr = CPM_PLCR1
|
||||
if plcr & CPM_PLCR1_PLL1EN:
|
||||
lcdclk = cpm_get_pllout () / (((cfcr & CPM_CFCR_LFR_MASK) >> CPM_CFCR_LFR_BIT) + 1)
|
||||
else:
|
||||
lcdclk = JZ_EXTAL
|
||||
return lcdclk
|
||||
|
||||
static __inline__ unsigned cpm_get_pixclk ():
|
||||
unsigned int pixclk
|
||||
unsigned long cfcr2 = CPM_CFCR2
|
||||
pixclk = cpm_get_pllout () / (cfcr2 + 1)
|
||||
return pixclk
|
||||
|
||||
static __inline__ unsigned cpm_get_devclk ():
|
||||
return JZ_EXTAL
|
||||
|
||||
static __inline__ unsigned cpm_get_rtcclk ():
|
||||
return RTC_CLOCK
|
||||
|
||||
static __inline__ unsigned cpm_get_uartclk ():
|
||||
return JZ_EXTAL;
|
||||
|
||||
static __inline__ unsigned cpm_get_usbclk ():
|
||||
unsigned int usbclk
|
||||
unsigned long cfcr = CPM_CFCR
|
||||
if cfcr & CPM_CFCR_MSC:
|
||||
usbclk = 48000000
|
||||
else:
|
||||
usbclk = cpm_get_pllout () / (((cfcr &CPM_CFCR_UFR_MASK) >> CPM_CFCR_UFR_BIT) + 1)
|
||||
return usbclk
|
||||
|
||||
static __inline__ unsigned cpm_get_i2sclk ():
|
||||
unsigned int i2sclk
|
||||
unsigned long cfcr = CPM_CFCR
|
||||
i2sclk = cpm_get_pllout () / ((cfcr & CPM_CFCR_I2S) ? 2: 1)
|
||||
return i2sclk
|
||||
|
||||
static __inline__ unsigned cpm_get_mscclk ():
|
||||
if CPM_CFCR & CPM_CFCR_I2S:
|
||||
return 24000000
|
||||
else:
|
||||
return 16000000
|
||||
|
||||
/***************************************************************************
|
||||
* SSI
|
||||
|
Loading…
x
Reference in New Issue
Block a user