Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id EC71FC433F5 for ; Mon, 17 Jan 2022 23:46:21 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1F829834A0; Tue, 18 Jan 2022 00:46:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="Rxeu/iQg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3109E82A71; Tue, 18 Jan 2022 00:46:17 +0100 (CET) Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) (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 8C636836E6 for ; Tue, 18 Jan 2022 00:46:13 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aford173@gmail.com Received: by mail-il1-x12e.google.com with SMTP id a2so10234283ilr.0 for ; Mon, 17 Jan 2022 15:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tBsf9ImFkUiBRiT/N5YOKjrcIU06xEbdrbQZi+IjXT8=; b=Rxeu/iQgYqG4TXJ8T8rRuE698VhRQjkSg2U32FwgIDEy7IlIOXp8xC3sGf1JKp1fIN QWE3gn2SqxyAxcPqUuwxb7k/cQxy58C6VtnUeF4RcK8lNtsqdqDlbgt9NHqWmvN7zZcQ dgw8boV0e6bHlqRwkBUL15zDRY2XMasTr2O/H0664QeWQmzwbwkbQkJChcAzBwtO6N0w SCGgEcPjwUiXjUvRxzgakddVUVGhAb1oxCInXNjnQv8BeWeHBt/miJZYje/87jm/ER3C wt+ga1Kzx7nkHVPnpP9p6fSVqU8Ugy1yo+YxCzCYxhBZo+3TeAkLlGWWDsV4MglQWkCr ejKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tBsf9ImFkUiBRiT/N5YOKjrcIU06xEbdrbQZi+IjXT8=; b=QR4Jutln/n5wmpHgAfurtBwlHAl7FqUUcYIFlhmZxc3/5HVQsFSG2wbgg1wvikmcnB KGJHHfHlYpCZQ4re9X3/uRRtQg21F/HU7IowtqJqpv9elh1yGkdhv5l4+HIlcGJNw4sH N0V2xHwoIIVwwklzy8foOWvXoSHkzg4gnqtWoCuYsMCeA3kJQvIT8i8IvHf1A2lV/C4V pPObwobtN+FlvR8jziLbWJbBjzN07ic3bvVkcycLGQeB5+6qaPj6n4a90CAuFKj/F3NR QukryBwd9MXxND5ily0j/rRl97sucoAYRQ7o8dFzNXSsK8VYsd46xmALmkmx85U6ln3s 9D+w== X-Gm-Message-State: AOAM532kQ6nLwWGRxVbUrBnFa6VhJo3R8qpl9jzLvTW3hlxU4je2rgAw sGiV9nllT6+WYsLVX6kuMtmUL10X+Gs= X-Google-Smtp-Source: ABdhPJySCfJM0Xo3z0O0r30d8fcrsZEP2+z1e1ygKzQ6bJlA/BcM7KZa0ECJPKtb030caFR5A27mmA== X-Received: by 2002:a92:cd8e:: with SMTP id r14mr12181352ilb.259.1642463171641; Mon, 17 Jan 2022 15:46:11 -0800 (PST) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:a8b:557:cea0:b490]) by smtp.gmail.com with ESMTPSA id v5sm11169114ilu.77.2022.01.17.15.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jan 2022 15:46:11 -0800 (PST) From: Adam Ford To: u-boot@lists.denx.de Cc: marex@denx.de, trini@konsulko.com, aford@beaconembedded.com, Adam Ford Subject: [PATCH V2] phy: nop-phy: Enable reset-gpios support Date: Mon, 17 Jan 2022 17:45:59 -0600 Message-Id: <20220117234559.108600-1-aford173@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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 Some usb-nop-xceiv devices use a gpio to put them in and out of reset. Add a reset function to put them into that state. This is similar to how Linux handles the usb-nop-xceiv driver. Signed-off-by: Adam Ford --- V2: Only use the GPIO functions when DM_GPIO is enabled Add error handling so if the GPIO fails, it will shutdown the clocks and return with the error code. Call nop_phy_reset() instead of repeating the same code. diff --git a/drivers/phy/nop-phy.c b/drivers/phy/nop-phy.c index 9f12ebc062..2be3d4039b 100644 --- a/drivers/phy/nop-phy.c +++ b/drivers/phy/nop-phy.c @@ -10,17 +10,47 @@ #include #include #include +#include struct nop_phy_priv { struct clk_bulk bulk; +#if CONFIG_IS_ENABLED(DM_GPIO) + struct gpio_desc reset_gpio; +#endif }; +#if CONFIG_IS_ENABLED(DM_GPIO) +static int nop_phy_reset(struct phy *phy) +{ + struct nop_phy_priv *priv = dev_get_priv(phy->dev); + + /* Return if there is no gpio since it's optional */ + if (!dm_gpio_is_valid(&priv->reset_gpio)) + return 0; + + return dm_gpio_set_value(&priv->reset_gpio, false); +} +#endif + static int nop_phy_init(struct phy *phy) { struct nop_phy_priv *priv = dev_get_priv(phy->dev); + int ret = 0; + + if (CONFIG_IS_ENABLED(CLK)) { + ret = clk_enable_bulk(&priv->bulk); + if (ret) + return ret; + } - if (CONFIG_IS_ENABLED(CLK)) - return clk_enable_bulk(&priv->bulk); + if (CONFIG_IS_ENABLED(DM_GPIO)) { + ret = nop_phy_reset(phy); + if (ret) { + if (CONFIG_IS_ENABLED(CLK)) + clk_disable_bulk(&priv->bulk); + return ret; + } + } return 0; } @@ -38,6 +68,12 @@ static int nop_phy_probe(struct udevice *dev) } } + ret = gpio_request_by_name(dev, "reset-gpios", 0, + &priv->reset_gpio, + GPIOD_IS_OUT); + if (ret != -ENOENT) + return ret; + return 0; } @@ -49,6 +85,7 @@ static const struct udevice_id nop_phy_ids[] = { static struct phy_ops nop_phy_ops = { .init = nop_phy_init, + .reset = nop_phy_reset, }; U_BOOT_DRIVER(nop_phy) = { -- 2.32.0