Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31498C07E95 for ; Thu, 8 Jul 2021 01:09:05 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 574E261CD7 for ; Thu, 8 Jul 2021 01:09:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 574E261CD7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B74B282EE6; Thu, 8 Jul 2021 03:08:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="PR1/V/Ou"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1B19482E94; Thu, 8 Jul 2021 03:08:40 +0200 (CEST) Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 015BA82E94 for ; Thu, 8 Jul 2021 03:08:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vincent.chen@sifive.com Received: by mail-pg1-x534.google.com with SMTP id y17so4168129pgf.12 for ; Wed, 07 Jul 2021 18:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z4zqX/PFQP1Ng5g/nmNcLF7TH/sYuZVD62Wf75lejxw=; b=PR1/V/Oug5ZuDFZGDtFNN7rvx+wae7fTE+6YC+ci9i0LKqQY57bfDhyX8PwRSkgINV a6vQmXtAmPEt+EOukkqm0lTE/UJp5c180jiK+unUzhNGeilsnANSq4uqHcQooTMO3FtG RiEDMDKALBucAjS1hR90SFE9BGB0jMg9biz0cOQu+9XWNvbZd4005wMMJH9Kb9g7J7rC Xuow1R9jG0q/alHqQtKXlVY0R5PrDRcchPK68pcFsNoURBo+zW0EE/Hviz5aVinLl/e2 bWdSYhRwuTdkXWp2TsxVQw1DU6iBw207YSqol8wxNC3YZ8tLfAf4pRT4OVR87E3wqPig mO/w== 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=z4zqX/PFQP1Ng5g/nmNcLF7TH/sYuZVD62Wf75lejxw=; b=YhRQvKRhVmH0nV6le1+cKjwwjE3slDlpf+A7Zvo9yZ3M3HDpdLIyxzkTFi5wajx6Cu ky+Ts2E8bgCl+bCqXV7u2GPM7tDersD4am/Lv54qx3oZZb6reTvHn0Jq9i110kY6KaZJ vNqtLDKDiliSHsvtXRiFb/4liGoHxV6GEKr1bZxONBK/FSn6rPQnlvqmEb74hrPkRa6F RvclH/R+bZ1sWUtzfKE9wkzNMnVJS3EWHuqz2PFfib3VZmvhNmjbHXbkhse4dcv08l/+ v0GsJYj0FnDMSfrC/MF3+2wqwGcsvlkVn9zq05hJEhYu+2//Lh4omHSCxMMaIcPI/UJx GA2Q== X-Gm-Message-State: AOAM533uKfuaTLQ2yq5bA17Mn6vtJmBHmbqPiOHIX1JyDWum2Bu84WW6 yfevor04s4HVtkbw8/azvoBxIw== X-Google-Smtp-Source: ABdhPJybIEr4qcgN+fgMLzfoRl9HgqzhWEMpEG97Slq7zYSVYtbc1NNgAnLKAP1VCKZEySun/rqxMA== X-Received: by 2002:aa7:8d01:0:b029:311:47d0:f169 with SMTP id j1-20020aa78d010000b029031147d0f169mr15228712pfe.78.1625706515283; Wed, 07 Jul 2021 18:08:35 -0700 (PDT) Received: from localhost.localdomain (111-243-35-231.dynamic-ip.hinet.net. [111.243.35.231]) by smtp.gmail.com with ESMTPSA id o1sm352321pjf.56.2021.07.07.18.08.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jul 2021 18:08:35 -0700 (PDT) From: Vincent Chen To: green.wan@sifive.com, rick@andestech.com, bmeng.cn@gmail.com, ycliang@andestech.com, u-boot@lists.denx.de Cc: vincent.chen@sifive.com Subject: [PATCH 2/2] board: sifive: unmatched: reset USB hub, PCIe-USB bridge, and ULPI device in SPL Date: Thu, 8 Jul 2021 09:08:21 +0800 Message-Id: <1625706501-964-3-git-send-email-vincent.chen@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1625706501-964-1-git-send-email-vincent.chen@sifive.com> References: <1625706501-964-1-git-send-email-vincent.chen@sifive.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Ensure USB hub, PCIe-USB bridge, and ULPI device to be reset even if the rebooting is without power-cycling. Signed-off-by: Vincent Chen --- board/sifive/unmatched/spl.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c index b598f9f..d566327 100644 --- a/board/sifive/unmatched/spl.c +++ b/board/sifive/unmatched/spl.c @@ -16,6 +16,9 @@ #include #include +#define UBRDG_RESET SIFIVE_GENERIC_GPIO_NR(0, 7) +#define ULPI_RESET SIFIVE_GENERIC_GPIO_NR(0, 9) +#define UHUB_RESET SIFIVE_GENERIC_GPIO_NR(0, 11) #define GEM_PHY_RESET SIFIVE_GENERIC_GPIO_NR(0, 12) #define MODE_SELECT_REG 0x1000 @@ -61,6 +64,21 @@ static inline int spl_gemgxl_init(void) return ret; } +static inline int spl_usb_pcie_bridge_init(void) +{ + return spl_reset_device_by_gpio("usb_pcie_bridge_reset", UBRDG_RESET, 3000); +} + +static inline int spl_usb_hub_init(void) +{ + return spl_reset_device_by_gpio("usb_hub_reset", UHUB_RESET, 100); +} + +static inline int spl_ulpi_init(void) +{ + return spl_reset_device_by_gpio("ulpi_reset", ULPI_RESET, 1); +} + int spl_board_init_f(void) { int ret; @@ -77,6 +95,24 @@ int spl_board_init_f(void) goto end; } + ret = spl_usb_pcie_bridge_init(); + if (ret) { + debug("USB Bridge (ASM1042A) init failed: %d\n", ret); + goto end; + } + + ret = spl_usb_hub_init(); + if (ret) { + debug("USB Hub (ASM1074) init failed: %d\n", ret); + goto end; + } + + ret = spl_ulpi_init(); + if (ret) { + debug("USB 2.0 PHY (USB3320C) init failed: %d\n", ret); + goto end; + } + end: return ret; } -- 2.7.4