|
|
|
|
@@ -22,7 +22,7 @@
|
|
|
|
|
#define __JZ4740_HH__
|
|
|
|
|
|
|
|
|
|
// Main clock, for cpu, serial port, and with divisors for most other hardware
|
|
|
|
|
#define JZ_EXTAL 12000000 /* 3.6864 MHz */
|
|
|
|
|
#define JZ_EXTAL 12000000 /* 12 MHz */
|
|
|
|
|
// RTC clock
|
|
|
|
|
#define RTC_CLOCK 32768 /* 32.768 KHz */
|
|
|
|
|
// Interrupt source used for system timer
|
|
|
|
|
@@ -50,7 +50,7 @@
|
|
|
|
|
#define CIM_PHYSICAL 0x13060000
|
|
|
|
|
#define ETH_PHYSICAL 0x13100000
|
|
|
|
|
|
|
|
|
|
#ifdef __KERNEL
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
// In kernel space you need to add 0xa0000000 to see them unmapped uncached in kseg2.
|
|
|
|
|
#define CPM_BASE (0xa0000000 + CPM_PHYSICAL)
|
|
|
|
|
#define INTC_BASE (0xa0000000 + INTC_PHYSICAL)
|
|
|
|
|
@@ -102,7 +102,7 @@
|
|
|
|
|
#define ETH_BASE 0x00014000
|
|
|
|
|
|
|
|
|
|
// Default lcd framebuffer mapping space.
|
|
|
|
|
#define LCD_FRAMEBUFFER_BASE ((unsigned short *)0x00015000)
|
|
|
|
|
#define LCD_FRAMEBUFFER_BASE ((unsigned char *)0x00015000)
|
|
|
|
|
|
|
|
|
|
// Map IO memory (requires a priviledged Kernel::my_thread capability).
|
|
|
|
|
#include <iris.hh>
|
|
|
|
|
@@ -2346,17 +2346,18 @@ static void gpio_disable_pull (unsigned p, unsigned pins):
|
|
|
|
|
// CPM
|
|
|
|
|
//**************************************************************************
|
|
|
|
|
static void pll_init ():
|
|
|
|
|
unsigned PHM_DIV = 3
|
|
|
|
|
unsigned int cfcr, plcr1
|
|
|
|
|
int n2FR[33] = { 0, 0, 1, 2, 3, 0, 4, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 9 }
|
|
|
|
|
int nf, pllout2;
|
|
|
|
|
cfcr = CPM_CPCCR_CLKOEN | (n2FR[1] << CPM_CPCCR_CDIV_BIT) | (n2FR[PHM_DIV] << CPM_CPCCR_HDIV_BIT) | (n2FR[PHM_DIV] << CPM_CPCCR_PDIV_BIT) | (n2FR[PHM_DIV] << CPM_CPCCR_MDIV_BIT) | (n2FR[PHM_DIV] << CPM_CPCCR_LDIV_BIT)
|
|
|
|
|
pllout2 = (cfcr & CPM_CPCCR_PCS) ? 252000000 : (252000000 / 2)
|
|
|
|
|
CPM_UHCCDR = pllout2 / 48000000 - 1
|
|
|
|
|
nf = 252000000 * 2 / JZ_EXTAL
|
|
|
|
|
plcr1 = ((nf - 2) << CPM_CPPCR_PLLM_BIT) | (0 << CPM_CPPCR_PLLN_BIT) | (0 << CPM_CPPCR_PLLOD_BIT) | (0x20 << CPM_CPPCR_PLLST_BIT) | CPM_CPPCR_PLLEN
|
|
|
|
|
CPM_CPCCR = cfcr
|
|
|
|
|
CPM_CPPCR = plcr1
|
|
|
|
|
// The cpu clock is set to 252 MHz
|
|
|
|
|
unsigned const cpu_clock = 252000000
|
|
|
|
|
// The usb clock must be 48 MHz
|
|
|
|
|
unsigned const usb_clock = 48000000
|
|
|
|
|
// ssi clock must be 12 MHz, therefore it is taken directly from JZ_EXTAL, not from divided pll output.
|
|
|
|
|
|
|
|
|
|
// USB clock must be 48 MHz.
|
|
|
|
|
CPM_UHCCDR = (cpu_clock / 2) / usb_clock - 1
|
|
|
|
|
// Set up dividers; see documentation for the meaning of all the values.
|
|
|
|
|
CPM_CPCCR = CPM_CPCCR_CLKOEN | CPM_CPCCR_UCS | (0 << CPM_CPCCR_CDIV_BIT) | (2 << CPM_CPCCR_HDIV_BIT) | (2 << CPM_CPCCR_PDIV_BIT) | (2 << CPM_CPCCR_MDIV_BIT) | (3 << CPM_CPCCR_LDIV_BIT)
|
|
|
|
|
// Configure the pll frequency to 252 MHz.
|
|
|
|
|
CPM_CPPCR = ((cpu_clock * 2 / JZ_EXTAL - 2) << CPM_CPPCR_PLLM_BIT) | (0 << CPM_CPPCR_PLLN_BIT) | (0 << CPM_CPPCR_PLLOD_BIT) | (0x20 << CPM_CPPCR_PLLST_BIT) | CPM_CPPCR_PLLEN
|
|
|
|
|
|
|
|
|
|
static unsigned cpm_get_pllm ():
|
|
|
|
|
return (CPM_CPPCR & CPM_CPPCR_PLLM_MASK) >> CPM_CPPCR_PLLM_BIT
|
|
|
|
|
@@ -2388,32 +2389,32 @@ static unsigned cpm_get_uhcdiv ():
|
|
|
|
|
static unsigned cpm_get_ssidiv ():
|
|
|
|
|
return (CPM_SSICDR & CPM_SSICDR_SSIDIV_MASK) >> CPM_SSICDR_SSIDIV_BIT
|
|
|
|
|
|
|
|
|
|
static unsigned cpm_set_cdiv (unsigned v):
|
|
|
|
|
return CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_CDIV_MASK) | (v << (CPM_CPCCR_CDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_hdiv (unsigned v):
|
|
|
|
|
return CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_HDIV_MASK) | (v << (CPM_CPCCR_HDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_pdiv (unsigned v):
|
|
|
|
|
return CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_PDIV_MASK) | (v << (CPM_CPCCR_PDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_mdiv (unsigned v):
|
|
|
|
|
return CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_MDIV_MASK) | (v << (CPM_CPCCR_MDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_ldiv (unsigned v):
|
|
|
|
|
return CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_LDIV_MASK) | (v << (CPM_CPCCR_LDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_udiv (unsigned v):
|
|
|
|
|
return CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_UDIV_MASK) | (v << (CPM_CPCCR_UDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_i2sdiv (unsigned v):
|
|
|
|
|
return CPM_I2SCDR = (CPM_I2SCDR & ~CPM_I2SCDR_I2SDIV_MASK) | (v << (CPM_I2SCDR_I2SDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_pixdiv (unsigned v):
|
|
|
|
|
return CPM_LPCDR = (CPM_LPCDR & ~CPM_LPCDR_PIXDIV_MASK) | (v << (CPM_LPCDR_PIXDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_mscdiv (unsigned v):
|
|
|
|
|
return CPM_MSCCDR = (CPM_MSCCDR & ~CPM_MSCCDR_MSCDIV_MASK) | (v << (CPM_MSCCDR_MSCDIV_BIT))
|
|
|
|
|
static unsigned cpm_set_uhcdiv (unsigned v):
|
|
|
|
|
return CPM_UHCCDR = (CPM_UHCCDR & ~CPM_UHCCDR_UHCDIV_MASK) | (v << (CPM_UHCCDR_UHCDIV_BIT))
|
|
|
|
|
static unsigned cpm_ssiclk_select_exclk ():
|
|
|
|
|
return CPM_SSICDR &= ~CPM_SSICDR_SCS
|
|
|
|
|
static unsigned cpm_ssiclk_select_pllout ():
|
|
|
|
|
return CPM_SSICDR |= CPM_SSICDR_SCS
|
|
|
|
|
static unsigned cpm_set_ssidiv (unsigned v):
|
|
|
|
|
return CPM_SSICDR = (CPM_SSICDR & ~CPM_SSICDR_SSIDIV_MASK) | ((v) << (CPM_SSICDR_SSIDIV_BIT))
|
|
|
|
|
static void cpm_set_cdiv (unsigned v):
|
|
|
|
|
CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_CDIV_MASK) | (v << (CPM_CPCCR_CDIV_BIT))
|
|
|
|
|
static void cpm_set_hdiv (unsigned v):
|
|
|
|
|
CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_HDIV_MASK) | (v << (CPM_CPCCR_HDIV_BIT))
|
|
|
|
|
static void cpm_set_pdiv (unsigned v):
|
|
|
|
|
CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_PDIV_MASK) | (v << (CPM_CPCCR_PDIV_BIT))
|
|
|
|
|
static void cpm_set_mdiv (unsigned v):
|
|
|
|
|
CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_MDIV_MASK) | (v << (CPM_CPCCR_MDIV_BIT))
|
|
|
|
|
static void cpm_set_ldiv (unsigned v):
|
|
|
|
|
CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_LDIV_MASK) | (v << (CPM_CPCCR_LDIV_BIT))
|
|
|
|
|
static void cpm_set_udiv (unsigned v):
|
|
|
|
|
CPM_CPCCR = (CPM_CPCCR & ~CPM_CPCCR_UDIV_MASK) | (v << (CPM_CPCCR_UDIV_BIT))
|
|
|
|
|
static void cpm_set_i2sdiv (unsigned v):
|
|
|
|
|
CPM_I2SCDR = (CPM_I2SCDR & ~CPM_I2SCDR_I2SDIV_MASK) | (v << (CPM_I2SCDR_I2SDIV_BIT))
|
|
|
|
|
static void cpm_set_pixdiv (unsigned v):
|
|
|
|
|
CPM_LPCDR = (CPM_LPCDR & ~CPM_LPCDR_PIXDIV_MASK) | (v << (CPM_LPCDR_PIXDIV_BIT))
|
|
|
|
|
static void cpm_set_mscdiv (unsigned v):
|
|
|
|
|
CPM_MSCCDR = (CPM_MSCCDR & ~CPM_MSCCDR_MSCDIV_MASK) | (v << (CPM_MSCCDR_MSCDIV_BIT))
|
|
|
|
|
static void cpm_set_uhcdiv (unsigned v):
|
|
|
|
|
CPM_UHCCDR = (CPM_UHCCDR & ~CPM_UHCCDR_UHCDIV_MASK) | (v << (CPM_UHCCDR_UHCDIV_BIT))
|
|
|
|
|
static void cpm_ssiclk_select_exclk ():
|
|
|
|
|
CPM_SSICDR &= ~CPM_SSICDR_SCS
|
|
|
|
|
static void cpm_ssiclk_select_pllout ():
|
|
|
|
|
CPM_SSICDR |= CPM_SSICDR_SCS
|
|
|
|
|
static void cpm_set_ssidiv (unsigned v):
|
|
|
|
|
CPM_SSICDR = (CPM_SSICDR & ~CPM_SSICDR_SSIDIV_MASK) | ((v) << (CPM_SSICDR_SSIDIV_BIT))
|
|
|
|
|
|
|
|
|
|
#define cpm_select_i2sclk_exclk() (CPM_CPCCR &= ~CPM_CPCCR_I2CS)
|
|
|
|
|
#define cpm_select_i2sclk_pll() (CPM_CPCCR |= CPM_CPCCR_I2CS)
|
|
|
|
|
@@ -2485,7 +2486,7 @@ static unsigned cpm_get_pllout ():
|
|
|
|
|
m = cpm_get_pllm () + 2
|
|
|
|
|
n = cpm_get_plln () + 2
|
|
|
|
|
no = od[cpm_get_pllod ()]
|
|
|
|
|
pllout = ((JZ_EXTAL) / (n * no)) * m
|
|
|
|
|
pllout = JZ_EXTAL * m / n / no
|
|
|
|
|
else:
|
|
|
|
|
pllout = JZ_EXTAL
|
|
|
|
|
return pllout
|
|
|
|
|
@@ -3011,6 +3012,13 @@ static void ac97_cold_reset_codec():
|
|
|
|
|
|
|
|
|
|
#define i2s_reset_codec() do { } while (0)
|
|
|
|
|
|
|
|
|
|
static void aic_use_internal_codec ():
|
|
|
|
|
aic_internal_codec ()
|
|
|
|
|
aic_select_i2s ()
|
|
|
|
|
i2s_as_slave ()
|
|
|
|
|
i2s_select_i2s ()
|
|
|
|
|
cpm_select_i2sclk_exclk ()
|
|
|
|
|
cpm_set_i2sdiv (1)
|
|
|
|
|
|
|
|
|
|
//**************************************************************************
|
|
|
|
|
// ICDC
|
|
|
|
|
@@ -3598,8 +3606,8 @@ static void setup_sdram ():
|
|
|
|
|
unsigned cas_latency_dmcr[2] = { 1 << EMC_DMCR_TCL_BIT, 2 << EMC_DMCR_TCL_BIT }
|
|
|
|
|
int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}
|
|
|
|
|
|
|
|
|
|
cpu_clk = 225000000
|
|
|
|
|
gpio_as_sdram_32bit ()
|
|
|
|
|
cpu_clk = 252000000
|
|
|
|
|
gpio_as_sdram_16bit ()
|
|
|
|
|
unsigned SDRAM_BW16 = 0
|
|
|
|
|
unsigned SDRAM_BANK4 = 1
|
|
|
|
|
unsigned SDRAM_ROW = 13
|
|
|
|
|
|