Glenn Stroz | 99291c2 | 2016-07-18 11:27:37 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved. |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 2 | |
| 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 Kadabi | 8fb2ab5 | 2015-06-02 16:19:24 -0700 | [diff] [blame] | 31 | #include <board.h> |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 32 | #include <platform/iomap.h> |
| 33 | #include <boot_device.h> |
Smita Ghosh | f5431c6 | 2014-09-18 14:11:14 -0700 | [diff] [blame] | 34 | #include <qpic_nand.h> |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 35 | |
| 36 | static uint32_t boot_device; |
| 37 | |
| 38 | void platform_read_boot_config() |
| 39 | { |
| 40 | boot_device = BOOT_DEVICE_MASK(readl(BOOT_CONFIG_REG)); |
Channagoud Kadabi | 8fb2ab5 | 2015-06-02 16:19:24 -0700 | [diff] [blame] | 41 | board_update_boot_dev(boot_device); |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | uint32_t platform_get_boot_dev() |
| 45 | { |
| 46 | return boot_device; |
| 47 | } |
| 48 | |
| 49 | /* |
| 50 | * Return 1 if boot from emmc else 0 |
| 51 | */ |
| 52 | uint32_t platform_boot_dev_isemmc() |
| 53 | { |
| 54 | uint32_t boot_dev_type; |
| 55 | |
| 56 | boot_dev_type = platform_get_boot_dev(); |
| 57 | |
Channagoud Kadabi | c42ea32 | 2014-10-10 12:26:54 -0700 | [diff] [blame] | 58 | #if USE_MDM_BOOT_CFG |
| 59 | /* For MDM default boot device is NAND */ |
| 60 | if (boot_dev_type == BOOT_EMMC) |
| 61 | #else |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 62 | if (boot_dev_type == BOOT_EMMC || boot_dev_type == BOOT_DEFAULT) |
Channagoud Kadabi | c42ea32 | 2014-10-10 12:26:54 -0700 | [diff] [blame] | 63 | #endif |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 64 | boot_dev_type = 1; |
| 65 | else |
| 66 | boot_dev_type = 0; |
| 67 | |
| 68 | return boot_dev_type; |
| 69 | } |
| 70 | |
| 71 | void platform_boot_dev_cmdline(char *buf) |
| 72 | { |
| 73 | uint32_t val = 0; |
Veera Sundaram Sankaran | 0018151 | 2014-12-09 11:23:39 -0800 | [diff] [blame] | 74 | void *dev = target_mmc_device(); |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 75 | |
| 76 | val = platform_get_boot_dev(); |
| 77 | switch(val) |
| 78 | { |
Channagoud Kadabi | c42ea32 | 2014-10-10 12:26:54 -0700 | [diff] [blame] | 79 | #if !USE_MDM_BOOT_CFG |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 80 | case BOOT_DEFAULT: |
Sridhar Parasuram | efc133f | 2015-05-04 13:35:41 -0700 | [diff] [blame] | 81 | snprintf(buf, ((sizeof((struct mmc_device *)dev)->host.base)*2) + 7,"%x.sdhci", ((struct mmc_device *)dev)->host.base); |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 82 | break; |
| 83 | case BOOT_UFS: |
Glenn Stroz | 99291c2 | 2016-07-18 11:27:37 -0700 | [diff] [blame] | 84 | case BOOT_SD_ELSE_UFS: |
Sridhar Parasuram | efc133f | 2015-05-04 13:35:41 -0700 | [diff] [blame] | 85 | snprintf(buf, ((sizeof((struct ufs_dev *)dev)->base)*2) + 7, "%x.ufshc", ((struct ufs_dev *)dev)->base); |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 86 | break; |
Channagoud Kadabi | c42ea32 | 2014-10-10 12:26:54 -0700 | [diff] [blame] | 87 | #endif |
| 88 | case BOOT_EMMC: |
Sridhar Parasuram | efc133f | 2015-05-04 13:35:41 -0700 | [diff] [blame] | 89 | snprintf(buf, ((sizeof((struct mmc_device *)dev)->host.base)*2) + 7,"%x.sdhci", ((struct mmc_device *)dev)->host.base); |
Smita Ghosh | f5431c6 | 2014-09-18 14:11:14 -0700 | [diff] [blame] | 90 | break; |
Sundarajan Srinivasan | 34bbe07 | 2014-03-21 17:27:16 -0700 | [diff] [blame] | 91 | default: |
| 92 | dprintf(CRITICAL,"ERROR: Unexpected boot_device val=%x",val); |
| 93 | ASSERT(0); |
| 94 | }; |
| 95 | } |