Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame^] | 1 | /* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved. |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -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. |
Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame^] | 12 | * * Neither the name of The Linux Foundation, Inc. nor the names of its |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 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 | */ |
| 29 | |
| 30 | #include <debug.h> |
| 31 | #include <board.h> |
| 32 | #include <smem.h> |
| 33 | #include <baseband.h> |
| 34 | |
| 35 | static struct board_data board = {UNKNOWN, |
| 36 | HW_PLATFORM_UNKNOWN, |
| 37 | HW_PLATFORM_SUBTYPE_UNKNOWN, |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 38 | LINUX_MACHTYPE_UNKNOWN, |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 39 | BASEBAND_MSM, |
| 40 | PMIC_IS_INVALID, |
Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame^] | 41 | 0, |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 42 | 0}; |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 43 | |
| 44 | static void platform_detect() |
| 45 | { |
| 46 | struct smem_board_info_v6 board_info_v6; |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 47 | struct smem_board_info_v7 board_info_v7; |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 48 | unsigned int board_info_len = 0; |
| 49 | unsigned ret = 0; |
| 50 | unsigned format = 0; |
| 51 | |
| 52 | ret = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION, |
| 53 | &format, sizeof(format), 0); |
| 54 | if (ret) |
| 55 | return; |
| 56 | |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 57 | if (format == 6) |
| 58 | { |
| 59 | board_info_len = sizeof(board_info_v6); |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 60 | |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 61 | ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION, |
| 62 | &board_info_v6, |
| 63 | board_info_len); |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 64 | if (ret) |
| 65 | return; |
| 66 | |
| 67 | board.platform = board_info_v6.board_info_v3.msm_id; |
Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame^] | 68 | board.platform_version = board_info_v6.board_info_v3.msm_version; |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 69 | board.platform_hw = board_info_v6.board_info_v3.hw_platform; |
| 70 | board.platform_subtype = board_info_v6.platform_subtype; |
| 71 | } |
| 72 | else if (format == 7) |
| 73 | { |
| 74 | board_info_len = sizeof(board_info_v7); |
| 75 | |
| 76 | ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION, |
| 77 | &board_info_v7, |
| 78 | board_info_len); |
| 79 | if (ret) |
| 80 | return; |
| 81 | |
| 82 | board.platform = board_info_v7.board_info_v3.msm_id; |
Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame^] | 83 | board.platform_version = board_info_v7.board_info_v3.msm_version; |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 84 | board.platform_hw = board_info_v7.board_info_v3.hw_platform; |
| 85 | board.platform_subtype = board_info_v7.platform_subtype; |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 86 | board.pmic_type = board_info_v7.pmic_type; |
| 87 | board.pmic_version = board_info_v7.pmic_version; |
Deepa Dinamani | a4ebcff | 2012-06-11 11:59:30 -0700 | [diff] [blame] | 88 | } |
| 89 | else |
| 90 | { |
| 91 | dprintf(CRITICAL, "Unsupported board info format\n"); |
| 92 | ASSERT(0); |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 96 | void board_init() |
| 97 | { |
| 98 | platform_detect(); |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 99 | target_detect(&board); |
| 100 | target_baseband_detect(&board); |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 103 | uint32_t board_platform_id(void) |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 104 | { |
| 105 | return board.platform; |
| 106 | } |
| 107 | |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 108 | uint32_t board_target_id() |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 109 | { |
| 110 | return board.target; |
| 111 | } |
| 112 | |
Amol Jadi | 5c61a95 | 2012-05-04 17:05:35 -0700 | [diff] [blame] | 113 | uint32_t board_baseband() |
Shashank Mittal | a635abf | 2012-03-28 18:11:43 -0700 | [diff] [blame] | 114 | { |
| 115 | return board.baseband; |
| 116 | } |
Neeti Desai | 465491e | 2012-07-31 12:53:35 -0700 | [diff] [blame] | 117 | |
| 118 | uint32_t board_hardware_id() |
| 119 | { |
| 120 | return board.platform_hw; |
| 121 | } |
Deepa Dinamani | b8b1643 | 2012-08-24 15:48:45 -0700 | [diff] [blame] | 122 | |
| 123 | uint32_t board_pmic_type() |
| 124 | { |
| 125 | return board.pmic_type; |
| 126 | } |
| 127 | |
| 128 | uint32_t board_pmic_ver() |
| 129 | { |
| 130 | return board.pmic_version; |
| 131 | } |
Channagoud Kadabi | afd62bf | 2013-01-08 20:32:52 -0800 | [diff] [blame^] | 132 | |
| 133 | uint32_t board_soc_version() |
| 134 | { |
| 135 | return board.platform_version; |
| 136 | } |