blob: 220c6d32b041167763b104445f49b219804fc8b1 [file] [log] [blame]
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Shashank Mittala635abf2012-03-28 18:11:43 -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.
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -080012 * * Neither the name of The Linux Foundation, Inc. nor the names of its
Shashank Mittala635abf2012-03-28 18:11:43 -070013 * 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
35static struct board_data board = {UNKNOWN,
36 HW_PLATFORM_UNKNOWN,
37 HW_PLATFORM_SUBTYPE_UNKNOWN,
Amol Jadi5c61a952012-05-04 17:05:35 -070038 LINUX_MACHTYPE_UNKNOWN,
Deepa Dinamanib8b16432012-08-24 15:48:45 -070039 BASEBAND_MSM,
40 PMIC_IS_INVALID,
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -080041 0,
Deepa Dinamanib8b16432012-08-24 15:48:45 -070042 0};
Shashank Mittala635abf2012-03-28 18:11:43 -070043
44static void platform_detect()
45{
46 struct smem_board_info_v6 board_info_v6;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070047 struct smem_board_info_v7 board_info_v7;
Shashank Mittala635abf2012-03-28 18:11:43 -070048 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 Dinamania4ebcff2012-06-11 11:59:30 -070057 if (format == 6)
58 {
59 board_info_len = sizeof(board_info_v6);
Shashank Mittala635abf2012-03-28 18:11:43 -070060
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070061 ret = smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
62 &board_info_v6,
63 board_info_len);
Shashank Mittala635abf2012-03-28 18:11:43 -070064 if (ret)
65 return;
66
67 board.platform = board_info_v6.board_info_v3.msm_id;
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -080068 board.platform_version = board_info_v6.board_info_v3.msm_version;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070069 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 Kadabiafd62bf2013-01-08 20:32:52 -080083 board.platform_version = board_info_v7.board_info_v3.msm_version;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070084 board.platform_hw = board_info_v7.board_info_v3.hw_platform;
85 board.platform_subtype = board_info_v7.platform_subtype;
Deepa Dinamanib8b16432012-08-24 15:48:45 -070086 board.pmic_type = board_info_v7.pmic_type;
87 board.pmic_version = board_info_v7.pmic_version;
Deepa Dinamania4ebcff2012-06-11 11:59:30 -070088 }
89 else
90 {
91 dprintf(CRITICAL, "Unsupported board info format\n");
92 ASSERT(0);
Shashank Mittala635abf2012-03-28 18:11:43 -070093 }
94}
95
Shashank Mittala635abf2012-03-28 18:11:43 -070096void board_init()
97{
98 platform_detect();
Amol Jadi5c61a952012-05-04 17:05:35 -070099 target_detect(&board);
100 target_baseband_detect(&board);
Shashank Mittala635abf2012-03-28 18:11:43 -0700101}
102
Amol Jadi5c61a952012-05-04 17:05:35 -0700103uint32_t board_platform_id(void)
Shashank Mittala635abf2012-03-28 18:11:43 -0700104{
105 return board.platform;
106}
107
Amol Jadi5c61a952012-05-04 17:05:35 -0700108uint32_t board_target_id()
Shashank Mittala635abf2012-03-28 18:11:43 -0700109{
110 return board.target;
111}
112
Amol Jadi5c61a952012-05-04 17:05:35 -0700113uint32_t board_baseband()
Shashank Mittala635abf2012-03-28 18:11:43 -0700114{
115 return board.baseband;
116}
Neeti Desai465491e2012-07-31 12:53:35 -0700117
118uint32_t board_hardware_id()
119{
120 return board.platform_hw;
121}
Deepa Dinamanib8b16432012-08-24 15:48:45 -0700122
123uint32_t board_pmic_type()
124{
125 return board.pmic_type;
126}
127
128uint32_t board_pmic_ver()
129{
130 return board.pmic_version;
131}
Channagoud Kadabiafd62bf2013-01-08 20:32:52 -0800132
133uint32_t board_soc_version()
134{
135 return board.platform_version;
136}