summaryrefslogtreecommitdiff
path: root/board/st/u8500/u8500.c
blob: 0cca76cf36e857c5ea90318c23bcae6aee14e795 (plain)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
* (C) Copyright 2009
* STEricsson, <www.stericsson.com>
*
* 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 <config.h>
#include <asm/types.h>
#include <asm/io.h>
#include <asm/errno.h>

#include "common.h"

void init_regs(void);
#if 0
void *memcopy(void *dest, const void *src, size_t count)
{
    u16 *tmp = (u16 *) dest, *s = (u16 *) src;

    count = count / 2;
    while (count--)
        *tmp++ = *s++;

    return dest;
}
#endif
#if defined(CONFIG_SHOW_BOOT_PROGRESS)
void show_boot_progress(int progress)
{
    printf("Boot reached stage %d\n", progress);
}
#endif

static inline void delay(unsigned long loops)
{
    __asm__ volatile ("1:\n"
              "subs %0, %1, #1\n" "bne 1b":"=r" (loops):"0"(loops));
}

/*
* Miscellaneous platform dependent initialisations
*/

int board_init(void)
{    
    DECLARE_GLOBAL_DATA_PTR;
    gd->bd->bi_arch_number = 0x1A4;
    gd->bd->bi_boot_params = 0x00000100;
    //enable the timers in PRCMU reg
    *((volatile unsigned int *)(CFG_PRCMU_BASE + 0x1C8)) = 0x20000;
    icache_enable();
    gpio_init();

    init_regs();
    return 0;
}

#ifdef CONFIG_MISC_INIT_R
int misc_init_r(void)
{
    setenv("verify", "n");
    return (0);
}
#endif

/******************************
Routine:
Description:
******************************/
int dram_init(void)
{
    DECLARE_GLOBAL_DATA_PTR;
    gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
    gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE_1;
    gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
    gd->bd->bi_dram[1].size = PHYS_SDRAM_SIZE_2;

    return 0;
}

#define ARRAY_SIZE(x)		(sizeof(x) / sizeof((x)[0]))
unsigned int addr_vall_arr[] = {
0x8011F000, 0x0000FFFF, // Clocks for HSI  TODO Enable reqd only
0x8011F008, 0x00001C44, // Clocks for HSI  TODO Enable reqd only
0x8000F000, 0x00007FFF, // Clocks for I2C  TODO Enable reqd only
0x8000F008, 0x00007FFF, // Clocks for I2C  TODO Enable reqd only
0x8000E120, 0x003C0000, // GPIO for I2C/SD
0x8000E124, 0x00000000, // GPIO for I2C/SD
0x8012F000, 0x00007FFF, // Clocks for SD  TODO Enable reqd only
0x8012F008, 0x00007FFF, // Clocks for SD  TODO Enable reqd only
0xA03DF000, 0x0000000D, // Clock for MTU Timers
0x8011E00C, 0x00000000, // GPIO ALT FUNC for EMMC
0x8011E004, 0x0000FFE0, // GPIO ALT FUNC for EMMC
0x8011E020, 0x0000FFE0, // GPIO ALT FUNC for EMMC
0x8011E024, 0x00000000, // GPIO ALT FUNC for EMMC
0x8012E00C, 0x00000000, // GPIO ALT FUNC for SD
0x8012E004, 0x0FFC0000, // GPIO ALT FUNC for SD
0x8012E020, 0x60000000, // GPIO ALT FUNC for SD
0x8012E024, 0x60000000, // GPIO ALT FUNC for SD
0x801571E4, 0x0000000C, // PRCMU settings for B2R2
0x80157024, 0x00000130, // PRCMU settings for EMMC/SD
0xA03FF000, 0x00000003, // USB
0xA03FF008, 0x00000001, // USB
0xA03FE00C, 0x00000000, // USB
0xA03FE020, 0x00000FFF, // USB
0xA03FE024, 0x00000000  // USB
};
#ifdef BOARD_LATE_INIT
int board_late_init(void)
{
	return (0);
}
#endif
void init_regs(void)
{    
    int i;
    for(i = 0; i < ARRAY_SIZE(addr_vall_arr)/2; i++)
    {
        
        *((volatile unsigned int *)(addr_vall_arr[2 * i]))
                                = addr_vall_arr[(2 * i) + 1];
    }    
}