]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/am33xx/mem.c
merged tx6dl-devel into denx master branch
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / am33xx / mem.c
1 /*
2  * (C) Copyright 2010
3  * Texas Instruments, <www.ti.com>
4  *
5  * Author :
6  *     Mansoor Ahamed <mansoor.ahamed@ti.com>
7  *
8  * Initial Code from:
9  *     Manikandan Pillai <mani.pillai@ti.com>
10  *     Richard Woodruff <r-woodruff2@ti.com>
11  *     Syed Mohammed Khasim <khasim@ti.com>
12  *
13  * SPDX-License-Identifier:     GPL-2.0+
14  */
15
16 #include <common.h>
17 #include <asm/io.h>
18 #include <asm/arch/cpu.h>
19 #include <asm/arch/mem.h>
20 #include <asm/arch/sys_proto.h>
21 #include <command.h>
22
23 #if defined(CONFIG_CMD_NAND)
24 static const u32 gpmc_m_nand[GPMC_MAX_REG] = {
25         M_NAND_GPMC_CONFIG1,
26         M_NAND_GPMC_CONFIG2,
27         M_NAND_GPMC_CONFIG3,
28         M_NAND_GPMC_CONFIG4,
29         M_NAND_GPMC_CONFIG5,
30         M_NAND_GPMC_CONFIG6, 0
31 };
32 #endif
33
34
35 void enable_gpmc_cs_config(const u32 *gpmc_config, struct gpmc_cs *cs, u32 base,
36                         u32 size)
37 {
38         writel(0, &cs->config7);
39         sdelay(1000);
40         /* Delay for settling */
41         writel(gpmc_config[0], &cs->config1);
42         writel(gpmc_config[1], &cs->config2);
43         writel(gpmc_config[2], &cs->config3);
44         writel(gpmc_config[3], &cs->config4);
45         writel(gpmc_config[4], &cs->config5);
46         writel(gpmc_config[5], &cs->config6);
47         /* Enable the config */
48         writel((((size & 0xF) << 8) | ((base >> 24) & 0x3F) |
49                 (1 << 6)), &cs->config7);
50         sdelay(2000);
51 }
52
53 /*****************************************************
54  * gpmc_init(): init gpmc bus
55  * Init GPMC for x16, MuxMode (SDRAM in x32).
56  * This code can only be executed from SRAM or SDRAM.
57  *****************************************************/
58 void gpmc_init(void)
59 {
60         /* putting a blanket check on GPMC based on ZeBu for now */
61         struct gpmc *gpmc_cfg = (struct gpmc *)GPMC_BASE;
62 #ifdef CONFIG_CMD_NAND
63         const u32 *gpmc_config = NULL;
64         u32 base = 0;
65         u32 size = 0;
66 #endif
67         /* global settings */
68         writel(0x00000008, &gpmc_cfg->sysconfig);
69         writel(0x00000100, &gpmc_cfg->irqstatus);
70         writel(0x00000100, &gpmc_cfg->irqenable);
71         writel(0x00000012, &gpmc_cfg->config);
72         /*
73          * Disable the GPMC0 config set by ROM code
74          */
75         writel(0, &gpmc_cfg->cs[0].config7);
76         sdelay(1000);
77
78 #ifdef CONFIG_CMD_NAND
79         gpmc_config = gpmc_m_nand;
80
81         base = PISMO1_NAND_BASE;
82         size = PISMO1_NAND_SIZE;
83         enable_gpmc_cs_config(gpmc_config, &gpmc_cfg->cs[0], base, size);
84 #endif
85 }