Path: blob/master/arch/blackfin/mach-common/clocks-init.c
10817 views
/*1* arch/blackfin/mach-common/clocks-init.c - reprogram clocks / memory2*3* Copyright 2004-2008 Analog Devices Inc.4*5* Licensed under the GPL-2 or later.6*/78#include <linux/linkage.h>9#include <linux/init.h>10#include <asm/blackfin.h>1112#include <asm/dma.h>13#include <asm/clocks.h>14#include <asm/mem_init.h>15#include <asm/dpmc.h>1617#define SDGCTL_WIDTH (1 << 31) /* SDRAM external data path width */18#define PLL_CTL_VAL \19(((CONFIG_VCO_MULT & 63) << 9) | CLKIN_HALF | \20(PLL_BYPASS << 8) | (ANOMALY_05000305 ? 0 : 0x8000))2122__attribute__((l1_text))23static void do_sync(void)24{25__builtin_bfin_ssync();26}2728__attribute__((l1_text))29void init_clocks(void)30{31/* Kill any active DMAs as they may trigger external memory accesses32* in the middle of reprogramming things, and that'll screw us up.33* For example, any automatic DMAs left by U-Boot for splash screens.34*/35size_t i;36for (i = 0; i < MAX_DMA_CHANNELS; ++i) {37struct dma_register *dma = dma_io_base_addr[i];38dma->cfg = 0;39}4041do_sync();4243#ifdef SIC_IWR044bfin_write_SIC_IWR0(IWR_ENABLE(0));45# ifdef SIC_IWR146/* BF52x system reset does not properly reset SIC_IWR1 which47* will screw up the bootrom as it relies on MDMA0/1 waking it48* up from IDLE instructions. See this report for more info:49* http://blackfin.uclinux.org/gf/tracker/432350*/51if (ANOMALY_05000435)52bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11));53else54bfin_write_SIC_IWR1(IWR_DISABLE_ALL);55# endif56# ifdef SIC_IWR257bfin_write_SIC_IWR2(IWR_DISABLE_ALL);58# endif59#else60bfin_write_SIC_IWR(IWR_ENABLE(0));61#endif62do_sync();63#ifdef EBIU_SDGCTL64bfin_write_EBIU_SDGCTL(bfin_read_EBIU_SDGCTL() | SRFS);65do_sync();66#endif6768#ifdef CLKBUFOE69bfin_write16(VR_CTL, bfin_read_VR_CTL() | CLKBUFOE);70do_sync();71__asm__ __volatile__("IDLE;");72#endif73bfin_write_PLL_LOCKCNT(0x300);74do_sync();75/* We always write PLL_CTL thus avoiding Anomaly 05000242 */76bfin_write16(PLL_CTL, PLL_CTL_VAL);77__asm__ __volatile__("IDLE;");78bfin_write_PLL_DIV(CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);79#ifdef EBIU_SDGCTL80bfin_write_EBIU_SDRRC(mem_SDRRC);81bfin_write_EBIU_SDGCTL((bfin_read_EBIU_SDGCTL() & SDGCTL_WIDTH) | mem_SDGCTL);82#else83bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() & ~(SRREQ));84do_sync();85bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() | 0x1);86bfin_write_EBIU_DDRCTL0(mem_DDRCTL0);87bfin_write_EBIU_DDRCTL1(mem_DDRCTL1);88bfin_write_EBIU_DDRCTL2(mem_DDRCTL2);89#ifdef CONFIG_MEM_EBIU_DDRQUE90bfin_write_EBIU_DDRQUE(CONFIG_MEM_EBIU_DDRQUE);91#endif92#endif93do_sync();94bfin_read16(0);95}969798