1
2
3
4
5
6
7
8
9
10
11
12
13#include <common.h>
14#include <twl4030.h>
15#include <asm/io.h>
16#include <asm/gpio.h>
17#include <asm/arch/mmc_host_def.h>
18#include <asm/arch/mux.h>
19#include <asm/arch/sys_proto.h>
20#include <asm/arch/mem.h>
21#include "tricorder.h"
22#include "tricorder-eeprom.h"
23
24DECLARE_GLOBAL_DATA_PTR;
25
26
27
28
29
30int board_init(void)
31{
32 gpmc_init();
33
34 gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
35
36 return 0;
37}
38
39
40
41
42
43
44
45
46static void get_eeprom(struct tricorder_eeprom *eeprom)
47{
48 int ret;
49
50 if (!eeprom)
51 panic("No eeprom given!\n");
52
53 ret = gpio_request(7, "BMS");
54 if (ret)
55 panic("gpio: requesting BMS pin failed\n");
56
57 ret = gpio_direction_input(7);
58 if (ret)
59 panic("gpio: set BMS as input failed\n");
60
61 ret = gpio_get_value(7);
62 if (ret < 0)
63 panic("gpio: get BMS pin state failed\n");
64
65 gpio_free(7);
66
67 if (ret == 0) {
68
69 ret = tricorder_get_eeprom(0x51, eeprom);
70 if (!ret) {
71 if (strncmp(eeprom->board_name, "CS10411", 7) != 0)
72 panic("Wrong board name '%.*s'\n",
73 sizeof(eeprom->board_name),
74 eeprom->board_name);
75 if (eeprom->board_version[0] < 'D')
76 panic("Wrong board version '%.*s'\n",
77 sizeof(eeprom->board_version),
78 eeprom->board_version);
79 } else {
80 panic("Could not get board revision\n");
81 }
82 } else {
83 memset(eeprom, 0, TRICORDER_EEPROM_SIZE);
84 }
85}
86
87
88
89
90
91
92static void print_hwversion(struct tricorder_eeprom *eeprom)
93{
94 size_t len;
95 if (!eeprom)
96 panic("No eeprom given!");
97
98 printf("Board %.*s:%.*s serial %.*s",
99 sizeof(eeprom->board_name), eeprom->board_name,
100 sizeof(eeprom->board_version), eeprom->board_version,
101 sizeof(eeprom->board_serial), eeprom->board_serial);
102
103 len = strnlen(eeprom->interface_version,
104 sizeof(eeprom->interface_version));
105 if (len > 0)
106 printf(" HW interface version %.*s",
107 sizeof(eeprom->interface_version),
108 eeprom->interface_version);
109 puts("\n");
110}
111
112
113
114
115
116int misc_init_r(void)
117{
118 struct tricorder_eeprom eeprom;
119 get_eeprom(&eeprom);
120 print_hwversion(&eeprom);
121
122 twl4030_power_init();
123 status_led_set(0, CONFIG_LED_STATUS_ON);
124 status_led_set(1, CONFIG_LED_STATUS_ON);
125 status_led_set(2, CONFIG_LED_STATUS_ON);
126
127 omap_die_id_display();
128
129 return 0;
130}
131
132
133
134
135
136
137
138void set_muxconf_regs(void)
139{
140 MUX_TRICORDER();
141}
142
143#if defined(CONFIG_GENERIC_MMC)
144int board_mmc_init(bd_t *bis)
145{
146 return omap_mmc_init(0, 0, 0, -1, -1);
147}
148#endif
149
150#if defined(CONFIG_GENERIC_MMC)
151void board_mmc_power_init(void)
152{
153 twl4030_power_mmc_init(0);
154}
155#endif
156
157
158
159
160
161
162
163
164void get_board_mem_timings(struct board_sdrc_timings *timings)
165{
166 struct tricorder_eeprom eeprom;
167 get_eeprom(&eeprom);
168
169
170 if (eeprom.board_version[0] > 'D') {
171
172 timings->mcfg = MCFG((256 << 20), 14);
173#define MT46H64M32_TDAL 6
174
175#define MT46H64M32_TDPL 3
176#define MT46H64M32_TRRD 2
177#define MT46H64M32_TRCD 3
178#define MT46H64M32_TRP 3
179#define MT46H64M32_TRAS 7
180#define MT46H64M32_TRC 10
181#define MT46H64M32_TRFC 12
182 timings->ctrla = ACTIM_CTRLA(MT46H64M32_TRFC, MT46H64M32_TRC,
183 MT46H64M32_TRAS, MT46H64M32_TRP,
184 MT46H64M32_TRCD, MT46H64M32_TRRD,
185 MT46H64M32_TDPL,
186 MT46H64M32_TDAL);
187
188#define MT46H64M32_TWTR 1
189#define MT46H64M32_TCKE 1
190#define MT46H64M32_XSR 19
191#define MT46H64M32_TXP 1
192 timings->ctrlb = ACTIM_CTRLB(MT46H64M32_TWTR, MT46H64M32_TCKE,
193 MT46H64M32_TXP, MT46H64M32_XSR);
194
195 timings->mr = MICRON_V_MR_165;
196 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
197 } else {
198
199 timings->mcfg = MICRON_V_MCFG_165(128 << 20);
200 timings->ctrla = MICRON_V_ACTIMA_165;
201 timings->ctrlb = MICRON_V_ACTIMB_165;
202 timings->mr = MICRON_V_MR_165;
203 timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz;
204 }
205}
206