From patchwork Sun Jan 28 20:22:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 10187963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 987076056F for ; Sun, 28 Jan 2018 20:23:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8764E2870C for ; Sun, 28 Jan 2018 20:23:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C3592870D; Sun, 28 Jan 2018 20:23:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF6EB2870F for ; Sun, 28 Jan 2018 20:23:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=elPnmoUuEClNO1joFr3yK9yZGDCpJDJiXaUguq8tK6k=; b=X6esGMg5ftWlrZtYMo81VbYo6t a2qd/4hkxbsb4scsBfw9sXgA90Igdz0pWBmlMQli9qKQ1hmj4j0m22PFJCsIZrwupY9IUxQRKLY/L mhqcgTs9rMbkzW3JjwPD2qQb3d2K8CmdfvN4YbxwK3FdPa9G6PHaZE8xP4WsCLfZM3iXtxqbHrbBc hLyKChKt5osFI/VP6DRE28VffkVir548ojfA3v0blj8KA05lzjqOm6tOsm0f/uDdkuzMMr1lH9uLv xsudw2kaoe5xmUmAdyN9nUpOdZncRwLeiaeA5+N7w3bCA3IG5NtqS7obthPVRc1DUlyE8TWvq0QBp 36SOpF2g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eftUE-00080H-V8; Sun, 28 Jan 2018 20:23:34 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eftUA-0007vN-9m for linux-amlogic@lists.infradead.org; Sun, 28 Jan 2018 20:23:32 +0000 Received: by mail-wm0-x242.google.com with SMTP id v71so30012697wmv.2 for ; Sun, 28 Jan 2018 12:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EDESj7WE9zybaoe0Wu2aFAM2xoIDWN1ohKw3ZRXkJsE=; b=pul4zsBU6BKZsnqzvpr4qJKniCteZHZ9TyasneB9K1CbxOu/SId+/r840XNOkK42M1 p8za68suDfOlCK+3zDsUSvN+go4D/0Umhl10mumbaKSR2XGlHMtTYkCOBoixbcQN6DUI zIdRWRoxKEgfEabvXbsCNsHRF4SwkWuDNc/E92lAYZ1NWKn90NqyH513qYebknYnNQ7I zXpleuT0lY/Yd2qIeAnfZKPt2nGccauUus41MAZ2dqOKIdntyM3wBkLQQas4TjYYJDon PDi8aehGOMzsrJbZ66wWCUp/NFRyIILrUxlDa9yLEhCzXuGK1zzUolaamgZDuFttFABa 9zog== 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=EDESj7WE9zybaoe0Wu2aFAM2xoIDWN1ohKw3ZRXkJsE=; b=ArRPL6IAMzQFEfN1/W9kp21Ws9wp2l9aX8KSM17k3eQJtMM+LtSTUWkXeymDsgVmc9 zmkefrnxtkKin/x68keVF9YoCSoZTgFmGdrGi6mOjYJC3uZHcZauzx3LgUaiaSUnISsR pXqBNrpk4nkE/cBOOUuq8Bl2ulaKktnuBP/L+CiVcd1DI1NUJAowsHaEpABmS4FiDuxZ zo4WCPZ95PC0pjeKbk8ewNSxYNP1yjNll1rcmjv0LsQ+/5eZHWgT8EEDJbjcuLuythMt gLxxM01hoHqB3yOvhxyZg6WxtnqMgIEvwOm5uMeBMI3i+HTZlE9TQgWwZlqgEhjYG1cT kAkA== X-Gm-Message-State: AKwxytceGMfFHFzKxEDfMayMfzPLxRV0Bj5LiDcUvOdH/uurKznox1i4 kPxLCmwCzGTkDSfG7OTzI0o= X-Google-Smtp-Source: AH8x224HN1WodNAkkE2Mex2UDYcp+v2NxJqqMJq4k23sH+84Qjcx7/iSAm9xY/j3SaWrpsYShOY+Bg== X-Received: by 10.28.37.5 with SMTP id l5mr6115908wml.143.1517170998154; Sun, 28 Jan 2018 12:23:18 -0800 (PST) Received: from blackbox.darklights.net (p5DD9B288.dip0.t-ipconnect.de. [93.217.178.136]) by smtp.googlemail.com with ESMTPSA id f8sm5687369wmc.3.2018.01.28.12.23.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jan 2018 12:23:17 -0800 (PST) From: Martin Blumenstingl To: robh+dt@kernel.org, mark.rutland@arm.com, kishon@ti.com, devicetree@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 2/5] phy: amlogic: phy-meson-gxl-usb2: support the clock and reset line Date: Sun, 28 Jan 2018 21:22:42 +0100 Message-Id: <20180128202245.25021-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180128202245.25021-1-martin.blumenstingl@googlemail.com> References: <20180128202245.25021-1-martin.blumenstingl@googlemail.com> X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: narmstrong@baylibre.com, Martin Blumenstingl , khilman@baylibre.com, yixun.lan@amlogic.com, carlo@caione.org, jbrunet@baylibre.com MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The Meson GXL USB2 PHYs require an additional clock (USB) which has to be enabled. If that clock is disabled then all PHY registers read 0x0. Luckily for us that clock is always enabled (either by harddware defaults, the bootrom, or any of the bootloaders before u-boot/BL3-3). The OTG capable USB2 PHY additionally has a reset line (USB_OTG, which is shared with other components, such as the USB3 PHY for example). Extend the driver so it handles this clock and the shared reset line. We only trigger the reset during the .init phase since it's a shared reset line, so triggering it during the driver's .reset implementation would effectively also only trigger it once anyways. Signed-off-by: Martin Blumenstingl --- drivers/phy/amlogic/phy-meson-gxl-usb2.c | 44 ++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/phy/amlogic/phy-meson-gxl-usb2.c b/drivers/phy/amlogic/phy-meson-gxl-usb2.c index e90c4ee25dfe..303b2b46af3c 100644 --- a/drivers/phy/amlogic/phy-meson-gxl-usb2.c +++ b/drivers/phy/amlogic/phy-meson-gxl-usb2.c @@ -11,11 +11,13 @@ * along with this program. If not, see . */ +#include #include #include #include #include #include +#include #include #include #include @@ -99,6 +101,8 @@ struct phy_meson_gxl_usb2_priv { struct regmap *regmap; enum phy_mode mode; int is_enabled; + struct clk *clk; + struct reset_control *reset; }; static const struct regmap_config phy_meson_gxl_usb2_regmap_conf = { @@ -108,6 +112,31 @@ static const struct regmap_config phy_meson_gxl_usb2_regmap_conf = { .max_register = U2P_R3, }; +static int phy_meson_gxl_usb2_init(struct phy *phy) +{ + struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); + int ret; + + ret = reset_control_reset(priv->reset); + if (ret) + return ret; + + ret = clk_prepare_enable(priv->clk); + if (ret) + return ret; + + return 0; +} + +static int phy_meson_gxl_usb2_exit(struct phy *phy) +{ + struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); + + clk_disable_unprepare(priv->clk); + + return 0; +} + static int phy_meson_gxl_usb2_reset(struct phy *phy) { struct phy_meson_gxl_usb2_priv *priv = phy_get_drvdata(phy); @@ -195,6 +224,8 @@ static int phy_meson_gxl_usb2_power_on(struct phy *phy) } static const struct phy_ops phy_meson_gxl_usb2_ops = { + .init = phy_meson_gxl_usb2_init, + .exit = phy_meson_gxl_usb2_exit, .power_on = phy_meson_gxl_usb2_power_on, .power_off = phy_meson_gxl_usb2_power_off, .set_mode = phy_meson_gxl_usb2_set_mode, @@ -240,6 +271,19 @@ static int phy_meson_gxl_usb2_probe(struct platform_device *pdev) if (IS_ERR(priv->regmap)) return PTR_ERR(priv->regmap); + priv->clk = devm_clk_get(dev, "phy"); + if (IS_ERR(priv->clk)) { + ret = PTR_ERR(priv->clk); + if (ret == -ENOENT) + priv->clk = NULL; + else + return ret; + } + + priv->reset = devm_reset_control_get_optional_shared(dev, "phy"); + if (IS_ERR(priv->reset)) + return PTR_ERR(priv->reset); + phy = devm_phy_create(dev, NULL, &phy_meson_gxl_usb2_ops); if (IS_ERR(phy)) { dev_err(dev, "failed to create PHY\n");