Blame view

board/freescale/m5275evb/m5275evb.c 3.34 KB
545c8e0a7   Matthew Fettke   ColdFire: Added M...
1
2
3
4
5
6
  /*
   * (C) Copyright 2000-2003
   * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
   *
   * Copyright (C) 2005-2008 Arthur Shipkowski (art@videon-central.com)
   *
32dbaafa5   Alison Wang   ColdFire: Clean u...
7
8
   * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved.
   *
545c8e0a7   Matthew Fettke   ColdFire: Added M...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
   * See file CREDITS for list of people who contributed to this
   * project.
   *
   * 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, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
   * MA 02111-1307 USA
   */
  
  #include <common.h>
  #include <asm/immap.h>
32dbaafa5   Alison Wang   ColdFire: Clean u...
30
  #include <asm/io.h>
545c8e0a7   Matthew Fettke   ColdFire: Added M...
31
32
33
34
35
36
37
38
39
40
41
  
  #define PERIOD		13	/* system bus period in ns */
  #define SDRAM_TREFI	7800	/* in ns */
  
  int checkboard(void)
  {
  	puts("Board: ");
  	puts("Freescale MCF5275 EVB
  ");
  	return 0;
  };
9973e3c61   Becky Bruce   Change initdram()...
42
  phys_size_t initdram(int board_type)
545c8e0a7   Matthew Fettke   ColdFire: Added M...
43
  {
32dbaafa5   Alison Wang   ColdFire: Clean u...
44
45
  	sdramctrl_t *sdp = (sdramctrl_t *)(MMAP_SDRAM);
  	gpio_t *gpio_reg = (gpio_t *)(MMAP_GPIO);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
46

32dbaafa5   Alison Wang   ColdFire: Clean u...
47
48
  	/* Enable SDRAM */
  	out_be16(&gpio_reg->par_sdram, 0x3FF);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
49
50
  
  	/* Set up chip select */
32dbaafa5   Alison Wang   ColdFire: Clean u...
51
52
  	out_be32(&sdp->sdbar0, CONFIG_SYS_SDRAM_BASE);
  	out_be32(&sdp->sdbmr0, MCF_SDRAMC_SDMRn_BAM_32M | MCF_SDRAMC_SDMRn_V);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
53
54
  
  	/* Set up timing */
32dbaafa5   Alison Wang   ColdFire: Clean u...
55
56
  	out_be32(&sdp->sdcfg1, 0x83711630);
  	out_be32(&sdp->sdcfg2, 0x46770000);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
57
58
  
  	/* Enable clock */
32dbaafa5   Alison Wang   ColdFire: Clean u...
59
  	out_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN | MCF_SDRAMC_SDCR_CKE);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
60
61
  
  	/* Set precharge */
32dbaafa5   Alison Wang   ColdFire: Clean u...
62
  	setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
63
64
  
  	/* Dummy write to start SDRAM */
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
65
  	*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
545c8e0a7   Matthew Fettke   ColdFire: Added M...
66
67
  
  	/* Send LEMR */
32dbaafa5   Alison Wang   ColdFire: Clean u...
68
69
70
  	setbits_be32(&sdp->sdmr,
  		MCF_SDRAMC_SDMR_BNKAD_LEMR | MCF_SDRAMC_SDMR_AD(0x0) |
  		MCF_SDRAMC_SDMR_CMD);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
71
  	*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
545c8e0a7   Matthew Fettke   ColdFire: Added M...
72
73
  
  	/* Send LMR */
32dbaafa5   Alison Wang   ColdFire: Clean u...
74
  	out_be32(&sdp->sdmr, 0x058d0000);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
75
  	*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
545c8e0a7   Matthew Fettke   ColdFire: Added M...
76
77
  
  	/* Stop sending commands */
32dbaafa5   Alison Wang   ColdFire: Clean u...
78
  	clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
79
80
  
  	/* Set precharge */
32dbaafa5   Alison Wang   ColdFire: Clean u...
81
  	setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
82
  	*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
545c8e0a7   Matthew Fettke   ColdFire: Added M...
83
84
  
  	/* Stop manual precharge, send 2 IREF */
32dbaafa5   Alison Wang   ColdFire: Clean u...
85
86
  	clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IPALL);
  	setbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_IREF);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
87
88
  	*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
  	*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
545c8e0a7   Matthew Fettke   ColdFire: Added M...
89

32dbaafa5   Alison Wang   ColdFire: Clean u...
90
91
  
  	out_be32(&sdp->sdmr, 0x018d0000);
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
92
  	*((volatile unsigned long *)CONFIG_SYS_SDRAM_BASE) = 0xa5a59696;
545c8e0a7   Matthew Fettke   ColdFire: Added M...
93
94
  
  	/* Stop sending commands */
32dbaafa5   Alison Wang   ColdFire: Clean u...
95
96
  	clrbits_be32(&sdp->sdmr, MCF_SDRAMC_SDMR_CMD);
  	clrbits_be32(&sdp->sdcr, MCF_SDRAMC_SDCR_MODE_EN);
545c8e0a7   Matthew Fettke   ColdFire: Added M...
97
98
  
  	/* Turn on auto refresh, lock SDMR */
32dbaafa5   Alison Wang   ColdFire: Clean u...
99
  	out_be32(&sdp->sdcr,
545c8e0a7   Matthew Fettke   ColdFire: Added M...
100
101
102
103
104
  		MCF_SDRAMC_SDCR_CKE
  		| MCF_SDRAMC_SDCR_REF
  		| MCF_SDRAMC_SDCR_MUX(1)
  		/* 1 added to round up */
  		| MCF_SDRAMC_SDCR_RCNT((SDRAM_TREFI/(PERIOD*64)) - 1 + 1)
32dbaafa5   Alison Wang   ColdFire: Clean u...
105
  		| MCF_SDRAMC_SDCR_DQS_OE(0x3));
545c8e0a7   Matthew Fettke   ColdFire: Added M...
106

6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
107
  	return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
545c8e0a7   Matthew Fettke   ColdFire: Added M...
108
109
110
111
112
113
114
115
116
117
  };
  
  int testdram(void)
  {
  	/* TODO: XXX XXX XXX */
  	printf("DRAM test not implemented!
  ");
  
  	return (0);
  }