blob: 6b2592906e85b73599bf4d66d4466519ce01285b [file] [log] [blame]
Deepa Dinamani645e9b12012-12-21 14:23:40 -08001/* Copyright (c) 2012-2013, The Linux Foundation. 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 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
29#include <debug.h>
30#include <platform/iomap.h>
31#include <reg.h>
32#include <target.h>
33#include <platform.h>
34#include <uart_dm.h>
35#include <mmc.h>
Deepa Dinamani7e729772013-02-25 11:54:05 -080036#include <platform/gpio.h>
Deepa Dinamani645e9b12012-12-21 14:23:40 -080037#include <spmi.h>
38#include <board.h>
Deepa Dinamaniff2b9ce2013-02-25 11:01:00 -080039#include <smem.h>
40#include <baseband.h>
Deepa Dinamani7e729772013-02-25 11:54:05 -080041#include <dev/keys.h>
Deepa Dinamani058f1cd2013-02-25 10:53:01 -080042#include <pm8x41.h>
Deepa Dinamani645e9b12012-12-21 14:23:40 -080043
44#define PMIC_ARB_CHANNEL_NUM 0
45#define PMIC_ARB_OWNER_ID 0
46
Deepa Dinamani7e729772013-02-25 11:54:05 -080047#define TLMM_VOL_UP_BTN_GPIO 106
48
Deepa Dinamani645e9b12012-12-21 14:23:40 -080049static uint32_t mmc_sdc_base[] =
Deepa Dinamani7c79d7d2013-02-08 13:47:08 -080050 { MSM_SDC1_BASE, MSM_SDC2_BASE, MSM_SDC3_BASE };
Deepa Dinamani645e9b12012-12-21 14:23:40 -080051
52void target_early_init(void)
53{
54#if WITH_DEBUG_UART
Deepa Dinamani0a6c48c2013-02-04 15:45:01 -080055 uart_dm_init(1, 0, BLSP1_UART2_BASE);
Deepa Dinamani645e9b12012-12-21 14:23:40 -080056#endif
57}
58
Deepa Dinamani7e729772013-02-25 11:54:05 -080059/* Return 1 if vol_up pressed */
60static int target_volume_up()
61{
62 uint8_t status = 0;
63
64 gpio_tlmm_config(TLMM_VOL_UP_BTN_GPIO, 0, GPIO_INPUT, GPIO_PULL_UP, GPIO_2MA, GPIO_ENABLE);
65
66 /* Get status of GPIO */
67 status = gpio_status(TLMM_VOL_UP_BTN_GPIO);
68
69 /* Active low signal. */
70 return !status;
71}
72
73/* Return 1 if vol_down pressed */
74uint32_t target_volume_down()
75{
76 /* Volume down button tied in with PMIC RESIN. */
77 return pm8x41_resin_status();
78}
79
Deepa Dinamani645e9b12012-12-21 14:23:40 -080080static void target_keystatus()
81{
Deepa Dinamani7e729772013-02-25 11:54:05 -080082 keys_init();
83
84 if(target_volume_down())
85 keys_post_event(KEY_VOLUMEDOWN, 1);
86
87 if(target_volume_up())
88 keys_post_event(KEY_VOLUMEUP, 1);
Deepa Dinamani645e9b12012-12-21 14:23:40 -080089}
90
91void target_init(void)
92{
93 uint32_t base_addr;
94 uint8_t slot;
95
96 dprintf(INFO, "target_init()\n");
97
98 spmi_init(PMIC_ARB_CHANNEL_NUM, PMIC_ARB_OWNER_ID);
99
100 target_keystatus();
101
102 /* Trying Slot 1*/
103 slot = 1;
104 base_addr = mmc_sdc_base[slot - 1];
105 if (mmc_boot_main(slot, base_addr))
106 {
107
108 /* Trying Slot 2 next */
109 slot = 2;
110 base_addr = mmc_sdc_base[slot - 1];
111 if (mmc_boot_main(slot, base_addr)) {
112 dprintf(CRITICAL, "mmc init failed!");
113 ASSERT(0);
114 }
115 }
116}
117
Deepa Dinamani058f1cd2013-02-25 10:53:01 -0800118/* Do any target specific intialization needed before entering fastboot mode */
119void target_fastboot_init(void)
120{
121 /* Set the BOOT_DONE flag in PM8026 */
122 pm8x41_set_boot_done();
123}
124
Deepa Dinamaniff2b9ce2013-02-25 11:01:00 -0800125/* Detect the target type */
126void target_detect(struct board_data *board)
127{
128 board->target = LINUX_MACHTYPE_UNKNOWN;
129}
130
131/* Detect the modem type */
132void target_baseband_detect(struct board_data *board)
133{
134 uint32_t platform;
135 uint32_t platform_subtype;
136
137 platform = board->platform;
138 platform_subtype = board->platform_subtype;
139
140 /*
141 * Look for platform subtype if present, else
142 * check for platform type to decide on the
143 * baseband type
144 */
145 switch(platform_subtype)
146 {
147 case HW_PLATFORM_SUBTYPE_UNKNOWN:
148 break;
149 default:
150 dprintf(CRITICAL, "Platform Subtype : %u is not supported\n", platform_subtype);
151 ASSERT(0);
152 };
153
154 switch(platform)
155 {
156 case MSM8826:
157 case MSM8626:
158 case MSM8226:
159 board->baseband = BASEBAND_MSM;
160 break;
161 default:
162 dprintf(CRITICAL, "Platform type: %u is not supported\n", platform);
163 ASSERT(0);
164 };
165}
166
Deepa Dinamani645e9b12012-12-21 14:23:40 -0800167void target_serialno(unsigned char *buf)
168{
169 uint32_t serialno;
170 if (target_is_emmc_boot()) {
171 serialno = mmc_get_psn();
172 snprintf((char *)buf, 13, "%x", serialno);
173 }
174}
175
176unsigned board_machtype(void)
177{
178}