From patchwork Sat May 2 09:35:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Wunderlich X-Patchwork-Id: 1281807 X-Patchwork-Delegate: marek.vasut@gmail.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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=QpjxpMuA; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 49F87K3KFBz9sPF for ; Sun, 3 May 2020 11:49:49 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9BEFC81E99; Sun, 3 May 2020 03:48:04 +0200 (CEST) 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="QpjxpMuA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 99AA581D5C; Sat, 2 May 2020 11:35:59 +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,FREEMAIL_FROM,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (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 E8CFC81D26 for ; Sat, 2 May 2020 11:35:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=frank.wunderlich@gmail.com Received: by mail-wr1-x442.google.com with SMTP id j1so14731477wrt.1 for ; Sat, 02 May 2020 02:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2SmBm0DLV4CdGqNlODogDTHgE+gn40hovoDuDOqmmEU=; b=QpjxpMuAX6RZ2o4Uj8t4uSgJSSnXrzjZbso99hof16VHwKIjXa5ehfqw2Oy3WaUMRK ZMKOxKDTzJd5WkENYcIWWmux3YFf5f4BiVbjtHwbySm5kU06x5yixLvppYVJR444NSti Y5guP79lWR2d/BEZC7+KPn7iN5M6xIC6iMKlzrkk3kJTvQ7+OYX1fo+epJZrD2G0gheE aion+KecgQp4B1duCwD63fcZItwsoVXjuKDnKB5ysRjJAAL22srQwMDarMgQedfdPjnZ H4MF0SH10rzj8bWt8EqL1d3lPkCAvnTkNSpPmJ0O7gOipxnXZuI6XmIkWPq1kN701il+ bR2Q== 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=2SmBm0DLV4CdGqNlODogDTHgE+gn40hovoDuDOqmmEU=; b=i43Kdvg7mAc3KDKoWymxOVgI5lLa4JkeA8dSoopeLnHzxdjK2B/+k9Wp6uHxPtXZUR Bwu79qsOEAjS4QPqPHebiA0dhLSVgp0Sf74Yhnm3oFW+Dw6HYPqO9SYBzszMNDzEbORb /dDZxztBKmP/WdIrQlQVmL8rsTBa/wvaV3Bg9YSLEKHQSe8GsI81gw3zz6fbsbjGAv+j PBtPig1tvOs2nDYayIGUELji/SIy4XHQsxQT9FSy15/dKsw/+P3bGrVDJJI4hL4CyqRC LOl3iNmbYuDZ9T4yqiZ/g4hlbtSYPsaePzWvTffQ6ffN9YBlMysYSbBttdMN1yAX7hbr lhaw== X-Gm-Message-State: AGi0PuZU2ly7suNea6beMW8FEvRtP2U8FQy/qTa4GAw3r02J6aefdYUH mKR/+jLzUSeV06McKNitSgA= X-Google-Smtp-Source: APiQypKW4h04LSM5zhIJRY6vJZHtZWAzXJGDKCXKyyC1wJFe7yhZWYLglkXE/lQZH4OUMegTSFwcNA== X-Received: by 2002:a5d:54d0:: with SMTP id x16mr8206077wrv.86.1588412156600; Sat, 02 May 2020 02:35:56 -0700 (PDT) Received: from localhost.localdomain (fttx-pool-185.76.96.142.bambit.de. [185.76.96.142]) by smtp.gmail.com with ESMTPSA id l16sm8196681wrp.91.2020.05.02.02.35.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2020 02:35:56 -0700 (PDT) From: Frank Wunderlich X-Google-Original-From: Frank Wunderlich To: Simon Glass , Ryder Lee , Marek Vasut , Bin Meng Cc: Frank Wunderlich , Weijie Gao , GSS_MTK_Uboot_upstream , Jagan Teki , Stefan Roese , Neil Armstrong , Sam Shih , Chunfeng Yun , Jean-Jacques Hiblot , Alex Marginean , Patrick Delaunay , Lukasz Majewski , AKASHI Takahiro , Anatolij Gustschin , Ye Li , Fabio Estevam , Marcel Ziswiler , Heiko Schocher , Mark Kettenis , Adam Ford , u-boot@lists.denx.de, Masahiro Yamada , Vignesh Raghavendra Subject: [PATCH v8 09/14] phy: phy-mtk-tphy: add a new reference clock Date: Sat, 2 May 2020 11:35:17 +0200 Message-Id: <20200502093522.3568-10-frank-w@public-files.de> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200502093522.3568-1-frank-w@public-files.de> References: <20200502093522.3568-1-frank-w@public-files.de> X-Mailman-Approved-At: Sun, 03 May 2020 03:47:26 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean From: Chunfeng Yun Usually the digital and analog phys use the same reference clock, but some platforms have two separate reference clocks for each of them, so add another optional clock to support them. In order to keep the clock names consistent with PHY IP's, change the da_ref for analog phy and ref clock for digital phy. Signed-off-by: Chunfeng Yun Signed-off-by: Frank Wunderlich Reviewed-by: Weijie Gao --- v8: no changes v7: no changes v6: add Reviewed-by Weijie v2~v5: no changes --- drivers/phy/phy-mtk-tphy.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/phy/phy-mtk-tphy.c b/drivers/phy/phy-mtk-tphy.c index 20167fe7cb..81525a48b7 100644 --- a/drivers/phy/phy-mtk-tphy.c +++ b/drivers/phy/phy-mtk-tphy.c @@ -199,8 +199,8 @@ struct mtk_phy_instance { struct u3phy_banks u3_banks; }; - /* reference clock of anolog phy */ - struct clk ref_clk; + struct clk ref_clk; /* reference clock of (digital) phy */ + struct clk da_ref_clk; /* reference clock of analog phy */ u32 index; u32 type; }; @@ -450,8 +450,17 @@ static int mtk_phy_init(struct phy *phy) int ret; ret = clk_enable(&instance->ref_clk); - if (ret) + if (ret < 0) { + dev_err(tphy->dev, "failed to enable ref_clk\n"); return ret; + } + + ret = clk_enable(&instance->da_ref_clk); + if (ret < 0) { + dev_err(tphy->dev, "failed to enable da_ref_clk %d\n", ret); + clk_disable(&instance->ref_clk); + return ret; + } switch (instance->type) { case PHY_TYPE_USB2: @@ -502,6 +511,7 @@ static int mtk_phy_exit(struct phy *phy) struct mtk_tphy *tphy = dev_get_priv(phy->dev); struct mtk_phy_instance *instance = tphy->phys[phy->id]; + clk_disable(&instance->da_ref_clk); clk_disable(&instance->ref_clk); return 0; @@ -611,6 +621,11 @@ static int mtk_tphy_probe(struct udevice *dev) &instance->ref_clk); if (err) return err; + + err = clk_get_optional_nodev(subnode, "da_ref", + &instance->da_ref_clk); + if (err) + return err; } return 0;