From patchwork Thu Jul 8 01:08:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 1502064 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=ezmU68Jd; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GKyqG3mJxz9sXN for ; Thu, 8 Jul 2021 11:08:58 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BCCB82EAC; Thu, 8 Jul 2021 03:08:41 +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="ezmU68Jd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C415D82E85; Thu, 8 Jul 2021 03:08:37 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) (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 E8C8C82E7D for ; Thu, 8 Jul 2021 03:08:34 +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-pf1-x429.google.com with SMTP id w22so3937536pff.5 for ; Wed, 07 Jul 2021 18:08:34 -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=ZHzaiXJiAX9us0a/e5oMJ6RTwBYocKly19JWC31ca+c=; b=ezmU68JdiVlATKaWt0UVwVPvfxJcsTGZO/FVE5DjMAJ4SGXSaCW4UlxvYTv/4ED6M2 ySqFUP0E2E7ouhEV2SllG4T5oKRgwCmaVwXXTY1LWnDOej1/ZpjLsfr/qmOjG2VwkW5f lxWXbCZrZWMf+i+ke+OCeo46C3RG+bktcRzb5dalvSdwYZK6BCg92IINXdEMAbEeQGGs 34NLU2F2I6/+bWU1FVX0IbSQTewDFKNkBjQznchCwo7E+UJeH5XW74126Wg3MXbDVUxr WoQAwf0Lm8XltuqOwywtw7EpUgl/Ie1MC4bK5GMG3qfESqAwLLmhYQCe3dZP3YlT3lXm u4SA== 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=ZHzaiXJiAX9us0a/e5oMJ6RTwBYocKly19JWC31ca+c=; b=Wxabs4Nnl2sKvmmaLLkxQH14mxY8bvLS37T5Iw0YN7rx/DVjqF/QjGbCHa6DI+lV9Y 6L2YBBsYcX/fxy3kktL5J2LEZSvAAFsxQPfvQsimSBApzhvHeRakuMZCCZILd7SrNhGj CxO4AjPQatZzVvsFe/EUw5fntZYEQz2qeT+KLCddq+M4ihSvpFFt9o3YReIuNTlPBbn/ 9qytezm87zG42A4hqyyrEwFHXrvar9BrI8iP5h4zKW39inbEk/b+rUfhzSEtL2HPvpOu ncjhDlv+djKsAqeyFZYbwSAoK+yXD0TI/cnot90LQMyBVAO6scI/Dlq60XoDv5TiFke7 qrwg== X-Gm-Message-State: AOAM531mkO9iZBv4Kw+ykAaiLStRUqFo3fy2MpEd+fYqVkkS3jSg7MLN ThQZUpJfPquFre5QJZPirX7ssg== X-Google-Smtp-Source: ABdhPJw9QtuG6o9J4DOMWZM90l29T7k5dG1oRRt5ykt/Lp+NWHdm2r15NF7L2/9nHtx3Pu8gO22P0w== X-Received: by 2002:a62:d41e:0:b029:305:b3ff:4056 with SMTP id a30-20020a62d41e0000b0290305b3ff4056mr27723282pfh.78.1625706513301; Wed, 07 Jul 2021 18:08:33 -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.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jul 2021 18:08:33 -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 1/2] board: sifive: unmatched: refine GEMGXL initialized function in SPL Date: Thu, 8 Jul 2021 09:08:20 +0800 Message-Id: <1625706501-964-2-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 Create a new function spl_reset_device_by_gpio to reset the device whose reset pin is connected to the GPIO. Then, using this function to initialize GEMGXL. Signed-off-by: Vincent Chen Reviewed-by: Leo Yu-Chi Liang --- board/sifive/unmatched/spl.c | 58 +++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c index 5e1333b..b598f9f 100644 --- a/board/sifive/unmatched/spl.c +++ b/board/sifive/unmatched/spl.c @@ -22,43 +22,63 @@ #define MODE_SELECT_SD 0xb #define MODE_SELECT_MASK GENMASK(3, 0) -int spl_board_init_f(void) +static inline int spl_reset_device_by_gpio(const char *label, int pin, int low_width) { int ret; - ret = spl_soc_init(); + ret = gpio_request(pin, label); if (ret) { - debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret); + debug("%s gpio request failed: %d\n", label, ret); + return ret; + } + + ret = gpio_direction_output(pin, 1); + if (ret) { + debug("%s gpio direction set failed: %d\n", label, ret); return ret; } + udelay(1); + + gpio_set_value(pin, 0); + udelay(low_width); + gpio_set_value(pin, 1); + + return ret; +} + +static inline int spl_gemgxl_init(void) +{ + int ret; /* * GEMGXL init VSC8541 PHY reset sequence; * leave pull-down active for 2ms */ udelay(2000); - ret = gpio_request(GEM_PHY_RESET, "gem_phy_reset"); + ret = spl_reset_device_by_gpio("gem_phy_reset", GEM_PHY_RESET, 1); + mdelay(15); + + return ret; +} + +int spl_board_init_f(void) +{ + int ret; + + ret = spl_soc_init(); if (ret) { - debug("gem_phy_reset gpio request failed: %d\n", ret); - return ret; + debug("HiFive Unmatched FU740 SPL init failed: %d\n", ret); + goto end; } - /* Set GPIO 12 (PHY NRESET) */ - ret = gpio_direction_output(GEM_PHY_RESET, 1); + ret = spl_gemgxl_init(); if (ret) { - debug("gem_phy_reset gpio direction set failed: %d\n", ret); - return ret; + debug("Gigabit ethernet PHY (VSC8541) init failed: %d\n", ret); + goto end; } - udelay(1); - - /* Reset PHY again to enter unmanaged mode */ - gpio_set_value(GEM_PHY_RESET, 0); - udelay(1); - gpio_set_value(GEM_PHY_RESET, 1); - mdelay(15); - - return 0; +end: + return ret; } u32 spl_boot_device(void) From patchwork Thu Jul 8 01:08:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 1502066 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.a=rsa-sha256 header.s=google header.b=PR1/V/Ou; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GKyqQ3lJ2z9sfR for ; Thu, 8 Jul 2021 11:09:06 +1000 (AEST) 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) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 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 Reviewed-by: Leo Yu-Chi Liang --- 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; }