blob: 94171d538c11a46aed28c6e1c00ada223a82b6ba [file] [log] [blame]
Shashank Mittal246f8d02011-01-21 17:12:27 -08001/*
2 * Copyright (c) 2009, Google Inc.
3 * All rights reserved.
Channagoud Kadabi3acfb742011-11-15 18:19:32 +05304 * Copyright (c) 2009-2012, Code Aurora Forum. All rights reserved.
Shashank Mittal246f8d02011-01-21 17:12:27 -08005 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google, Inc. nor the names of its contributors
16 * may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
29 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
Amol Jadi2dfe3392011-07-19 16:03:37 -070033#include <reg.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080034#include <debug.h>
35#include <dev/keys.h>
Kinson Chikea646242011-09-01 13:53:16 -070036#include <dev/ssbi.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080037#include <lib/ptable.h>
38#include <dev/flash.h>
39#include <smem.h>
Greg Griscod6250552011-06-29 14:40:23 -070040#include <mmc.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080041#include <platform/iomap.h>
Channagoud Kadabi539ef722012-03-29 16:02:50 +053042#include <target/board.h>
Greg Griscod6250552011-06-29 14:40:23 -070043#include <platform.h>
Deepa Dinamani5e5c21a2012-02-16 18:59:57 -080044#include <crypto_hash.h>
Shashank Mittal246f8d02011-01-21 17:12:27 -080045
Shashank Mittal246f8d02011-01-21 17:12:27 -080046#define VARIABLE_LENGTH 0x10101010
47#define DIFF_START_ADDR 0xF0F0F0F0
48#define NUM_PAGES_PER_BLOCK 0x40
Channagoud Kadabi16da3a22011-10-24 20:25:07 +053049#define RECOVERY_MODE 0x77665502
50#define FOTA_COOKIE 0x64645343
51
52unsigned int fota_cookie[1];
Shashank Mittal246f8d02011-01-21 17:12:27 -080053
54static struct ptable flash_ptable;
Shashank Mittalcb25d252011-04-05 12:13:30 -070055unsigned hw_platform = 0;
56unsigned target_msm_id = 0;
Shashank Mittal246f8d02011-01-21 17:12:27 -080057
Deepa Dinamani5e5c21a2012-02-16 18:59:57 -080058/* Setting this variable to different values defines the
59 * behavior of CE engine:
60 * platform_ce_type = CRYPTO_ENGINE_TYPE_NONE : No CE engine
61 * platform_ce_type = CRYPTO_ENGINE_TYPE_SW : Software CE engine
62 * platform_ce_type = CRYPTO_ENGINE_TYPE_HW : Hardware CE engine
63 * Behavior is determined in the target code.
64 */
65static crypto_engine_type platform_ce_type = CRYPTO_ENGINE_TYPE_SW;
66
Channagoud Kadabi3acfb742011-11-15 18:19:32 +053067int machine_is_evb();
Channagoud Kadabid53664b2011-12-28 16:39:15 +053068
Shashank Mittal246f8d02011-01-21 17:12:27 -080069/* for these partitions, start will be offset by either what we get from
70 * smem, or from the above offset if smem is not useful. Also, we should
71 * probably have smem_ptable code populate our flash_ptable.
72 *
73 * When smem provides us with a full partition table, we can get rid of
74 * this altogether.
75 *
76 */
Channagoud Kadabie57173d2011-12-19 15:42:44 +053077static struct ptentry board_part_list[] = {
Shashank Mittal246f8d02011-01-21 17:12:27 -080078 {
Ajay Dudanib01e5062011-12-03 23:23:42 -080079 .start = 0,
80 .length = 10 /* In MB */ ,
81 .name = "boot",
82 },
Shashank Mittal246f8d02011-01-21 17:12:27 -080083 {
Ajay Dudanib01e5062011-12-03 23:23:42 -080084 .start = DIFF_START_ADDR,
Channagoud Kadabi71961882012-02-09 16:32:41 +053085 .length = 253 /* In MB */ ,
Ajay Dudanib01e5062011-12-03 23:23:42 -080086 .name = "system",
87 },
Shashank Mittal246f8d02011-01-21 17:12:27 -080088 {
Ajay Dudanib01e5062011-12-03 23:23:42 -080089 .start = DIFF_START_ADDR,
90 .length = 40 /* In MB */ ,
91 .name = "cache",
92 },
Shashank Mittal246f8d02011-01-21 17:12:27 -080093 {
Ajay Dudanib01e5062011-12-03 23:23:42 -080094 .start = DIFF_START_ADDR,
95 .length = 4 /* In MB */ ,
96 .name = "misc",
97 },
Shashank Mittal246f8d02011-01-21 17:12:27 -080098 {
Ajay Dudanib01e5062011-12-03 23:23:42 -080099 .start = DIFF_START_ADDR,
100 .length = VARIABLE_LENGTH,
101 .name = "userdata",
102 },
Shashank Mittal246f8d02011-01-21 17:12:27 -0800103 {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800104 .start = DIFF_START_ADDR,
105 .length = 4 /* In MB */ ,
106 .name = "persist",
107 },
Shashank Mittal246f8d02011-01-21 17:12:27 -0800108 {
Ajay Dudanib01e5062011-12-03 23:23:42 -0800109 .start = DIFF_START_ADDR,
110 .length = 10 /* In MB */ ,
111 .name = "recovery",
112 },
Shashank Mittal246f8d02011-01-21 17:12:27 -0800113};
Ajay Dudanib01e5062011-12-03 23:23:42 -0800114
Channagoud Kadabie57173d2011-12-19 15:42:44 +0530115static int num_parts = sizeof(board_part_list) / sizeof(struct ptentry);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800116
Shashank Mittal246f8d02011-01-21 17:12:27 -0800117void smem_ptable_init(void);
118unsigned smem_get_apps_flash_start(void);
119
120void keypad_init(void);
121
122int target_is_emmc_boot(void);
123
124void target_init(void)
125{
126 unsigned offset;
127 struct flash_info *flash_info;
128 unsigned total_num_of_blocks;
129 unsigned next_ptr_start_adr = 0;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800130 unsigned blocks_per_1MB = 8; /* Default value of 2k page size on 256MB flash drive */
Shashank Mittal246f8d02011-01-21 17:12:27 -0800131 int i;
132
133 dprintf(INFO, "target_init()\n");
134
Shashank Mittal246f8d02011-01-21 17:12:27 -0800135#if (!ENABLE_NANDWRITE)
136 keys_init();
137 keypad_init();
138#endif
Shashank Mittal246f8d02011-01-21 17:12:27 -0800139
Kinson Chikce306ff2011-07-08 15:23:33 -0700140 /* Display splash screen if enabled */
141#if DISPLAY_SPLASH_SCREEN
Channagoud Kadabi539ef722012-03-29 16:02:50 +0530142 display_init();
143 dprintf(SPEW, "Diplay initialized\n");
Kinson Chikce306ff2011-07-08 15:23:33 -0700144#endif
145
Ajay Dudanib01e5062011-12-03 23:23:42 -0800146 if (target_is_emmc_boot()) {
Amol Jadi2dfe3392011-07-19 16:03:37 -0700147 /* Must wait for modem-up before we can intialize MMC.
148 */
Ajay Dudanib01e5062011-12-03 23:23:42 -0800149 while (readl(MSM_SHARED_BASE + 0x14) != 1) ;
Amol Jadi2dfe3392011-07-19 16:03:37 -0700150
Ajay Dudanib01e5062011-12-03 23:23:42 -0800151 if (mmc_boot_main(MMC_SLOT, MSM_SDC3_BASE)) {
Shashank Mittal246f8d02011-01-21 17:12:27 -0800152 dprintf(CRITICAL, "mmc init failed!");
153 ASSERT(0);
154 }
155 return;
156 }
157
158 ptable_init(&flash_ptable);
159 smem_ptable_init();
160
161 flash_init();
162 flash_info = flash_get_info();
163 ASSERT(flash_info);
164
165 offset = smem_get_apps_flash_start();
166 if (offset == 0xffffffff)
Ajay Dudanib01e5062011-12-03 23:23:42 -0800167 while (1) ;
Shashank Mittal246f8d02011-01-21 17:12:27 -0800168
169 total_num_of_blocks = flash_info->num_blocks;
170 blocks_per_1MB = (1 << 20) / (flash_info->block_size);
171
172 for (i = 0; i < num_parts; i++) {
173 struct ptentry *ptn = &board_part_list[i];
174 unsigned len = ((ptn->length) * blocks_per_1MB);
175
Ajay Dudanib01e5062011-12-03 23:23:42 -0800176 if (ptn->start != 0)
177 ASSERT(ptn->start == DIFF_START_ADDR);
Shashank Mittal246f8d02011-01-21 17:12:27 -0800178
179 ptn->start = next_ptr_start_adr;
180
Ajay Dudanib01e5062011-12-03 23:23:42 -0800181 if (ptn->length == VARIABLE_LENGTH) {
Shashank Mittal246f8d02011-01-21 17:12:27 -0800182 unsigned length_for_prt = 0;
183 unsigned j;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800184 for (j = i + 1; j < num_parts; j++) {
185 struct ptentry *temp_ptn = &board_part_list[j];
186 ASSERT(temp_ptn->length != VARIABLE_LENGTH);
187 length_for_prt +=
188 ((temp_ptn->length) * blocks_per_1MB);
Shashank Mittal246f8d02011-01-21 17:12:27 -0800189 }
Ajay Dudanib01e5062011-12-03 23:23:42 -0800190 len =
191 (total_num_of_blocks - 1) - (offset + ptn->start +
192 length_for_prt);
Shashank Mittal246f8d02011-01-21 17:12:27 -0800193 ASSERT(len >= 0);
194 }
195 next_ptr_start_adr = ptn->start + len;
196 ptable_add(&flash_ptable, ptn->name, offset + ptn->start,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800197 len, ptn->flags, TYPE_APPS_PARTITION,
198 PERM_WRITEABLE);
Shashank Mittal246f8d02011-01-21 17:12:27 -0800199 }
200
201 smem_add_modem_partitions(&flash_ptable);
202
203 ptable_dump(&flash_ptable);
204 flash_set_ptable(&flash_ptable);
205}
206
Shashank Mittalcb25d252011-04-05 12:13:30 -0700207void board_info(void)
208{
209 struct smem_board_info_v4 board_info_v4;
210 unsigned int board_info_len = 0;
211 unsigned smem_status;
212 unsigned format = 0;
213 unsigned id = 0;
214
215 if (hw_platform && target_msm_id)
216 return;
217
218 hw_platform = MSM7X27A_SURF;
219 target_msm_id = MSM7225A;
220
221 smem_status = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800222 &format, sizeof(format), 0);
223 if (!smem_status) {
224 if (format == 4) {
Shashank Mittalcb25d252011-04-05 12:13:30 -0700225 board_info_len = sizeof(board_info_v4);
Ajay Dudanib01e5062011-12-03 23:23:42 -0800226 smem_status =
227 smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
228 &board_info_v4,
229 board_info_len);
230 if (!smem_status) {
Shashank Mittalcb25d252011-04-05 12:13:30 -0700231 id = board_info_v4.board_info_v3.hw_platform;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800232 target_msm_id =
233 board_info_v4.board_info_v3.msm_id;
Shashank Mittalcb25d252011-04-05 12:13:30 -0700234 }
235 }
236
Channagoud Kadabi4c41c412011-09-08 15:38:30 +0530237 /* Detect SURF v/s FFA v/s QRD */
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530238 if (target_msm_id >= MSM8225 && target_msm_id <= MSM8625) {
239 switch (id) {
240 case 0x1:
241 hw_platform = MSM8X25_SURF;
242 break;
Aparna Mallavarapu1bb33672012-04-20 16:07:24 +0530243 case 0x2:
244 hw_platform = MSM8X25_FFA;
245 break;
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530246 case 0xC:
247 hw_platform = MSM8X25_EVB;
248 break;
Aparna Mallavarapuac332982012-03-18 14:02:38 +0530249 case 0xF:
250 hw_platform = MSM8X25_QRD7;
251 break;
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530252 default:
253 hw_platform = MSM8X25_SURF;
254 }
255 } else {
256 switch (id) {
257 case 0x1:
258 /* Set the machine type based on msm ID */
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530259 if (msm_is_7x25a(target_msm_id))
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530260 hw_platform = MSM7X25A_SURF;
Channagoud Kadabi849ad5e2012-04-02 23:21:21 +0530261 else
262 hw_platform = MSM7X27A_SURF;
263 break;
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530264 case 0x2:
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530265 if (msm_is_7x25a(target_msm_id))
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530266 hw_platform = MSM7X25A_FFA;
Channagoud Kadabi849ad5e2012-04-02 23:21:21 +0530267 else
268 hw_platform = MSM7X27A_FFA;
269 break;
270 case 0xB:
271 if(target_is_emmc_boot())
272 hw_platform = MSM7X27A_QRD1;
273 else
274 hw_platform = MSM7X27A_QRD3;
275 break;
276 case 0xC:
277 hw_platform = MSM7X27A_EVB;
278 break;
279 case 0xF:
Channagoud Kadabib33d4832012-02-06 17:10:56 +0530280 hw_platform = MSM7X27A_QRD3;
Channagoud Kadabi849ad5e2012-04-02 23:21:21 +0530281 break;
282 default:
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530283 if (msm_is_7x25a(target_msm_id))
Channagoud Kadabi849ad5e2012-04-02 23:21:21 +0530284 hw_platform = MSM7X25A_SURF;
285 else
286 hw_platform = MSM7X27A_SURF;
287 };
288 }
Ajay Dudanib01e5062011-12-03 23:23:42 -0800289 /* Set msm ID for target variants based on values read from smem */
290 switch (target_msm_id) {
291 case MSM7225A:
292 case MSM7625A:
293 case ESM7225A:
294 case MSM7225AA:
295 case MSM7625AA:
296 case ESM7225AA:
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530297 case MSM7225AB:
298 case MSM7625AB:
299 case ESM7225AB:
Ajay Dudanib01e5062011-12-03 23:23:42 -0800300 target_msm_id = MSM7625A;
301 break;
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530302 case MSM8225:
303 case MSM8625:
304 target_msm_id = MSM8625;
305 break;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800306 default:
307 target_msm_id = MSM7627A;
Shashank Mittalcb25d252011-04-05 12:13:30 -0700308 }
309 }
310 return;
311}
312
Shashank Mittal246f8d02011-01-21 17:12:27 -0800313unsigned board_machtype(void)
314{
Shashank Mittalcb25d252011-04-05 12:13:30 -0700315 board_info();
316 return hw_platform;
317}
318
319unsigned board_msm_id(void)
320{
321 board_info();
322 return target_msm_id;
Shashank Mittal246f8d02011-01-21 17:12:27 -0800323}
324
Deepa Dinamani5e5c21a2012-02-16 18:59:57 -0800325crypto_engine_type board_ce_type(void)
326{
327 return platform_ce_type;
328}
329
Shashank Mittal246f8d02011-01-21 17:12:27 -0800330void reboot_device(unsigned reboot_reason)
331{
332 reboot(reboot_reason);
333}
334
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530335static int read_from_flash(struct ptentry* ptn, int offset, int size, void *dest)
336{
337 void *buffer = NULL;
338 unsigned page_size = flash_page_size();
339 unsigned page_mask = page_size - 1;
340 int read_size = (size + page_mask) & (~page_mask);
341
342 buffer = malloc(read_size);
343 if(!buffer){
344 dprintf(CRITICAL, "ERROR : Malloc failed for read_from_flash \n");
345 return -1;
346 }
347
348 if(flash_read(ptn, offset, buffer, read_size)){
349 dprintf(CRITICAL, "ERROR : Flash read failed \n");
350 return -1;
351 }
352 memcpy(dest, buffer, size);
353 free(buffer);
354 return 0;
355}
356
357static unsigned int get_fota_cookie_mtd(void)
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530358{
359 struct ptentry *ptn;
360 struct ptable *ptable;
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530361 unsigned int cookie = 0;
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530362
363 ptable = flash_get_ptable();
364 if (ptable == NULL) {
365 dprintf(CRITICAL, "ERROR: Partition table not found\n");
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530366 return 0;
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530367 }
368
369 ptn = ptable_find(ptable, "FOTA");
370 if (ptn == NULL) {
371 dprintf(CRITICAL, "ERROR: No FOTA partition found\n");
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530372 return 0;
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530373 }
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530374
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530375 if (read_from_flash(ptn, 0, sizeof(unsigned int), &cookie) == -1) {
376 dprintf(CRITICAL, "ERROR: failed to read fota cookie from flash\n");
377 return 0;
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530378 }
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530379 return cookie;
380}
381
382static int read_from_mmc(struct ptentry* ptn, int size, void *dest)
383{
384 void *buffer = NULL;
385 unsigned sector_mask = 511;
386 int read_size = (size + sector_mask) & (~sector_mask);
387
388 buffer = malloc(read_size);
389 if(!buffer){
390 dprintf(CRITICAL, "ERROR : Malloc failed for read_from_flash \n");
391 return -1;
392 }
393
394 if(mmc_read(ptn, buffer, read_size)) {
395 dprintf(CRITICAL, "ERROR : Flash read failed \n");
396 return -1;
397 }
398 memcpy(dest, buffer, size);
399 free(buffer);
400 return 0;
401}
402
403static int get_fota_cookie_mmc(void)
404{
405 unsigned long long ptn = 0;
406 int index = -1;
407 unsigned int cookie = 0;
408
409 index = partition_get_index("FOTA");
410 ptn = partition_get_offset(index);
411
412 if(ptn == 0) {
413 dprintf(CRITICAL,"ERROR: FOTA partition not found\n");
414 return 0;
415 }
416 if(read_from_mmc(ptn, sizeof(unsigned int), &cookie)) {
417 dprintf(CRITICAL, "ERROR: Cannot read cookie info\n");
418 return 0;
419 }
420 return cookie;
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530421}
422
Shashank Mittal246f8d02011-01-21 17:12:27 -0800423unsigned check_reboot_mode(void)
424{
Ajay Dudanib01e5062011-12-03 23:23:42 -0800425 unsigned mode[2] = { 0, 0 };
Shashank Mittal246f8d02011-01-21 17:12:27 -0800426 unsigned int mode_len = sizeof(mode);
427 unsigned smem_status;
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530428 unsigned int cookie = 0;
Shashank Mittal246f8d02011-01-21 17:12:27 -0800429
430 smem_status = smem_read_alloc_entry(SMEM_APPS_BOOT_MODE,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800431 &mode, mode_len);
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530432
433 /*
434 * SMEM value is relied upon on power shutdown. Check either of SMEM
435 * or FOTA update cookie is set
436 */
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530437 if (target_is_emmc_boot())
438 cookie = get_fota_cookie_mmc();
439 else
440 cookie = get_fota_cookie_mtd();
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530441
Channagoud Kadabi16f50952012-04-02 16:24:07 +0530442 if ((mode[0] == RECOVERY_MODE) || (cookie == FOTA_COOKIE))
Channagoud Kadabi16da3a22011-10-24 20:25:07 +0530443 return RECOVERY_MODE;
444
Ajay Dudanib01e5062011-12-03 23:23:42 -0800445 if (smem_status) {
446 dprintf(CRITICAL,
447 "ERROR: unable to read shared memory for reboot mode\n");
448 return 0;
Shashank Mittal246f8d02011-01-21 17:12:27 -0800449 }
450 return mode[0];
451}
452
453static unsigned target_check_power_on_reason(void)
454{
455 unsigned power_on_status = 0;
456 unsigned int status_len = sizeof(power_on_status);
457 unsigned smem_status;
458
459 smem_status = smem_read_alloc_entry(SMEM_POWER_ON_STATUS_INFO,
Ajay Dudanib01e5062011-12-03 23:23:42 -0800460 &power_on_status, status_len);
461 if (smem_status) {
462 dprintf(CRITICAL,
463 "ERROR: unable to read shared memory for power on reason\n");
Shashank Mittal246f8d02011-01-21 17:12:27 -0800464 }
465
466 return power_on_status;
467}
468
469unsigned target_pause_for_battery_charge(void)
470{
Ajay Dudaniba822332011-11-25 13:37:31 -0800471 if (target_check_power_on_reason() == PWR_ON_EVENT_WALL_CHG)
Shashank Mittal246f8d02011-01-21 17:12:27 -0800472 return 1;
473 return 0;
474}
475
476void target_battery_charging_enable(unsigned enable, unsigned disconnect)
477{
478}
Shashank Mittal59392f32011-05-01 20:49:56 -0700479
480#if _EMMC_BOOT
481void target_serialno(unsigned char *buf)
482{
483 unsigned int serialno;
Ajay Dudanib01e5062011-12-03 23:23:42 -0800484 serialno = mmc_get_psn();
485 sprintf(buf, "%x", serialno);
Shashank Mittal59392f32011-05-01 20:49:56 -0700486}
Subbaraman Narayanamurthy0e445b02011-06-19 21:34:46 -0700487
488int emmc_recovery_init(void)
489{
490 int rc;
491 rc = _emmc_recovery_init();
492 return rc;
493}
Shashank Mittal59392f32011-05-01 20:49:56 -0700494#endif
Channagoud Kadabid53664b2011-12-28 16:39:15 +0530495
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530496int machine_is_evb()
Channagoud Kadabid53664b2011-12-28 16:39:15 +0530497{
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530498 int ret = 0;
499 unsigned mach_type = board_machtype();
500
501 switch(mach_type) {
502 case MSM7X27A_EVB:
503 case MSM8X25_EVB:
504 ret = 1;
505 break;
506 default:
507 ret = 0;
508 }
509 return ret;
Channagoud Kadabid53664b2011-12-28 16:39:15 +0530510}
Aparna Mallavarapuac332982012-03-18 14:02:38 +0530511int machine_is_qrd()
Channagoud Kadabib33d4832012-02-06 17:10:56 +0530512{
Aparna Mallavarapuac332982012-03-18 14:02:38 +0530513 int ret = 0;
514 unsigned mach_type = board_machtype();
Channagoud Kadabib33d4832012-02-06 17:10:56 +0530515
Aparna Mallavarapuac332982012-03-18 14:02:38 +0530516 switch(mach_type) {
517 case MSM7X27A_QRD1:
518 case MSM7X27A_QRD3:
519 case MSM8X25_QRD7:
520 ret = 1;
521 break;
522 default:
523 ret = 0;
524 }
525 return ret;
Channagoud Kadabib33d4832012-02-06 17:10:56 +0530526}
Channagoud Kadabi81ba1102011-10-01 16:37:59 +0530527int machine_is_8x25()
528{
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530529 int ret = 0;
530 unsigned mach_type = board_machtype();
531
532 switch(mach_type) {
533 case MSM8X25_SURF:
Aparna Mallavarapu1bb33672012-04-20 16:07:24 +0530534 case MSM8X25_FFA:
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530535 case MSM8X25_EVB:
Aparna Mallavarapuac332982012-03-18 14:02:38 +0530536 case MSM8X25_QRD7:
Channagoud Kadabi3acfb742011-11-15 18:19:32 +0530537 ret = 1;
538 break;
539 default:
540 ret = 0;
541 }
542 return ret;
Channagoud Kadabi81ba1102011-10-01 16:37:59 +0530543}
Channagoud Kadabibd14e2f2012-05-03 22:54:50 +0530544
545int msm_is_7x25a(int msm_id)
546{
547 int ret = 0;
548
549 switch (msm_id) {
550 case MSM7225A:
551 case MSM7625A:
552 case ESM7225A:
553 case MSM7225AA:
554 case MSM7625AA:
555 case ESM7225AA:
556 case MSM7225AB:
557 case MSM7625AB:
558 case ESM7225AB:
559 ret = 1;
560 break;
561 default:
562 ret = 0;
563 };
564 return ret;
565}