mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-26 20:09:02 +09:00
![Tom Rini](/assets/img/avatar_default.png)
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
76 lines
1.9 KiB
C
76 lines
1.9 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* (C) Copyright 2014
|
|
* Heiko Schocher, DENX Software Engineering, hs@denx.de.
|
|
*
|
|
* Based on:
|
|
* (C) Copyright 2007-2008
|
|
* Stelian Pop <stelian@popies.net>
|
|
* Lead Tech Design <www.leadtechdesign.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <asm/io.h>
|
|
#include <asm/arch/at91_common.h>
|
|
#include <asm/arch/at91sam9_sdramc.h>
|
|
#include <asm/arch/gpio.h>
|
|
|
|
int sdramc_initialize(unsigned int sdram_address, const struct sdramc_reg *p)
|
|
{
|
|
struct sdramc_reg *reg = (struct sdramc_reg *)ATMEL_BASE_SDRAMC;
|
|
unsigned int i;
|
|
|
|
/* SDRAM feature must be in the configuration register */
|
|
writel(p->cr, ®->cr);
|
|
|
|
/* The SDRAM memory type must be set in the Memory Device Register */
|
|
writel(p->mdr, ®->mdr);
|
|
|
|
/*
|
|
* The minimum pause of 200 us is provided to precede any single
|
|
* toggle
|
|
*/
|
|
for (i = 0; i < 1000; i++)
|
|
;
|
|
|
|
/* A NOP command is issued to the SDRAM devices */
|
|
writel(AT91_SDRAMC_MODE_NOP, ®->mr);
|
|
writel(0x00000000, sdram_address);
|
|
|
|
/* An All Banks Precharge command is issued to the SDRAM devices */
|
|
writel(AT91_SDRAMC_MODE_PRECHARGE, ®->mr);
|
|
writel(0x00000000, sdram_address);
|
|
|
|
for (i = 0; i < 10000; i++)
|
|
;
|
|
|
|
/* Eight auto-refresh cycles are provided */
|
|
for (i = 0; i < 8; i++) {
|
|
writel(AT91_SDRAMC_MODE_REFRESH, ®->mr);
|
|
writel(0x00000001 + i, sdram_address + 4 + 4 * i);
|
|
}
|
|
|
|
/*
|
|
* A Mode Register set (MRS) cyscle is issued to program the
|
|
* SDRAM parameters(TCSR, PASR, DS)
|
|
*/
|
|
writel(AT91_SDRAMC_MODE_LMR, ®->mr);
|
|
writel(0xcafedede, sdram_address + 0x24);
|
|
|
|
/*
|
|
* The application must go into Normal Mode, setting Mode
|
|
* to 0 in the Mode Register and perform a write access at
|
|
* any location in the SDRAM.
|
|
*/
|
|
writel(AT91_SDRAMC_MODE_NORMAL, ®->mr);
|
|
writel(0x00000000, sdram_address); /* Perform Normal mode */
|
|
|
|
/*
|
|
* Write the refresh rate into the count field in the SDRAMC
|
|
* Refresh Timer Rgister.
|
|
*/
|
|
writel(p->tr, ®->tr);
|
|
|
|
return 0;
|
|
}
|