blob: 3416ad97d8e3822f868afd9f9b66bed548d7cf93 [file] [log] [blame]
Sridhar Parasuramefc133f2015-05-04 13:35:41 -07001/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -07002
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are
5 * met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer in the documentation and/or other materials provided
11 * with the distribution.
12 * * Neither the name of The Linux Foundation. nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28#include <debug.h>
29#include <mmc.h>
30#include <ufs.h>
Channagoud Kadabi8fb2ab52015-06-02 16:19:24 -070031#include <board.h>
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070032#include <platform/iomap.h>
33#include <boot_device.h>
Smita Ghoshf5431c62014-09-18 14:11:14 -070034#include <qpic_nand.h>
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070035
36static uint32_t boot_device;
37
38void platform_read_boot_config()
39{
40 boot_device = BOOT_DEVICE_MASK(readl(BOOT_CONFIG_REG));
Channagoud Kadabi8fb2ab52015-06-02 16:19:24 -070041 board_update_boot_dev(boot_device);
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070042}
43
44uint32_t platform_get_boot_dev()
45{
46 return boot_device;
47}
48
49/*
50 * Return 1 if boot from emmc else 0
51 */
52uint32_t platform_boot_dev_isemmc()
53{
54 uint32_t boot_dev_type;
55
56 boot_dev_type = platform_get_boot_dev();
57
Channagoud Kadabic42ea322014-10-10 12:26:54 -070058#if USE_MDM_BOOT_CFG
59 /* For MDM default boot device is NAND */
60 if (boot_dev_type == BOOT_EMMC)
61#else
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070062 if (boot_dev_type == BOOT_EMMC || boot_dev_type == BOOT_DEFAULT)
Channagoud Kadabic42ea322014-10-10 12:26:54 -070063#endif
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070064 boot_dev_type = 1;
65 else
66 boot_dev_type = 0;
67
68 return boot_dev_type;
69}
70
71void platform_boot_dev_cmdline(char *buf)
72{
73 uint32_t val = 0;
Veera Sundaram Sankaran00181512014-12-09 11:23:39 -080074 void *dev = target_mmc_device();
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070075
76 val = platform_get_boot_dev();
77 switch(val)
78 {
Channagoud Kadabic42ea322014-10-10 12:26:54 -070079#if !USE_MDM_BOOT_CFG
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070080 case BOOT_DEFAULT:
Sridhar Parasuramefc133f2015-05-04 13:35:41 -070081 snprintf(buf, ((sizeof((struct mmc_device *)dev)->host.base)*2) + 7,"%x.sdhci", ((struct mmc_device *)dev)->host.base);
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070082 break;
83 case BOOT_UFS:
Sridhar Parasuramefc133f2015-05-04 13:35:41 -070084 snprintf(buf, ((sizeof((struct ufs_dev *)dev)->base)*2) + 7, "%x.ufshc", ((struct ufs_dev *)dev)->base);
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070085 break;
Channagoud Kadabic42ea322014-10-10 12:26:54 -070086#endif
87 case BOOT_EMMC:
Sridhar Parasuramefc133f2015-05-04 13:35:41 -070088 snprintf(buf, ((sizeof((struct mmc_device *)dev)->host.base)*2) + 7,"%x.sdhci", ((struct mmc_device *)dev)->host.base);
Smita Ghoshf5431c62014-09-18 14:11:14 -070089 break;
Sundarajan Srinivasan34bbe072014-03-21 17:27:16 -070090 default:
91 dprintf(CRITICAL,"ERROR: Unexpected boot_device val=%x",val);
92 ASSERT(0);
93 };
94}