head.S 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/*
 * File:         arch/blackfin/mach-bf548/head.S
 * Based on:     arch/blackfin/mach-bf537/head.S
 * Author:       Jeff Dionne <jeff@uclinux.org> COPYRIGHT 1998 D. Jeff Dionne
 *
 * Created:      1998
 * Description:  Startup code for Blackfin BF548
 *
 * Modified:
 *               Copyright 2004-2007 Analog Devices Inc.
 *
 * Bugs:         Enter bugs at http://blackfin.uclinux.org/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see the file COPYING, or write
 * to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <linux/linkage.h>
31
#include <linux/init.h>
32
#include <asm/blackfin.h>
33
#ifdef CONFIG_BFIN_KERNEL_CLOCK
34 35
#include <asm/clocks.h>
#include <mach/mem_init.h>
36 37 38
#endif

.section .l1.text
39
#ifdef CONFIG_BFIN_KERNEL_CLOCK
40 41 42 43 44 45 46 47 48 49
ENTRY(_start_dma_code)

	/* Enable PHY CLK buffer output */
	p0.h = hi(VR_CTL);
	p0.l = lo(VR_CTL);
	r0.l = w[p0];
	bitset(r0, 14);
	w[p0] = r0.l;
	ssync;

50 51
	p0.h = hi(SIC_IWR0);
	p0.l = lo(SIC_IWR0);
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
	r0.l = 0x1;
	r0.h = 0x0;
	[p0] = r0;
	SSYNC;

	/*
	 *  Set PLL_CTL
	 *   - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
	 *   - [8]     = BYPASS    : BYPASS the PLL, run CLKIN into CCLK/SCLK
	 *   - [7]     = output delay (add 200ps of delay to mem signals)
	 *   - [6]     = input delay (add 200ps of input delay to mem signals)
	 *   - [5]     = PDWN      : 1=All Clocks off
	 *   - [3]     = STOPCK    : 1=Core Clock off
	 *   - [1]     = PLL_OFF   : 1=Disable Power to PLL
	 *   - [0]     = DF        : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
	 *   all other bits set to zero
	 */

	p0.h = hi(PLL_LOCKCNT);
	p0.l = lo(PLL_LOCKCNT);
	r0 = 0x300(Z);
	w[p0] = r0.l;
	ssync;

76
	/* enable self refresh via SRREQ */
77 78 79 80
	P2.H = hi(EBIU_RSTCTL);
	P2.L = lo(EBIU_RSTCTL);
	R0 = [P2];
	BITSET (R0, 3);
81 82
	[P2] = R0;
	SSYNC;
83 84

	/* wait for SRACK bit to be set */
85 86 87 88
.LSRR_MODE:
	R0 = [P2];
	CC = BITTST(R0, 4);
	if !CC JUMP .LSRR_MODE;
89 90 91 92 93 94 95 96

	r0 = CONFIG_VCO_MULT & 63;       /* Load the VCO multiplier         */
	r0 = r0 << 9;                    /* Shift it over,                  */
	r1 = CLKIN_HALF;                 /* Do we need to divide CLKIN by 2?*/
	r0 = r1 | r0;
	r1 = PLL_BYPASS;                 /* Bypass the PLL?                 */
	r1 = r1 << 8;                    /* Shift it over                   */
	r0 = r1 | r0;                    /* add them all together           */
97
#ifdef ANOMALY_05000265
98
	BITSET(r0, 15);                  /* Add 250 mV of hysteresis to SPORT input pins */
99
#endif
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

	p0.h = hi(PLL_CTL);
	p0.l = lo(PLL_CTL);              /* Load the address                */
	cli r2;                          /* Disable interrupts              */
	ssync;
	w[p0] = r0.l;                    /* Set the value                   */
	idle;                            /* Wait for the PLL to stablize    */
	sti r2;                          /* Enable interrupts               */

.Lcheck_again:
	p0.h = hi(PLL_STAT);
	p0.l = lo(PLL_STAT);
	R0 = W[P0](Z);
	CC = BITTST(R0,5);
	if ! CC jump .Lcheck_again;

	/* Configure SCLK & CCLK Dividers */
	r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
	p0.h = hi(PLL_DIV);
	p0.l = lo(PLL_DIV);
	w[p0] = r0.l;
	ssync;

123
	/* disable self refresh by clearing SRREQ */
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
	P2.H = hi(EBIU_RSTCTL);
	P2.L = lo(EBIU_RSTCTL);
	R0 = [P2];
	CC = BITTST(R0, 0);
	if CC jump .Lskipddrrst;
	BITSET (R0, 0);
.Lskipddrrst:
	BITCLR (R0, 3);
	[P2] = R0;
	SSYNC;

	p0.l = lo(EBIU_DDRCTL0);
	p0.h = hi(EBIU_DDRCTL0);
	r0.l = lo(mem_DDRCTL0);
	r0.h = hi(mem_DDRCTL0);
	[p0] = r0;
	ssync;

	p0.l = lo(EBIU_DDRCTL1);
	p0.h = hi(EBIU_DDRCTL1);
	r0.l = lo(mem_DDRCTL1);
	r0.h = hi(mem_DDRCTL1);
	[p0] = r0;
	ssync;

	p0.l = lo(EBIU_DDRCTL2);
	p0.h = hi(EBIU_DDRCTL2);
	r0.l = lo(mem_DDRCTL2);
	r0.h = hi(mem_DDRCTL2);
	[p0] = r0;
	ssync;
155 156

	RTS;
157
ENDPROC(_start_dma_code)
158
#endif /* CONFIG_BFIN_KERNEL_CLOCK */