blob: c9d48bf7d015c76233e172ee4e43c7ebed573588 [file] [log] [blame]
Shashank Mittala635abf2012-03-28 18:11:43 -07001/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
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 Code Aurora Forum, Inc. 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 */
29
30#include <debug.h>
31#include <board.h>
32#include <smem.h>
33#include <baseband.h>
Amol Jadi5c61a952012-05-04 17:05:35 -070034#include <board.h>
Shashank Mittala635abf2012-03-28 18:11:43 -070035
36static struct board_data board = {UNKNOWN,
37 HW_PLATFORM_UNKNOWN,
38 HW_PLATFORM_SUBTYPE_UNKNOWN,
Amol Jadi5c61a952012-05-04 17:05:35 -070039 LINUX_MACHTYPE_UNKNOWN,
40 BASEBAND_MSM};
Shashank Mittala635abf2012-03-28 18:11:43 -070041
42static void platform_detect()
43{
44 struct smem_board_info_v6 board_info_v6;
45 unsigned int board_info_len = 0;
46 unsigned ret = 0;
47 unsigned format = 0;
48
49 ret = smem_read_alloc_entry_offset(SMEM_BOARD_INFO_LOCATION,
50 &format, sizeof(format), 0);
51 if (ret)
52 return;
53
54 if (format == 6) {
55 board_info_len = sizeof(board_info_v6);
56
57 ret =
58 smem_read_alloc_entry(SMEM_BOARD_INFO_LOCATION,
59 &board_info_v6,
60 board_info_len);
61 if (ret)
62 return;
63
64 board.platform = board_info_v6.board_info_v3.msm_id;
65 board.platform_hw =
66 board_info_v6.board_info_v3.hw_platform;
67 board.platform_subtype =
68 board_info_v6.platform_subtype;
69 } else {
70 dprintf(CRITICAL, "Unsupported board info format.\n");
71 }
72}
73
Shashank Mittala635abf2012-03-28 18:11:43 -070074void board_init()
75{
76 platform_detect();
Amol Jadi5c61a952012-05-04 17:05:35 -070077 target_detect(&board);
78 target_baseband_detect(&board);
Shashank Mittala635abf2012-03-28 18:11:43 -070079}
80
Amol Jadi5c61a952012-05-04 17:05:35 -070081uint32_t board_platform_id(void)
Shashank Mittala635abf2012-03-28 18:11:43 -070082{
83 return board.platform;
84}
85
Amol Jadi5c61a952012-05-04 17:05:35 -070086uint32_t board_target_id()
Shashank Mittala635abf2012-03-28 18:11:43 -070087{
88 return board.target;
89}
90
Amol Jadi5c61a952012-05-04 17:05:35 -070091uint32_t board_baseband()
Shashank Mittala635abf2012-03-28 18:11:43 -070092{
93 return board.baseband;
94}