From mboxrd@z Thu Jan 1 00:00:00 1970 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 13EEDC433F5 for ; Sat, 22 Jan 2022 18:02:20 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A039B81109; Sat, 22 Jan 2022 19:02:18 +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="l0cdvgDA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0C4FD80384; Sat, 22 Jan 2022 19:02:17 +0100 (CET) Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) (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 792CA81109 for ; Sat, 22 Jan 2022 19:02:14 +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-x130.google.com with SMTP id i1so4338625ils.5 for ; Sat, 22 Jan 2022 10:02:14 -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=cVQCugtU/eqaeMSPtAKXcht8s4yoRqcaVkEt/C0zUyU=; b=l0cdvgDASllnkke4HXORuVfWimEGr2IhtHRUqgyAFvlQGFVJvUbi8bD1CRJhLkqOGh GT1siU9UeKVRFExaMhCFZBkA8UARZNMjNzNM5e2uhK0NOzdS0eoKW9ov0jl5gAJu9mmf S61AFrNQXuBANbzI+mKJSO04daLKjwdCrTpqIrPZfAxC7Ss0KPnp5Yel806t5U1I+rdW dt6IG7bngAR4dJ+FEIA9BxOlkucj2HEZGljniAAYaZxnAK2ps0B3pOzhfcfpxGzu1aGI kolTf/kcPBUUIezVPvip8iUODdYmlCYzkc9hcrdKYG4jDjliqaqK6ANZUZ9HooNwZQby LtuA== 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=cVQCugtU/eqaeMSPtAKXcht8s4yoRqcaVkEt/C0zUyU=; b=VvY/uTjMqMA/FJ6dgO6ozThe6aCc3dzIDEztC+Fl1nNOCcCvA+qeu8BWg+V6AQzX2r ABkO1if0G8/ic4YS68QmwONKmrkqhAUUFZsrpD92AWtc8EwrkDlZ76DcUpq9DNBMBf+g MIJmiUg0ymkcOF04+Ovh4PNv8lhNHNAo1CUrVvZ2mxlQah7mCsGWha0ZMJvg08e6t3vS sWqm/LyPU8k1NhZkpRdkKLrgCEWHGxmdbe9WrILvezuDnQxGiTBWvxZ0/kWlbB+kcxVW 3RmKveOMNhGw8bW/acyOEfX1ScMeTAGCMwooIhOjpsRcj2mWRBaRtBopLCRHn1wgU2x1 RFTA== X-Gm-Message-State: AOAM531rEle6qC8xDMpb5GB+keD7Yyz3SIVrYWOYFWw/FP7g4z+U1VLY zDiO4SwwfihsnRMYDLWs087PfYwHZ0g= X-Google-Smtp-Source: ABdhPJyWy09Ae5bTw3zTXr6DwTPqx0uDg/Q3a+gzW2gr0V15HuZjQvB8plzJhUcMeP0e2XIAB9eHiA== X-Received: by 2002:a05:6e02:1686:: with SMTP id f6mr5220916ila.298.1642874532652; Sat, 22 Jan 2022 10:02:12 -0800 (PST) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:6f25:fae8:96cf:3bfc]) by smtp.gmail.com with ESMTPSA id r5sm5088775ilb.8.2022.01.22.10.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Jan 2022 10:02:12 -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 V3] phy: nop-phy: Enable reset-gpios support Date: Sat, 22 Jan 2022 12:02:02 -0600 Message-Id: <20220122180202.13583-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.5 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 --- V3: Encapsulate the nop_phy_ops reference to nop_phy_reset in an if-def so it doesn't appear when DM_GPIO is not enabled. 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..eac00953d3 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,9 @@ static const struct udevice_id nop_phy_ids[] = { static struct phy_ops nop_phy_ops = { .init = nop_phy_init, +#if CONFIG_IS_ENABLED(DM_GPIO) + .reset = nop_phy_reset, +#endif }; U_BOOT_DRIVER(nop_phy) = { -- 2.32.0