From patchwork Thu Jul 12 11:05:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Panizzo X-Patchwork-Id: 942917 X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="QMsPPEY8"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41RCs44vKRz9rxx for ; Thu, 12 Jul 2018 21:10:16 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 2492BC21FD6; Thu, 12 Jul 2018 11:10:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4968EC21F9D; Thu, 12 Jul 2018 11:06:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6088AC21FA4; Thu, 12 Jul 2018 11:06:45 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id A2299C21FA0 for ; Thu, 12 Jul 2018 11:06:29 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id 69-v6so5558148wmf.3 for ; Thu, 12 Jul 2018 04:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=c82NKCOoeL3odpIvNb+TyzDkLfcUhAB60tay1TMibk0=; b=QMsPPEY8COk1riRW2Jx+WGWp2H5sVCHe2rAMKpDeCX4O7ib0naT/LzmYE/JkFbfCd9 Z2J8zasd6sYXuG0w3XFFiayLYxWTvfwN4Xdmy+ObrxMGg2oeu1u8AqlYFWP7HgTwiXOl DNtZTU9M1UWxM6HiinVvedz3P3TPcWQKckyDA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=c82NKCOoeL3odpIvNb+TyzDkLfcUhAB60tay1TMibk0=; b=rYDpYBjMrPez0u0bcecvxZIieLSkuDwpiKCOtyzwIOTCHDNyyMDZAsatXah/o68c6v 7XU69fmt7Pyztlgpou3pX8dwbFsI1KM3zP0xEYKxzqhVQBtHSYTgQY+523VTr9frLqLg OHMONbQPP5GWGRT5koaMN/BetklkoQJkgqhlBZgHRNzpFQyz90+eNgrP7iesCYnT7/Kw +eNzv6FCZkDcJclf6+wp+Uv6IINZKkLJja9tfc7fNwRFbJJ82vsnr9f99+ZOYfupLB/b Vyk5C0cET8MxAdh2W/vIt8hQHVxri68J18WNFAbHcNzfRVUGv+YvZwDKHQQ7ag+EqdRE q5gw== X-Gm-Message-State: AOUpUlEYCg7bRERIXQ8Xq7ATR8LkxU7ogDWleXmXVkys195QgI3htTDc Uw0sqzlTHS39LVJIyi9BaUylJ58K X-Google-Smtp-Source: AAOMgpcHVVoZARi2NAmbvjhshf/oj/3xO/KeLvrPck7Ms8hBvLzELfDV3/0IOOkR7dKklj76TtlJmw== X-Received: by 2002:a1c:7908:: with SMTP id l8-v6mr1039327wme.80.1531393589193; Thu, 12 Jul 2018 04:06:29 -0700 (PDT) Received: from localhost.localdomain (host-9473-86-113.popwifi.it. [94.73.86.113]) by smtp.googlemail.com with ESMTPSA id t140-v6sm6982421wmd.14.2018.07.12.04.06.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Jul 2018 04:06:28 -0700 (PDT) From: Alberto Panizzo To: u-boot@lists.denx.de Date: Thu, 12 Jul 2018 13:05:42 +0200 Message-Id: <1531393559-28958-3-git-send-email-alberto@amarulasolutions.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531393559-28958-1-git-send-email-alberto@amarulasolutions.com> References: <1531393559-28958-1-git-send-email-alberto@amarulasolutions.com> Cc: Marek Vasut Subject: [U-Boot] [PATCH v3 2/9] usb: rockchip: implement skeleton for K_FW_GET_CHIP_VER command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Chip Version is a string saved in BOOTROM address space Little Endian. Ex for rk3288: 0x33323041 0x32303134 0x30383133 0x56323030 which brings: 320A20140813V200 Note that memory version do invert MSB/LSB so printing the char buffer would show: A02341023180002V Signed-off-by: Alberto Panizzo Reviewed-by: Philipp Tomsich --- doc/README.rockusb | 9 ++++++--- drivers/usb/gadget/f_rockusb.c | 44 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/doc/README.rockusb b/doc/README.rockusb index 5405dc4..3a93edc 100644 --- a/doc/README.rockusb +++ b/doc/README.rockusb @@ -42,9 +42,12 @@ see doc/README.rockchip for more detail about how to get U-Boot binary. sudo rkdeveloptool wl 64 -There are plenty of Rockusb command. but wl(write lba) and -rd(reboot) command. These two command can let people flash -image to device. +Current set of rkdeveloptool commands supported: +- rci: Read Chip Info +- rfi: Read Flash Id +- rd : Reset Device +- td : Test Device Ready +- wl : Write blocks using LBA To do ----- diff --git a/drivers/usb/gadget/f_rockusb.c b/drivers/usb/gadget/f_rockusb.c index 58e483c..0314ff0 100644 --- a/drivers/usb/gadget/f_rockusb.c +++ b/drivers/usb/gadget/f_rockusb.c @@ -523,6 +523,48 @@ static void cb_read_storage_id(struct usb_ep *ep, struct usb_request *req) rockusb_tx_write_str(emmc_id); } +int __weak rk_get_bootrom_chip_version(unsigned int *chip_info, int size) +{ + return 0; +} + +static void cb_get_chip_version(struct usb_ep *ep, struct usb_request *req) +{ + ALLOC_CACHE_ALIGN_BUFFER(struct fsg_bulk_cb_wrap, cbw, + sizeof(struct fsg_bulk_cb_wrap)); + struct f_rockusb *f_rkusb = get_rkusb(); + unsigned int chip_info[4], i; + + memset(chip_info, 0, sizeof(chip_info)); + rk_get_bootrom_chip_version(chip_info, 4); + + /* + * Chip Version is a string saved in BOOTROM address space Little Endian + * + * Ex for rk3288: 0x33323041 0x32303134 0x30383133 0x56323030 + * which brings: 320A20140813V200 + * + * Note that memory version do invert MSB/LSB so printing the char + * buffer will show: A02341023180002V + */ + printf("read chip version: "); + for (i = 0; i < 4; i++) { + printf("%c%c%c%c", + (chip_info[i] >> 24) & 0xFF, + (chip_info[i] >> 16) & 0xFF, + (chip_info[i] >> 8) & 0xFF, + (chip_info[i] >> 0) & 0xFF); + } + printf("\n"); + memcpy((char *)cbw, req->buf, USB_BULK_CB_WRAP_LEN); + + /* Prepare for sending subsequent CSW_GOOD */ + f_rkusb->tag = cbw->tag; + f_rkusb->in_req->complete = tx_handler_send_csw; + + rockusb_tx_write((char *)chip_info, sizeof(chip_info)); +} + static void cb_write_lba(struct usb_ep *ep, struct usb_request *req) { ALLOC_CACHE_ALIGN_BUFFER(struct fsg_bulk_cb_wrap, cbw, @@ -661,7 +703,7 @@ static const struct cmd_dispatch_info cmd_dispatch_info[] = { }, { .cmd = K_FW_GET_CHIP_VER, - .cb = cb_not_support, + .cb = cb_get_chip_version, }, { .cmd = K_FW_LOW_FORMAT,