From patchwork Tue Dec 18 09:52:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 154132 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3505071ljp; Tue, 18 Dec 2018 01:55:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/U/3V7nAMNJ3S/Ni4f8FoArRBxIPt0k31HdFOr9EzfABoFIG0LInwZzOECTvGWdCTp6znIT X-Received: by 2002:a50:8fe4:: with SMTP id y91mr15711042edy.231.1545126904727; Tue, 18 Dec 2018 01:55:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545126904; cv=none; d=google.com; s=arc-20160816; b=cm5gRpCwAZUTYSh06ftuiR9lHlr4w8cHvfRnjrAx/sEDip9xhGbE8EEn0R/XtRa3I+ 1GHL8gKurntb30sJY26653MNK55GngmcHrOjINFoNSCPHK+W4+/dK5CzWRk/FkisFjKm 4LVfVsCfw7Bnnh042HTYv/1D9W6fBSVRWBkoi5vfSvR5IP1D+sqXgMVB6bLJ5Y9GQoRG KUinpgTRWat1M0NNd1XcCujZoK+FLbSLt4dmnJ1KfSjBCLpxA0jb/SWJW4y8+U+DyA/n QsmlR8xnyvG/xOiRDKQuoxN4kVJq9QlfCcWFAikQ2T37kW50d3xofnhBdgqYRT0ZL35L tHWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature; bh=ZrpARfizf76qaGD8mi61dBTO5xO//kQ1tmU3EqGELFM=; b=gNcQf0Owpw7Hjlir8S9816l1McmLfGsXLcrXFEWwQxGsrO98P99H3tijxdsBCwQEy2 F2aBGYbRPHPTOUBqqYbrBkMaEeE+B74ZfpHBNqaZNWqsPm8QPuZqUpxhXENbeikZIThA ykrEaSKZbjJzeZsO9VRSz2TsRXJcyv4C7gmw3LiQ3SryliEp2qff5XRtJkbIV6wGNoQv h3U4Aa6ztxHAjZRTJMP39/u6Y6E+K8SN2kndpfufOwFk/+WYpVAN7NOphg3HVpK2u2LE NBK42U5cFnOj3ka6SYYYKGNy1yaILI2EDUlElyloCpSCwnpoXkoQllCtxYws8/mH0o1T 6YTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V+1xwcZh; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id f14si3574697edw.282.2018.12.18.01.55.04; Tue, 18 Dec 2018 01:55:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=V+1xwcZh; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 51C2BC221B1; Tue, 18 Dec 2018 09:54:00 +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_DNSWL_NONE, 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 320C3C221C6; Tue, 18 Dec 2018 09:53:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0D350C2200D; Tue, 18 Dec 2018 09:53:27 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by lists.denx.de (Postfix) with ESMTPS id F1FA5C22088 for ; Tue, 18 Dec 2018 09:53:23 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id b85so7896114pfc.3 for ; Tue, 18 Dec 2018 01:53:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ePzIhDrHtBShgkgH3kUHRjKROKBloyPC9Al6GnURIuw=; b=V+1xwcZhsa10lkKPgYMv5wRQVQt0T/Vb9ngCLladM1UvSikHT12JGvMqHp+S9Sl0Wb Q0nx42C63iQXd2a7s+P5KJy3+APdIjw5sBfwfZD9IxBk0v7Kz0x++sxwVq5lauqr3lQJ zrAzCgTU9+LjtrN3A2TQpLlTwUfmOV7dRHHx4= 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=ePzIhDrHtBShgkgH3kUHRjKROKBloyPC9Al6GnURIuw=; b=t3+s0RzRCo0citdd4xG9BZmo6bzH2Wb1V1X/Dyy+7wUzRdHNIcL8zqkAKdGM21kiOc loYqn8L3QW0JfR9/Jurq/iTf/jNHNWezYxWfgOjuNQlcygjeVLOz6GMRM143w5L+C1DI 6wIo1/AdzedQzrY/4i6CzPKSlHnetV39MBLs7/DtPMyL90dnhRor4ZeRTyEOYNefst9T gBNaSg3yi1f9el0Dea8LeTts7xldiBQiiL3SjGgGaiWNZnCHYFU8EoLOcb1MKbM7+la2 jwTWjoWnvn8W/3tklc+8eVp2nsebq8MBKqOrw+N2yjkGTXTCs8F2CfPKdFiAsTaYxC+8 GINA== X-Gm-Message-State: AA+aEWYL28ISQyUlzzeWqL+sqgA4SR24m6IwO07AFUWT9zMIsCD10WK9 Y1DJh1K73HJ7O9fmRXSr+09N2afT9r7wBQ== X-Received: by 2002:a63:b105:: with SMTP id r5mr15276345pgf.442.1545126802627; Tue, 18 Dec 2018 01:53:22 -0800 (PST) Received: from localhost.localdomain (61-216-91-114.HINET-IP.hinet.net. [61.216.91.114]) by smtp.gmail.com with ESMTPSA id l69sm30817514pfb.75.2018.12.18.01.53.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Dec 2018 01:53:21 -0800 (PST) From: Shawn Guo To: Tom Rini Date: Tue, 18 Dec 2018 17:52:06 +0800 Message-Id: <20181218095207.11620-2-shawn.guo@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20181218095207.11620-1-shawn.guo@linaro.org> References: <20181218095207.11620-1-shawn.guo@linaro.org> Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 1/2] poplar: add DWC2 OTG gadget support 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" It enables DWC2 OTG gadget driver support for Poplar board. As usb2_phy_init() is being always called from board_init(), we can save the call from board_usb_init(). Signed-off-by: Shawn Guo --- .../asm/arch-hi3798cv200/hi3798cv200.h | 5 ++++ board/hisilicon/poplar/poplar.c | 28 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/arch/arm/include/asm/arch-hi3798cv200/hi3798cv200.h b/arch/arm/include/asm/arch-hi3798cv200/hi3798cv200.h index f97b1eb29f84..bb221e17e0ed 100644 --- a/arch/arm/include/asm/arch-hi3798cv200/hi3798cv200.h +++ b/arch/arm/include/asm/arch-hi3798cv200/hi3798cv200.h @@ -13,11 +13,16 @@ /* DEVICES */ #define REG_BASE_MCI 0xF9830000 #define REG_BASE_UART0 0xF8B00000 +#define HIOTG_BASE_ADDR 0xF98C0000 /* PERI control registers (4KB) */ /* USB2 PHY01 configuration register */ #define PERI_CTRL_USB0 (REG_BASE_PERI_CTRL + 0x120) + /* USB2 controller configuration register */ +#define PERI_CTRL_USB3 (REG_BASE_PERI_CTRL + 0x12c) +#define USB2_2P_CHIPID (1 << 28) + /* PERI CRG registers (4KB) */ /* USB2 CTRL0 clock and soft reset */ #define PERI_CRG46 (REG_BASE_CRG + 0xb8) diff --git a/board/hisilicon/poplar/poplar.c b/board/hisilicon/poplar/poplar.c index e1fbd5d0c669..af018ad2f8e4 100644 --- a/board/hisilicon/poplar/poplar.c +++ b/board/hisilicon/poplar/poplar.c @@ -168,6 +168,34 @@ int board_mmc_init(bd_t *bis) } #endif +#if defined(CONFIG_USB_GADGET) && defined(CONFIG_USB_GADGET_DWC2_OTG) +#include +#include +#include + +static struct dwc2_plat_otg_data poplar_otg_data = { + .regs_otg = HIOTG_BASE_ADDR +}; + +static void set_usb_to_device(void) +{ + setbits_le32(PERI_CTRL_USB3, USB2_2P_CHIPID); +} + +int board_usb_init(int index, enum usb_init_type init) +{ + set_usb_to_device(); + return dwc2_udc_probe(&poplar_otg_data); +} + +int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name) +{ + if (!env_get("serial#")) + g_dnl_set_serialnumber("0123456789POPLAR"); + return 0; +} +#endif + int board_init(void) { usb2_phy_init();