Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 1 | /* |
Casey Piper | a277d88 | 2013-10-21 10:11:04 -0700 | [diff] [blame] | 2 | * Copyright (c) 2008 Travis Geiselbrecht |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 3 | * |
lijuang | c518f5d | 2015-02-10 10:22:53 +0800 | [diff] [blame] | 4 | * Copyright (c) 2015, The Linux Foundation. All rights reserved. |
| 5 | * |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 6 | * Permission is hereby granted, free of charge, to any person obtaining |
| 7 | * a copy of this software and associated documentation files |
| 8 | * (the "Software"), to deal in the Software without restriction, |
| 9 | * including without limitation the rights to use, copy, modify, merge, |
| 10 | * publish, distribute, sublicense, and/or sell copies of the Software, |
| 11 | * and to permit persons to whom the Software is furnished to do so, |
| 12 | * subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be |
| 15 | * included in all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 20 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 21 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 23 | * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | #include <err.h> |
| 26 | #include <debug.h> |
| 27 | #include <target.h> |
| 28 | #include <compiler.h> |
Pavel Nedev | a4c9d3a | 2013-05-15 14:42:34 +0300 | [diff] [blame] | 29 | #include <dload_util.h> |
Channagoud Kadabi | 41c81a6 | 2014-10-08 19:55:30 -0700 | [diff] [blame] | 30 | #include <sdhci_msm.h> |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 31 | |
Subbaraman Narayanamurthy | f17b4ae | 2011-02-16 20:19:56 -0800 | [diff] [blame] | 32 | #define EXPAND(NAME) #NAME |
| 33 | #define TARGET(NAME) EXPAND(NAME) |
Amol Jadi | 57abe4c | 2011-05-24 15:47:27 -0700 | [diff] [blame] | 34 | /* |
Travis Geiselbrecht | 1d0df69 | 2008-09-01 02:26:09 -0700 | [diff] [blame] | 35 | * default implementations of these routines, if the target code |
| 36 | * chooses not to implement. |
| 37 | */ |
| 38 | |
| 39 | __WEAK void target_early_init(void) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | __WEAK void target_init(void) |
| 44 | { |
| 45 | } |
| 46 | |
David Ng | 3679bc5 | 2010-02-09 15:43:43 -0800 | [diff] [blame] | 47 | __WEAK void *target_get_scratch_address(void) |
| 48 | { |
| 49 | return (void *)(SCRATCH_ADDR); |
| 50 | } |
| 51 | |
Vivek Mehta | 5f1c9d4 | 2011-04-01 20:11:59 -0700 | [diff] [blame] | 52 | __WEAK unsigned target_get_max_flash_size(void) |
| 53 | { |
| 54 | return (120 * 1024 * 1024); |
| 55 | } |
| 56 | |
Tanya Brokhman | 1c94f1a | 2015-02-15 09:05:03 +0200 | [diff] [blame] | 57 | __WEAK int flash_ubi_img(void) |
| 58 | { |
| 59 | return 0; |
| 60 | } |
| 61 | |
Tanya Brokhman | 84eaaf6 | 2015-02-24 21:57:06 +0200 | [diff] [blame] | 62 | __WEAK int update_ubi_vol(void) |
| 63 | { |
| 64 | return 0; |
| 65 | } |
| 66 | |
David Ng | 183a742 | 2009-12-07 14:55:21 -0800 | [diff] [blame] | 67 | __WEAK int target_is_emmc_boot(void) |
| 68 | { |
David Ng | 025c1d9 | 2009-12-09 23:46:00 -0800 | [diff] [blame] | 69 | #if _EMMC_BOOT |
| 70 | return 1; |
| 71 | #else |
David Ng | 183a742 | 2009-12-07 14:55:21 -0800 | [diff] [blame] | 72 | return 0; |
David Ng | 025c1d9 | 2009-12-09 23:46:00 -0800 | [diff] [blame] | 73 | #endif |
David Ng | 183a742 | 2009-12-07 14:55:21 -0800 | [diff] [blame] | 74 | } |
Chandan Uddaraju | de85d3f | 2010-01-05 16:32:33 -0800 | [diff] [blame] | 75 | |
| 76 | __WEAK unsigned check_reboot_mode(void) |
| 77 | { |
| 78 | return 0; |
| 79 | } |
Chandan Uddaraju | 94183c0 | 2010-01-15 15:13:59 -0800 | [diff] [blame] | 80 | |
lijuang | c518f5d | 2015-02-10 10:22:53 +0800 | [diff] [blame] | 81 | __WEAK unsigned check_hard_reboot_mode(void) |
| 82 | { |
| 83 | return 0; |
| 84 | } |
| 85 | |
Chandan Uddaraju | 94183c0 | 2010-01-15 15:13:59 -0800 | [diff] [blame] | 86 | __WEAK void reboot_device(unsigned reboot_reason) |
| 87 | { |
| 88 | } |
Chandan Uddaraju | 7f5b901 | 2010-02-06 16:37:48 -0800 | [diff] [blame] | 89 | |
Matthew Qin | defd556 | 2014-07-11 18:02:40 +0800 | [diff] [blame] | 90 | __WEAK uint32_t is_user_force_reset(void) |
| 91 | { |
| 92 | return 0; |
| 93 | } |
| 94 | |
Pavel Nedev | a4c9d3a | 2013-05-15 14:42:34 +0300 | [diff] [blame] | 95 | __WEAK int set_download_mode(enum dload_mode mode) |
Pavel Nedev | 76a3e21 | 2013-05-09 10:37:21 +0300 | [diff] [blame] | 96 | { |
| 97 | return -1; |
| 98 | } |
| 99 | |
David Ng | f773dde | 2010-07-26 19:55:08 -0700 | [diff] [blame] | 100 | __WEAK unsigned target_pause_for_battery_charge(void) |
| 101 | { |
| 102 | return 0; |
| 103 | } |
Ajay Dudani | d04110c | 2011-01-17 23:55:07 -0800 | [diff] [blame] | 104 | |
| 105 | __WEAK unsigned target_baseband() |
| 106 | { |
| 107 | return 0; |
| 108 | } |
Subbaraman Narayanamurthy | f17b4ae | 2011-02-16 20:19:56 -0800 | [diff] [blame] | 109 | |
| 110 | __WEAK void target_serialno(unsigned char *buf) |
| 111 | { |
Ajay Dudani | f63d02f | 2011-10-01 08:29:53 -0700 | [diff] [blame] | 112 | snprintf((char *) buf, 13, "%s",TARGET(BOARD)); |
Subbaraman Narayanamurthy | f17b4ae | 2011-02-16 20:19:56 -0800 | [diff] [blame] | 113 | } |
Amol Jadi | 57abe4c | 2011-05-24 15:47:27 -0700 | [diff] [blame] | 114 | |
| 115 | __WEAK void target_fastboot_init() |
| 116 | { |
| 117 | } |
Subbaraman Narayanamurthy | 0e445b0 | 2011-06-19 21:34:46 -0700 | [diff] [blame] | 118 | |
| 119 | __WEAK int emmc_recovery_init(void) |
| 120 | { |
| 121 | return 0; |
| 122 | } |
Shashank Mittal | cd98d47 | 2011-08-02 14:29:24 -0700 | [diff] [blame] | 123 | |
| 124 | __WEAK bool target_use_signed_kernel(void) |
| 125 | { |
| 126 | #if _SIGNED_KERNEL |
| 127 | return 1; |
| 128 | #else |
| 129 | return 0; |
| 130 | #endif |
| 131 | } |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 132 | |
Stanimir Varbanov | 8bc68c7 | 2013-07-08 18:22:04 +0300 | [diff] [blame] | 133 | __WEAK bool target_is_ssd_enabled(void) |
| 134 | { |
| 135 | #ifdef SSD_ENABLE |
| 136 | return 1; |
| 137 | #else |
| 138 | return 0; |
| 139 | #endif |
| 140 | } |
| 141 | |
Stanimir Varbanov | 677001e | 2013-07-18 18:16:39 +0300 | [diff] [blame] | 142 | __WEAK void target_load_ssd_keystore(void) |
| 143 | { |
| 144 | } |
Amol Jadi | 6834f1a | 2012-06-29 14:42:59 -0700 | [diff] [blame] | 145 | |
| 146 | /* Default target does not support continuous splash screen feature. */ |
| 147 | __WEAK int target_cont_splash_screen() |
| 148 | { |
| 149 | return 0; |
| 150 | } |
Amol Jadi | da118b9 | 2012-07-06 19:53:18 -0700 | [diff] [blame] | 151 | |
| 152 | /* Default target specific initialization before using USB */ |
| 153 | __WEAK void target_usb_init(void) |
| 154 | { |
| 155 | } |
| 156 | |
| 157 | /* Default target specific usb shutdown */ |
| 158 | __WEAK void target_usb_stop(void) |
| 159 | { |
| 160 | } |
Channagoud Kadabi | fa6179e | 2013-06-18 18:35:14 -0700 | [diff] [blame] | 161 | |
| 162 | /* Default target specific target uninit */ |
| 163 | __WEAK void target_uninit(void) |
| 164 | { |
| 165 | } |
Dhaval Patel | cdcb646 | 2013-07-18 14:46:57 -0700 | [diff] [blame] | 166 | |
Padmanabhan Komanduru | bccbcdc | 2015-06-30 16:19:24 +0530 | [diff] [blame] | 167 | __WEAK bool target_display_panel_node(char *pbuf, uint16_t buf_size) |
Dhaval Patel | cdcb646 | 2013-07-18 14:46:57 -0700 | [diff] [blame] | 168 | { |
| 169 | return false; |
| 170 | } |
Channagoud Kadabi | 9fbdcdf | 2013-09-19 16:24:16 -0700 | [diff] [blame] | 171 | |
Aravind Venkateswaran | 6385f7e | 2014-02-25 16:45:11 -0800 | [diff] [blame] | 172 | __WEAK void target_display_init(const char *panel_name) |
Aravind Venkateswaran | dd50c1a | 2014-02-25 14:42:43 -0800 | [diff] [blame] | 173 | { |
| 174 | } |
| 175 | |
| 176 | __WEAK void target_display_shutdown(void) |
| 177 | { |
| 178 | } |
| 179 | |
Casey Piper | f8cebb6 | 2013-09-11 15:56:17 -0700 | [diff] [blame] | 180 | __WEAK uint8_t target_panel_auto_detect_enabled() |
| 181 | { |
| 182 | return 0; |
| 183 | } |
| 184 | |
Casey Piper | 48bfc0d | 2013-11-18 13:24:35 -0800 | [diff] [blame] | 185 | __WEAK uint8_t target_is_edp() |
| 186 | { |
| 187 | return 0; |
| 188 | } |
| 189 | |
Amol Jadi | 417c7f2 | 2013-10-07 12:52:21 -0700 | [diff] [blame] | 190 | /* default usb controller to be used. */ |
| 191 | __WEAK const char * target_usb_controller() |
| 192 | { |
| 193 | return "ci"; |
| 194 | } |
Amol Jadi | 9ff7bb5 | 2013-10-11 14:11:45 -0700 | [diff] [blame] | 195 | |
| 196 | /* override for target specific usb phy reset. */ |
| 197 | __WEAK void target_usb_phy_reset(void) |
| 198 | { |
| 199 | } |
Hanumant Singh | 8e1ac23 | 2014-01-29 13:41:51 -0800 | [diff] [blame] | 200 | |
| 201 | /* determine if target is in warm boot. */ |
| 202 | __WEAK bool target_warm_boot(void) |
| 203 | { |
| 204 | return false; |
| 205 | } |
Aparna Mallavarapu | 373d38b | 2014-05-23 14:47:19 +0530 | [diff] [blame] | 206 | |
| 207 | /* Determine the HLOS subtype of the target */ |
| 208 | __WEAK uint32_t target_get_hlos_subtype(void) |
| 209 | { |
| 210 | return 0; |
| 211 | } |
Channagoud Kadabi | 82cf5c6 | 2014-08-24 22:17:34 -0700 | [diff] [blame] | 212 | |
| 213 | /* Initialize crypto parameters */ |
| 214 | __WEAK void target_crypto_init_params() |
| 215 | { |
| 216 | } |
Channagoud Kadabi | 41c81a6 | 2014-10-08 19:55:30 -0700 | [diff] [blame] | 217 | |
| 218 | /* Default CFG delay value */ |
| 219 | __WEAK uint32_t target_ddr_cfg_val() |
| 220 | { |
| 221 | return DDR_CONFIG_VAL; |
| 222 | } |
Channagoud Kadabi | 2021cef | 2015-02-25 12:08:32 -0800 | [diff] [blame] | 223 | |
| 224 | /* Return Build variant */ |
| 225 | __WEAK bool target_build_variant_user() |
| 226 | { |
| 227 | #if USER_BUILD_VARIANT |
| 228 | return true; |
| 229 | #else |
| 230 | return false; |
| 231 | #endif |
| 232 | } |