分类: LINUX
2010-01-04 16:52:10
{
s
s
s
}
{
if (xtal == 0)
xtal = 12*1000*1000;
if (cpu == NULL)
panic("s
if (cpu->init_clocks == NULL)
panic("s
else
(cpu->init_clocks)(xtal);
}
{
.idcode = 0x32410000,
.idmask = 0xffffffff,
.map_io = s
.init_clocks = s
.init_uarts = s
.init = s
.name = name_s
},
{
.idcode = 0x32410002,
.idmask = 0xffffffff,
.map_io = s
.init_clocks = s
.init_uarts = s
.init = s
.name = name_s
},
{
.idcode = 0x32440000,
.idmask = 0xffffffff,
.map_io = s
.init_clocks = s
.init_uarts = s
.init = s
.name = name_s
},
};
{
unsigned long clkdiv;
unsigned long camdiv;
unsigned long hclk, fclk, pclk;
int hdiv = 1;
/* now we've got our machine bits initialised, work out what
* clocks we've got */
unsigned long delay=0;
__raw_writel(__raw_readl(S
while(delay<10) delay++;
delay=0;
__raw_writel(S
while(delay<100) delay++;
fclk = s
clkdiv = __raw_readl(S
camdiv = __raw_readl(S
/* work out clock scalings */
switch (clkdiv & S
case S
hdiv = 1;
break;
case S
hdiv = 2;
break;
case S
hdiv = (camdiv & S
break;
case S
hdiv = (camdiv & S
break;
}
hclk = fclk / hdiv;
pclk = hclk / ((clkdiv & S
/* print brief summary of clocks, etc */
printk("S
print_mhz(fclk), print_mhz(hclk), print_mhz(pclk));
/* initialise the clocks here, to allow other things like the
* console to use them, and to add new ones after the initialisation
*/
s
s
}
/* base clocks */
struct clk clk_xtal = {
.name = "xtal",
.id = -1,
.rate = 0,
.parent = NULL,
.ctrlbit = 0,
};
struct clk clk_mpll = {
.name = "mpll",
.id = -1,
};
struct clk clk_upll = {
.name = "upll",
.id = -1,
.parent = NULL,
.ctrlbit = 0,
};
struct clk clk_f = {
.name = "fclk",
.id = -1,
.rate = 0,
.parent = &clk_mpll,
.ctrlbit = 0,
};
struct clk clk_h = {
.name = "hclk",
.id = -1,
.rate = 0,
.parent = NULL,
.ctrlbit = 0,
};
struct clk clk_p = {
.name = "pclk",
.id = -1,
.rate = 0,
.parent = NULL,
.ctrlbit = 0,
};
struct clk clk_usb_bus = {
.name = "usb-bus",
.id = -1,
.rate = 0,
.parent = &clk_upll,
};
int s
{
clk->owner = THIS_MODULE;
if (clk->enable == NULL)
clk->enable = clk_null_enable;
/* add to the list of available clocks */
mutex_lock(&clocks_mutex);
list_add(&clk->list, &clocks);
mutex_unlock(&clocks_mutex);
return 0;
}
unsigned long fclk,
unsigned long hclk,
unsigned long pclk)
{
printk(KERN_INFO "S
/* initialise the main system clocks */
clk_xtal.rate = xtal;
clk_upll.rate = s
clk_mpll.rate = fclk;
clk_h.rate = hclk;
clk_p.rate = pclk;
clk_f.rate = fclk;
/* assume uart clocks are correctly setup */
/* register our clocks */
if (s
printk(KERN_ERR "failed to register master xtal\n");
if (s
printk(KERN_ERR "failed to register mpll clock\n");
if (s
printk(KERN_ERR "failed to register upll clock\n");
if (s
printk(KERN_ERR "failed to register cpu fclk\n");
if (s
printk(KERN_ERR "failed to register cpu hclk\n");
if (s
printk(KERN_ERR "failed to register cpu pclk\n");
return 0;
}
{
unsigned int clocks = clk->ctrlbit;
unsigned long clkcon;
clkcon = __raw_readl(S
if (enable)
clkcon |= clocks;
else
clkcon &= ~clocks;
/* ensure none of the special function bits set */
clkcon &= ~(S
__raw_writel(clkcon, S
return 0;
}
{
unsigned long clkslow = __raw_readl(S
unsigned long orig = clkslow;
if (enable)
clkslow &= ~S
else
clkslow |= S
__raw_writel(clkslow, S
/* if we started the UPLL, then allow to settle */
if (enable && (orig & S
udelay(200);
return 0;
}
/* standard clock definitions */
static struct clk init_clocks_disable[] = {
{
.name = "nand",
.id = -1,
.parent = &clk_h,
.enable = s
.ctrlbit = S
}, {
.name = "sdi",
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "adc",
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "i
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "iis",
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "spi",
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}
};
static struct clk init_clocks[] = {
{
.name = "lcd",
.id = -1,
.parent = &clk_h,
.enable = s
.ctrlbit = S
}, {
.name = "gpio",
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "usb-host",
.id = -1,
.parent = &clk_h,
.enable = s
.ctrlbit = S
}, {
.name = "usb-device",
.id = -1,
.parent = &clk_h,
.enable = s
.ctrlbit = S
}, {
.name = "timers",
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "uart",
.id = 0,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "uart",
.id = 1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "uart",
.id = 2,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "rtc",
.id = -1,
.parent = &clk_p,
.enable = s
.ctrlbit = S
}, {
.name = "watchdog",
.id = -1,
.parent = &clk_p,
.ctrlbit = 0,
}, {
.name = "usb-bus-host",
.id = -1,
.parent = &clk_usb_bus,
}, {
.name = "usb-bus-gadget",
.id = -1,
.parent = &clk_usb_bus,
},
};
/* s
*
* Add all the clocks used by the s
* such as the S
*
* We cannot use a system device as we are needed before any
* of the init-calls that initialise the devices are actually
* done.
*/
{
unsigned long clkslow = __raw_readl(S
unsigned long clkcon = __raw_readl(S
struct clk *clkp;
struct clk *xtal;
int ret;
int ptr;
clk_upll.enable = s
if (s
printk(KERN_ERR "failed to register usb bus clock\n");
/* register clocks from clock array */
clkp = init_clocks;
for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) {
/* ensure that we note the clock state */
clkp->usage = clkcon & clkp->ctrlbit ? 1 : 0;
ret = s
if (ret < 0) {
printk(KERN_ERR "Failed to register clock %s (%d)\n",
clkp->name, ret);
}
}
/* We must be careful disabling the clocks we are not intending to
* be using at boot time, as subsystems such as the LCD which do
* their own DMA requests to the bus can cause the system to lockup
* if they where in the middle of requesting bus access.
*
* Disabling the LCD clock if the LCD is active is very dangerous,
* and therefore the bootloader should be careful to not enable
* the LCD clock if it is not needed.
*/
/* install (and disable) the clocks we do not need immediately */
clkp = init_clocks_disable;
for (ptr = 0; ptr < ARRAY_SIZE(init_clocks_disable); ptr++, clkp++) {
ret = s
if (ret < 0) {
printk(KERN_ERR "Failed to register clock %s (%d)\n",
clkp->name, ret);
}
s
}
/* show the clock-slow value */
xtal = clk_get(NULL, "xtal");
printk("CLOCK: Slow mode (%ld.%ld MHz), %s, MPLL %s, UPLL %s\n",
print_mhz(clk_get_rate(xtal) /
( 2 * S
(clkslow & S
(clkslow & S
(clkslow & S
return 0;
}
CPU S
S
S
CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on