aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShankar Rao2013-08-16 15:35:59 -0500
committerShankar Rao2013-08-16 15:35:59 -0500
commitc389203d808d9cee572f0b83678a8c6640a1d6b0 (patch)
tree9b698f4e688410edfa3574d0354126df67e6051c
parentc4c26a791e4c9e352dd4a7af764afd543be9cc13 (diff)
downloadu-boot-ti-u-boot-2013.04+android.tar.gz
u-boot-ti-u-boot-2013.04+android.tar.xz
u-boot-ti-u-boot-2013.04+android.zip
u-boot: fastboot: Get the board type (HS/GP)ti-u-boot-2013.04+android
This patch adds the functionality to get the board type (HS/GP) and return it to the host via fastboot getvar secure command. Change-Id: I05f2f0ac94b4c2f3de949c74eb6f19c344c89a1c Signed-off-by: Shankar Rao <shankar.nrao@ti.com>
-rw-r--r--drivers/usb/gadget/u_fastboot.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/drivers/usb/gadget/u_fastboot.c b/drivers/usb/gadget/u_fastboot.c
index 5df693b47d..b861ceda5c 100644
--- a/drivers/usb/gadget/u_fastboot.c
+++ b/drivers/usb/gadget/u_fastboot.c
@@ -65,10 +65,23 @@
65#include <bootimg.h> 65#include <bootimg.h>
66#include <mmc.h> 66#include <mmc.h>
67#include <malloc.h> 67#include <malloc.h>
68#include <asm/io.h>
68#include "g_fastboot.h" 69#include "g_fastboot.h"
69 70
70/* The 64 defined bytes plus \0 */ 71/* The 64 defined bytes plus \0 */
71#define RESPONSE_LEN (64 + 1) 72#define RESPONSE_LEN (64 + 1)
73#define CONTROL_STATUS 0x4A002134
74#define DEVICETYPE_MASK (0x7 << 6)
75/* omap-type */
76typedef enum {
77 OMAP_TYPE_TEST,
78 OMAP_TYPE_EMU,
79 OMAP_TYPE_SEC,
80 OMAP_TYPE_GP,
81 OMAP_TYPE_BAD,
82} omap_type;
83
84
72 85
73struct fastboot_config fb_cfg; 86struct fastboot_config fb_cfg;
74 87
@@ -110,6 +123,32 @@ static int strcmp_l1(const char *s1, const char *s2)
110 return strncmp(s1, s2, strlen(s1)); 123 return strncmp(s1, s2, strlen(s1));
111} 124}
112 125
126static char *get_cpu_type(void)
127{
128 static char proc_type[8];
129 unsigned int value;
130
131 value = readl(CONTROL_STATUS);
132 value &= DEVICETYPE_MASK;
133
134 switch (value >> 6) {
135 case OMAP_TYPE_EMU:
136 strcpy(proc_type, "EMU");
137 break;
138 case OMAP_TYPE_SEC:
139 strcpy(proc_type, "HS");
140 break;
141 case OMAP_TYPE_GP:
142 strcpy(proc_type, "GP");
143 break;
144 default:
145 strcpy(proc_type, "unknown");
146 break;
147 }
148
149 return proc_type;
150}
151
113static void cb_getvar(struct usb_ep *ep, struct usb_request *req) 152static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
114{ 153{
115 char *cmd = req->buf; 154 char *cmd = req->buf;
@@ -158,7 +197,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
158 strcpy(response, "FAILValue not set"); 197 strcpy(response, "FAILValue not set");
159 } else if (!strcmp_l1("secure", cmd)) { 198 } else if (!strcmp_l1("secure", cmd)) {
160 199
161 s = fb_find_usb_string(FB_STR_PROC_TYPE_IDX); 200 s = get_cpu_type();
162 if (s) 201 if (s)
163 strncat(response, s, sizeof(response)); 202 strncat(response, s, sizeof(response));
164 else 203 else
@@ -172,6 +211,7 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req)
172 fastboot_tx_write_str(response); 211 fastboot_tx_write_str(response);
173} 212}
174 213
214
175static unsigned int rx_bytes_expected(void) 215static unsigned int rx_bytes_expected(void)
176{ 216{
177 int rx_remain = download_size - download_bytes; 217 int rx_remain = download_size - download_bytes;